Benny Andersen / microbitOLED

Dependencies:   microbit

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "MicroBit.h"
00002 
00003 #include "cppNorm.h"
00004 #include "OLED.h"
00005 #include "Display.h"
00006 
00007 MicroBit uBit;
00008 OLED oled;
00009 Display display(uBit.display); // only ref to uninitialized uBit
00010 
00011 void example_OLED();
00012 void example_stick();
00013 void example_BinaryRows();
00014 void example_clock();
00015 void example_secClock();
00016 void example_assert();
00017 void example_flag();
00018 void example_peek();
00019 
00020 
00021 struct {
00022     void (*example)(void);
00023     string name;
00024     } examples[] = { 
00025          {example_OLED,"OLED"}
00026         ,{example_stick,"stick"}
00027         ,{example_BinaryRows,"binaryRows"}
00028         ,{example_clock,"clock"} // 17:31
00029         ,{example_secClock,"sec-clock"} // 17:31:00
00030         ,{example_assert,"assertion"}
00031         ,{example_flag,"flag"}
00032         ,{example_peek,"peek"}
00033         };
00034 
00035 void showExample(string name) {
00036     for (int8_t i = 0; i < sizeof(examples)/sizeof(examples[0]); i++)
00037         if (name == examples[i].name) 
00038             (examples[i].example)();
00039         
00040 }
00041 /**
00042   * In absence of terminal or bluetooth command interface, chose an example by hand
00043   */ 
00044 int main() {
00045     uBit.init();
00046     
00047     // change to try
00048     showExample("flag");
00049     uBit.panic(987);
00050 }
00051