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

Dependencies:   mbed 4dGENIE

Files at this revision

API Documentation at this revision

Comitter:
chris215
Date:
Sun Jul 06 17:24:43 2014 +0000
Parent:
4:5e14a065031d
Commit message:
Demo application updated to work with the new 4dgenie class

Changed in this revision

4dGENIE.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/4dGENIE.lib	Sun Feb 23 17:41:02 2014 +0000
+++ b/4dGENIE.lib	Sun Jul 06 17:24:43 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/chris215/code/4dGENIE/#11c49c49cd1a
+http://mbed.org/users/chris215/code/4dGENIE/#b5ba0df2d0db
--- a/main.cpp	Sun Feb 23 17:41:02 2014 +0000
+++ b/main.cpp	Sun Jul 06 17:24:43 2014 +0000
@@ -2,75 +2,68 @@
 #include "mbed_genie.h"
 
 DigitalOut myled(LED1);
+DigitalOut myledr(LED2);
 /*
     The Mbed4dGenie class requires 3 parameters
     1 - Tx pin
     2 - Rx pin
     3 - Reset pin
 */
-Mbed4dGenie lcd4d(p9,p10,p11);
-void myGenieEventHandler(void) 
+Mbed4dGenie lcd4d(PTE0,PTE1,PTB9);
+
+void MyGenieEventHandler(void)
 {
-    myled = 1;
-    genieFrame Event;
-    lcd4d.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
+    genieFrame TheEven;
+    while(lcd4d.PendingFrames()){
+        if(lcd4d.genieDequeueEvent(&TheEven))
         {
-            if (Event.reportObject.index == 0) 
+            
+            if( TheEven.reportObject.cmd == GENIE_REPORT_EVENT)
             {
-                 printf("Button 1 pressed!\n\r");
+                myledr = !myledr; //toggle led when receiving a genie event frame
             }
-            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)
-      {
-    
-      }
+    }
 }
 
-
-
 int main() {
     int temp = 0;
-printf("Mbed Genie demo \n\r");
-lcd4d.genieAttachEventHandler(&myGenieEventHandler);
-lcd4d.genieWriteContrast(0);
-wait(0.25);
-lcd4d.genieWriteContrast(1);
-
+    printf("Mbed Genie demo \n\r");
+    lcd4d.Start(); 
+    lcd4d.genieAttachEventHandler(&MyGenieEventHandler);
  /*
- for example, in this loop we increment the thermometer0 object from 0 to 100
+ for example, in this loop we increment the object from 0 to 100
  */
  
     while(1) {
         if(temp >= 100)
         {
-            temp = -1;
+            temp = 0;
         }
         else
         {
             temp++;
         }
-        lcd4d.genieWriteObject(GENIE_OBJ_THERMOMETER,0,temp);
+
+        //printf("write:%d\n\r",lcd4d.genieWriteObject(GENIE_OBJ_LED_DIGITS,1,temp));
+        int error;
+        error = lcd4d.genieWriteObject(GENIE_OBJ_LED_DIGITS,1,temp);
+        if(error != ERROR_NONE)
+        {
+            printf("Error is:%d\n\r",error);
+        }
+        
         myled = 1;
-        wait(0.25);
+        //wait(0.05);
+        //printf("read:%d\n\r",lcd4d.genieReadObj(GENIE_OBJ_LED_DIGITS,1));
+        error = lcd4d.genieReadObj(GENIE_OBJ_LED_DIGITS,1);
+        if(error != ERROR_NONE)
+        {
+            printf("Error is:%d\n\r",error);
+        }
         myled = 0;
-        wait(0.25);
+        //wait(0.05);
     }
 }
--- a/mbed.bld	Sun Feb 23 17:41:02 2014 +0000
+++ b/mbed.bld	Sun Jul 06 17:24:43 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/f37f3b9c9f0b
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file