Example for BBC Micro:bit

Dependencies:   Blynk microbit

Fork of microbit-samples by BBC

Committer:
LancasterUniversity
Date:
Fri Apr 08 16:59:43 2016 +0100
Revision:
2:5b2cd31ac474
Parent:
1:2ee7e607faaa
Synchronized with git rev 8f9a0bcc
Author: Joe Finney
microbit-samples: Added a suite of basic samples

Also introduced MicroBitSamples.h as a simple, cross IDE mechanism to choose
which sample to build.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
LancasterUniversity 1:2ee7e607faaa 1 /*
LancasterUniversity 1:2ee7e607faaa 2 The MIT License (MIT)
LancasterUniversity 1:2ee7e607faaa 3
LancasterUniversity 1:2ee7e607faaa 4 Copyright (c) 2016 British Broadcasting Corporation.
LancasterUniversity 1:2ee7e607faaa 5 This software is provided by Lancaster University by arrangement with the BBC.
LancasterUniversity 1:2ee7e607faaa 6
LancasterUniversity 1:2ee7e607faaa 7 Permission is hereby granted, free of charge, to any person obtaining a
LancasterUniversity 1:2ee7e607faaa 8 copy of this software and associated documentation files (the "Software"),
LancasterUniversity 1:2ee7e607faaa 9 to deal in the Software without restriction, including without limitation
LancasterUniversity 1:2ee7e607faaa 10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
LancasterUniversity 1:2ee7e607faaa 11 and/or sell copies of the Software, and to permit persons to whom the
LancasterUniversity 1:2ee7e607faaa 12 Software is furnished to do so, subject to the following conditions:
LancasterUniversity 1:2ee7e607faaa 13
LancasterUniversity 1:2ee7e607faaa 14 The above copyright notice and this permission notice shall be included in
LancasterUniversity 1:2ee7e607faaa 15 all copies or substantial portions of the Software.
LancasterUniversity 1:2ee7e607faaa 16
LancasterUniversity 1:2ee7e607faaa 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
LancasterUniversity 1:2ee7e607faaa 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
LancasterUniversity 1:2ee7e607faaa 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
LancasterUniversity 1:2ee7e607faaa 20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LancasterUniversity 1:2ee7e607faaa 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
LancasterUniversity 1:2ee7e607faaa 22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
LancasterUniversity 1:2ee7e607faaa 23 DEALINGS IN THE SOFTWARE.
LancasterUniversity 1:2ee7e607faaa 24 */
LancasterUniversity 1:2ee7e607faaa 25
LancasterUniversity 1:2ee7e607faaa 26 #include "MicroBit.h"
LancasterUniversity 2:5b2cd31ac474 27 #include "MicroBitSamples.h"
LancasterUniversity 2:5b2cd31ac474 28
LancasterUniversity 2:5b2cd31ac474 29 #ifdef MICROBIT_SAMPLE_HELLO_WORLD
LancasterUniversity 1:2ee7e607faaa 30
LancasterUniversity 1:2ee7e607faaa 31 MicroBit uBit;
LancasterUniversity 1:2ee7e607faaa 32
LancasterUniversity 1:2ee7e607faaa 33 int main()
LancasterUniversity 1:2ee7e607faaa 34 {
LancasterUniversity 1:2ee7e607faaa 35 // Initialise the micro:bit runtime.
LancasterUniversity 1:2ee7e607faaa 36 uBit.init();
LancasterUniversity 1:2ee7e607faaa 37
LancasterUniversity 1:2ee7e607faaa 38 // Insert your code here!
LancasterUniversity 1:2ee7e607faaa 39 uBit.display.scroll("HELLO WORLD! :)");
LancasterUniversity 1:2ee7e607faaa 40
LancasterUniversity 1:2ee7e607faaa 41 // If main exits, there may still be other fibers running or registered event handlers etc.
LancasterUniversity 1:2ee7e607faaa 42 // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then
LancasterUniversity 1:2ee7e607faaa 43 // sit in the idle task forever, in a power efficient sleep.
LancasterUniversity 1:2ee7e607faaa 44 release_fiber();
LancasterUniversity 1:2ee7e607faaa 45 }
LancasterUniversity 2:5b2cd31ac474 46
LancasterUniversity 2:5b2cd31ac474 47 #endif