should work with the data logger app to measure temperature, etc.

Dependencies:   microbit

main.cpp

Committer:
kinga
Date:
2017-01-19
Revision:
0:9ac8338343fb

File content as of revision 0:9ac8338343fb:

/* 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();
}