christian b
/
Genie_Test
Simple port of the 4d genie arduino code. Works, but needs more work to be fully functionnal as a class!
main.cpp@1:203466f6d54f, 2013-11-18 (annotated)
- Committer:
- chris215
- Date:
- Mon Nov 18 03:04:46 2013 +0000
- Revision:
- 1:203466f6d54f
- Parent:
- 0:f065693322dd
- Child:
- 2:e0f7812d4524
added hello world string
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris215 | 0:f065693322dd | 1 | #include "mbed.h" |
chris215 | 0:f065693322dd | 2 | #include "mbed_genie.h" |
chris215 | 0:f065693322dd | 3 | DigitalOut myled(LED1); |
chris215 | 0:f065693322dd | 4 | void myGenieEventHandler(void) |
chris215 | 0:f065693322dd | 5 | { |
chris215 | 0:f065693322dd | 6 | genieFrame Event; |
chris215 | 0:f065693322dd | 7 | genieDequeueEvent(&Event); |
chris215 | 0:f065693322dd | 8 | //event report from an object |
chris215 | 0:f065693322dd | 9 | if(Event.reportObject.cmd == GENIE_REPORT_EVENT) |
chris215 | 0:f065693322dd | 10 | { |
chris215 | 0:f065693322dd | 11 | if (Event.reportObject.object == GENIE_OBJ_4DBUTTON) // If the Reported Message was from a Slider |
chris215 | 0:f065693322dd | 12 | { |
chris215 | 0:f065693322dd | 13 | if (Event.reportObject.index == 0) |
chris215 | 0:f065693322dd | 14 | { |
chris215 | 0:f065693322dd | 15 | printf("Button 1 pressed!\n\r"); |
chris215 | 0:f065693322dd | 16 | } |
chris215 | 0:f065693322dd | 17 | if (Event.reportObject.index == 1) |
chris215 | 0:f065693322dd | 18 | { |
chris215 | 0:f065693322dd | 19 | printf("Button 2 pressed!\n\r"); |
chris215 | 0:f065693322dd | 20 | } |
chris215 | 0:f065693322dd | 21 | if (Event.reportObject.index == 2) |
chris215 | 0:f065693322dd | 22 | { |
chris215 | 0:f065693322dd | 23 | printf("Button 3 pressed!\n\r"); |
chris215 | 0:f065693322dd | 24 | } |
chris215 | 0:f065693322dd | 25 | } |
chris215 | 0:f065693322dd | 26 | } |
chris215 | 0:f065693322dd | 27 | //Cmd from a reported object (happens when an object read is requested) |
chris215 | 0:f065693322dd | 28 | if(Event.reportObject.cmd == GENIE_REPORT_OBJ) |
chris215 | 0:f065693322dd | 29 | { |
chris215 | 0:f065693322dd | 30 | |
chris215 | 0:f065693322dd | 31 | } |
chris215 | 0:f065693322dd | 32 | |
chris215 | 0:f065693322dd | 33 | |
chris215 | 0:f065693322dd | 34 | } |
chris215 | 0:f065693322dd | 35 | |
chris215 | 0:f065693322dd | 36 | int main() { |
chris215 | 0:f065693322dd | 37 | |
chris215 | 1:203466f6d54f | 38 | printf("Mbed Genie demo \n\r"); |
chris215 | 1:203466f6d54f | 39 | |
chris215 | 1:203466f6d54f | 40 | |
chris215 | 0:f065693322dd | 41 | SetupGenie(); |
chris215 | 0:f065693322dd | 42 | genieAttachEventHandler(&myGenieEventHandler); |
chris215 | 0:f065693322dd | 43 | //Write a string to the Display |
chris215 | 0:f065693322dd | 44 | genieWriteStr(0, GENIE_VERSION); |
chris215 | 0:f065693322dd | 45 | |
chris215 | 0:f065693322dd | 46 | |
chris215 | 0:f065693322dd | 47 | while(1) { |
chris215 | 0:f065693322dd | 48 | |
chris215 | 0:f065693322dd | 49 | myled = 1; |
chris215 | 0:f065693322dd | 50 | wait(0.2); |
chris215 | 0:f065693322dd | 51 | myled = 0; |
chris215 | 0:f065693322dd | 52 | wait(0.2); |
chris215 | 0:f065693322dd | 53 | } |
chris215 | 0:f065693322dd | 54 | } |