Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:9ac8338343fb
diff -r 000000000000 -r 9ac8338343fb main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 19 10:14:02 2017 +0000 @@ -0,0 +1,41 @@ +/* See + * http://lancaster-university.github.io/microbit-docs/advanced/ + * for docs about using the micro:bit library +*/ +#include "MicroBit.h" + +MicroBit uBit; + +void onConnected(MicroBitEvent) +{ + uBit.display.print("C"); +} + +void onDisconnected(MicroBitEvent) +{ + uBit.display.print("D"); +} + +int main() +{ + // Initialise the micro:bit runtime. + uBit.init(); + // Display a start-up message + uBit.display.scroll("GREEN FOX"); + + // Application code will go here and in functions outside of main() + + uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected); + uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected); + + new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer); + new MicroBitMagnetometerService(*uBit.ble, uBit.compass); + new MicroBitTemperatureService(*uBit.ble, uBit.thermometer); + + // end of application code in main() + + // If main exits, there may still be other fibers running or registered event handlers etc. + // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then + // sit in the idle task forever, in a power efficient sleep. + release_fiber(); +} \ No newline at end of file