a quick program to test the 4Dgenie library

Dependencies:   4dGENIE_2 mbed

Fork of Genie_Test by christian b

Committer:
chris215
Date:
Wed Nov 20 22:47:46 2013 +0000
Revision:
2:e0f7812d4524
Parent:
1:203466f6d54f
Child:
3:4fe144f2f64e
Phase 1 - Now the Mbed is using WiflyInterface to connect to my network and the 4d genie interface to talk to the LCD screen

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 2:e0f7812d4524 3 #include "WiflyInterface.h"
chris215 2:e0f7812d4524 4 /*
chris215 2:e0f7812d4524 5 For Now, the 4d Screen Genie is hard coded to operate on the uart connected at pins p9 and p10
chris215 2:e0f7812d4524 6 Further improvements would be to make to turn it into a class that could be instantiated to any
chris215 2:e0f7812d4524 7 or the Mbed uarts -> TODO
chris215 2:e0f7812d4524 8 */
chris215 2:e0f7812d4524 9 /* wifly object where:
chris215 2:e0f7812d4524 10 * - p13 and p14 are for the serial communication
chris215 2:e0f7812d4524 11 * - p25 is for the reset pin
chris215 2:e0f7812d4524 12 * - p26 is for the connection status
chris215 2:e0f7812d4524 13 * - "mbed" is the ssid of the network
chris215 2:e0f7812d4524 14 * - "password" is the password
chris215 2:e0f7812d4524 15 * - WPA is the security
chris215 2:e0f7812d4524 16 */
chris215 2:e0f7812d4524 17 WiflyInterface wifly(p13, p14, p25, p26, "Bibite", "DIR825Chris24", WPA);
chris215 0:f065693322dd 18 DigitalOut myled(LED1);
chris215 0:f065693322dd 19 void myGenieEventHandler(void)
chris215 0:f065693322dd 20 {
chris215 0:f065693322dd 21 genieFrame Event;
chris215 0:f065693322dd 22 genieDequeueEvent(&Event);
chris215 0:f065693322dd 23 //event report from an object
chris215 0:f065693322dd 24 if(Event.reportObject.cmd == GENIE_REPORT_EVENT)
chris215 0:f065693322dd 25 {
chris215 0:f065693322dd 26 if (Event.reportObject.object == GENIE_OBJ_4DBUTTON) // If the Reported Message was from a Slider
chris215 0:f065693322dd 27 {
chris215 0:f065693322dd 28 if (Event.reportObject.index == 0)
chris215 0:f065693322dd 29 {
chris215 0:f065693322dd 30 printf("Button 1 pressed!\n\r");
chris215 0:f065693322dd 31 }
chris215 0:f065693322dd 32 if (Event.reportObject.index == 1)
chris215 0:f065693322dd 33 {
chris215 0:f065693322dd 34 printf("Button 2 pressed!\n\r");
chris215 0:f065693322dd 35 }
chris215 0:f065693322dd 36 if (Event.reportObject.index == 2)
chris215 0:f065693322dd 37 {
chris215 0:f065693322dd 38 printf("Button 3 pressed!\n\r");
chris215 0:f065693322dd 39 }
chris215 0:f065693322dd 40 }
chris215 0:f065693322dd 41 }
chris215 0:f065693322dd 42 //Cmd from a reported object (happens when an object read is requested)
chris215 0:f065693322dd 43 if(Event.reportObject.cmd == GENIE_REPORT_OBJ)
chris215 0:f065693322dd 44 {
chris215 0:f065693322dd 45
chris215 0:f065693322dd 46 }
chris215 0:f065693322dd 47
chris215 0:f065693322dd 48
chris215 0:f065693322dd 49 }
chris215 0:f065693322dd 50
chris215 0:f065693322dd 51 int main() {
chris215 2:e0f7812d4524 52 SetupGenie();
chris215 2:e0f7812d4524 53 genieAttachEventHandler(&myGenieEventHandler);
chris215 2:e0f7812d4524 54 genieWriteContrast(0);
chris215 2:e0f7812d4524 55 wifly.init(); // use DHCP
chris215 2:e0f7812d4524 56 while (!wifly.connect()); // join the network
chris215 2:e0f7812d4524 57 printf("IP Address is %s\n\r", wifly.getIPAddress());
chris215 0:f065693322dd 58
chris215 1:203466f6d54f 59 printf("Mbed Genie demo \n\r");
chris215 1:203466f6d54f 60
chris215 1:203466f6d54f 61
chris215 2:e0f7812d4524 62 genieWriteContrast(1);
chris215 0:f065693322dd 63 //Write a string to the Display
chris215 2:e0f7812d4524 64 genieWriteStr(0, __DATE__" " __TIME__);
chris215 2:e0f7812d4524 65 genieWriteStr(1, wifly.getIPAddress());
chris215 2:e0f7812d4524 66 genieWriteStr(2, "Mbed Genie Test and developement");
chris215 0:f065693322dd 67
chris215 0:f065693322dd 68
chris215 0:f065693322dd 69 while(1) {
chris215 0:f065693322dd 70
chris215 0:f065693322dd 71 myled = 1;
chris215 0:f065693322dd 72 wait(0.2);
chris215 0:f065693322dd 73 myled = 0;
chris215 0:f065693322dd 74 wait(0.2);
chris215 0:f065693322dd 75 }
chris215 0:f065693322dd 76 }