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

Dependencies:   mbed 4dGENIE

Revision:
4:5e14a065031d
Parent:
3:4fe144f2f64e
Child:
5:b1e5af95a2fb
--- a/main.cpp	Sat Dec 07 02:34:40 2013 +0000
+++ b/main.cpp	Sun Feb 23 17:41:02 2014 +0000
@@ -2,67 +2,72 @@
 #include "mbed_genie.h"
 
 DigitalOut myled(LED1);
+/*
+    The Mbed4dGenie class requires 3 parameters
+    1 - Tx pin
+    2 - Rx pin
+    3 - Reset pin
+*/
+Mbed4dGenie lcd4d(p9,p10,p11);
 void myGenieEventHandler(void) 
 {
-  genieFrame Event;
-  genieDequeueEvent(&Event);
-  //event report from an object
-  if(Event.reportObject.cmd == GENIE_REPORT_EVENT)
-  {
-    /*
-    for example here we check if we received a message from 4dbuttons objects
-    the index is the button number, refer to the 4dgenie project to know the index
-    */
-    if (Event.reportObject.object == GENIE_OBJ_4DBUTTON)                // If the Reported Message was from a Slider
+    myled = 1;
+    genieFrame Event;
+    lcd4d.genieDequeueEvent(&Event);
+    //event report from an object
+    if(Event.reportObject.cmd == GENIE_REPORT_EVENT)
     {
-        if (Event.reportObject.index == 0) 
+        /*
+        for example here we check if we received a message from 4dbuttons objects
+        the index is the button number, refer to the 4dgenie project to know the index
+        */
+        if (Event.reportObject.object == GENIE_OBJ_4DBUTTON)                // If the Reported Message was from a Slider
         {
-             printf("Button 1 pressed!\n\r");
+            if (Event.reportObject.index == 0) 
+            {
+                 printf("Button 1 pressed!\n\r");
+            }
+            if (Event.reportObject.index == 1) 
+            {
+                printf("Button 2 pressed!\n\r");
+            }
+            if (Event.reportObject.index == 2) 
+            {
+                printf("Button 3 pressed!\n\r");
+            }
         }
-        if (Event.reportObject.index == 1) 
-        {
-            printf("Button 2 pressed!\n\r");
-        }
-        if (Event.reportObject.index == 2) 
-        {
-            printf("Button 3 pressed!\n\r");
-        }
-    }
-  }
-  //Cmd from a reported object (happens when an object read is requested)
-  if(Event.reportObject.cmd == GENIE_REPORT_OBJ)
-  {
-
-  }
+      }
+      //Cmd from a reported object (happens when an object read is requested)
+      if(Event.reportObject.cmd == GENIE_REPORT_OBJ)
+      {
+    
+      }
+}
 
 
-}
 
 int main() {
     int temp = 0;
-
-SetupGenie();
-genieAttachEventHandler(&myGenieEventHandler);
-genieWriteContrast(0);
-
 printf("Mbed Genie demo \n\r");
-
-
-genieWriteContrast(1);
+lcd4d.genieAttachEventHandler(&myGenieEventHandler);
+lcd4d.genieWriteContrast(0);
+wait(0.25);
+lcd4d.genieWriteContrast(1);
 
  /*
  for example, in this loop we increment the thermometer0 object from 0 to 100
  */
+ 
     while(1) {
         if(temp >= 100)
         {
-            temp = 0;
+            temp = -1;
         }
         else
         {
             temp++;
         }
-        genieWriteObject(GENIE_OBJ_THERMOMETER,0,temp);
+        lcd4d.genieWriteObject(GENIE_OBJ_THERMOMETER,0,temp);
         myled = 1;
         wait(0.25);
         myled = 0;