Simple port of the 4d genie arduino code. Works, but needs more work to be fully functionnal as a class!

Dependencies:   mbed 4dGENIE

Committer:
chris215
Date:
Mon Nov 18 02:39:18 2013 +0000
Revision:
0:f065693322dd
Child:
1:203466f6d54f
First commit of a working implementation of the 4d genie interface on mbed

Who changed what in which revision?

UserRevisionLine numberNew 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 0:f065693322dd 38 SetupGenie();
chris215 0:f065693322dd 39 genieAttachEventHandler(&myGenieEventHandler);
chris215 0:f065693322dd 40 //Write a string to the Display
chris215 0:f065693322dd 41 genieWriteStr(0, GENIE_VERSION);
chris215 0:f065693322dd 42
chris215 0:f065693322dd 43
chris215 0:f065693322dd 44 while(1) {
chris215 0:f065693322dd 45
chris215 0:f065693322dd 46 myled = 1;
chris215 0:f065693322dd 47 wait(0.2);
chris215 0:f065693322dd 48 myled = 0;
chris215 0:f065693322dd 49 wait(0.2);
chris215 0:f065693322dd 50 }
chris215 0:f065693322dd 51 }