Chrono TIR

Dependencies:   mbed

Committer:
pathae
Date:
Wed Jan 22 10:26:34 2020 +0000
Revision:
0:f38ea4ed5621
chrono_TIR_V1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pathae 0:f38ea4ed5621 1 /* 4d systems touch screen display.
pathae 0:f38ea4ed5621 2
pathae 0:f38ea4ed5621 3 uses the mbed_genie library ported from the arduino
pathae 0:f38ea4ed5621 4 visie-genie library by Christian B
pathae 0:f38ea4ed5621 5
pathae 0:f38ea4ed5621 6 The display serial TX and RX pins are connected to pin PA_9
pathae 0:f38ea4ed5621 7 and pin PA_10 of the mbed
pathae 0:f38ea4ed5621 8
pathae 0:f38ea4ed5621 9 The reset pin is not connected as reset function is not implemented
pathae 0:f38ea4ed5621 10
pathae 0:f38ea4ed5621 11 For setting up the display in Visie-Genie
pathae 0:f38ea4ed5621 12
pathae 0:f38ea4ed5621 13 The display has an gauge meter object, a LED digits object, two buttons
pathae 0:f38ea4ed5621 14 and three static text objects.
pathae 0:f38ea4ed5621 15
pathae 0:f38ea4ed5621 16 The On and Off button has been set to report on change
pathae 0:f38ea4ed5621 17 The baud rate of the display is set to 115200 baud
pathae 0:f38ea4ed5621 18 */
pathae 0:f38ea4ed5621 19 #include "mbed.h"
pathae 0:f38ea4ed5621 20 #include "mbed_genie.h"
pathae 0:f38ea4ed5621 21
pathae 0:f38ea4ed5621 22 DigitalOut myled(LED1); //LED 1 for indication
pathae 0:f38ea4ed5621 23
pathae 0:f38ea4ed5621 24 int flag = 0; //holds the "power status" of the voltmeter. flag = 0 means voltmeter is "off", flag = 1 means the voltmeter is "on".
pathae 0:f38ea4ed5621 25 float chrono; //holds the digital voltage value to be sent to the angular meter
pathae 0:f38ea4ed5621 26
pathae 0:f38ea4ed5621 27 //Event handler for the 4d Systems display
pathae 0:f38ea4ed5621 28 void myGenieEventHandler(void)
pathae 0:f38ea4ed5621 29 {
pathae 0:f38ea4ed5621 30 genieFrame Event;
pathae 0:f38ea4ed5621 31 genieDequeueEvent(&Event);
pathae 0:f38ea4ed5621 32 //event report from an object
pathae 0:f38ea4ed5621 33 if(Event.reportObject.cmd == GENIE_REPORT_EVENT) {
pathae 0:f38ea4ed5621 34 /*
pathae 0:f38ea4ed5621 35 for example here we check if we received a message from 4dbuttons objects
pathae 0:f38ea4ed5621 36 the index is the button number, refer to the 4dgenie project to know the index
pathae 0:f38ea4ed5621 37 */
pathae 0:f38ea4ed5621 38 if (Event.reportObject.object == GENIE_OBJ_4DBUTTON) { // If the Reported Message was from a button
pathae 0:f38ea4ed5621 39 if (Event.reportObject.index == 0) {
pathae 0:f38ea4ed5621 40 //printf("Off Button pressed!\n\r");
pathae 0:f38ea4ed5621 41 wait(0.2);
pathae 0:f38ea4ed5621 42 flag=1;
pathae 0:f38ea4ed5621 43 }
pathae 0:f38ea4ed5621 44 if (Event.reportObject.index == 1) {
pathae 0:f38ea4ed5621 45 //printf("On Button pressed!\n\r");
pathae 0:f38ea4ed5621 46 wait(0.2);
pathae 0:f38ea4ed5621 47 flag=0;
pathae 0:f38ea4ed5621 48 }
pathae 0:f38ea4ed5621 49 }
pathae 0:f38ea4ed5621 50 }
pathae 0:f38ea4ed5621 51
pathae 0:f38ea4ed5621 52 //Cmd from a reported object (happens when an object read is requested)
pathae 0:f38ea4ed5621 53 // if(Event.reportObject.cmd == GENIE_REPORT_OBJ)
pathae 0:f38ea4ed5621 54 // {
pathae 0:f38ea4ed5621 55 // }
pathae 0:f38ea4ed5621 56 }
pathae 0:f38ea4ed5621 57
pathae 0:f38ea4ed5621 58 int main()
pathae 0:f38ea4ed5621 59
pathae 0:f38ea4ed5621 60 {
pathae 0:f38ea4ed5621 61 SetupGenie();
pathae 0:f38ea4ed5621 62 genieAttachEventHandler(&myGenieEventHandler);
pathae 0:f38ea4ed5621 63 genieWriteContrast(10); //set screen contrast to full brightness
pathae 0:f38ea4ed5621 64 chrono=99;
pathae 0:f38ea4ed5621 65
pathae 0:f38ea4ed5621 66 while(1) {
pathae 0:f38ea4ed5621 67
pathae 0:f38ea4ed5621 68 if (flag == 1) {
pathae 0:f38ea4ed5621 69 //printf("Flag status: %d \r\n", flag);
pathae 0:f38ea4ed5621 70 chrono=chrono-1;
pathae 0:f38ea4ed5621 71 genieWriteObject(GENIE_OBJ_LED_DIGITS, 0x00, chrono); //write to Leddigits0 the value of voltLED
pathae 0:f38ea4ed5621 72 genieWriteObject(GENIE_OBJ_GAUGE , 0x00, chrono); //write to Angularmeter0 the value of voltMeter*/
pathae 0:f38ea4ed5621 73 wait (0.5);
pathae 0:f38ea4ed5621 74 }
pathae 0:f38ea4ed5621 75
pathae 0:f38ea4ed5621 76 else if(flag == 0){
pathae 0:f38ea4ed5621 77 genieWriteObject(GENIE_OBJ_LED_DIGITS, 0x00, 0);
pathae 0:f38ea4ed5621 78 genieWriteObject(GENIE_OBJ_GAUGE , 0x00, 0); //write to Angularmeter0 the value of voltMeter
pathae 0:f38ea4ed5621 79 chrono=99;
pathae 0:f38ea4ed5621 80 wait (0.5);
pathae 0:f38ea4ed5621 81 }
pathae 0:f38ea4ed5621 82
pathae 0:f38ea4ed5621 83 }
pathae 0:f38ea4ed5621 84
pathae 0:f38ea4ed5621 85 }