A - floating heart B - FOX

Dependencies:   microbit

Files at this revision

API Documentation at this revision

Comitter:
kinga
Date:
Thu Jan 19 18:20:54 2017 +0000
Commit message:
A - floating heart; B - FOX

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
microbit.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 99984a8707ad main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 19 18:20:54 2017 +0000
@@ -0,0 +1,33 @@
+#include "MicroBit.h"
+
+MicroBit uBit;
+
+void onButtonA(MicroBitEvent e) {
+    MicroBitImage heart("0, 1, 0, 1, 0\n1, 1, 1, 1, 1\n1, 1, 1, 1, 1\n0, 1, 1, 1, 0\n0, 0, 1, 0, 0\n");
+    uBit.display.setDisplayMode(DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE);
+    for (int y = 4; y >= 0; --y) {
+      uBit.display.image.paste(heart, 0, y);
+      uBit.sleep(500);
+    }
+}
+
+void onButtonB(MicroBitEvent e) {
+    uBit.display.print("FOX");
+}
+
+int main()
+{
+    // Initialise the micro:bit runtime.
+    uBit.init();
+
+    // Insert your code here!
+    
+    uBit.messageBus.listen(MICROBIT_ID_BUTTON_A, MICROBIT_BUTTON_EVT_CLICK, onButtonA);
+    uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonB);
+
+    // 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();
+}
+
diff -r 000000000000 -r 99984a8707ad microbit.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/microbit.lib	Thu Jan 19 18:20:54 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Lancaster-University/code/microbit/#4b89e7e3494f