Tick Tock / Mbed 2 deprecated CANary

Dependencies:   SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2_ILI9341 mbed

Fork of CANary_corrupt by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Wed Aug 20 02:09:21 2014 +0000
Parent:
197:f566f65ff034
Child:
199:400b8950effa
Commit message:
// Fixed false long touch bug

Changed in this revision

displayModes.cpp 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
utility.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/displayModes.cpp	Sat Aug 16 02:41:28 2014 +0000
+++ b/displayModes.cpp	Wed Aug 20 02:09:21 2014 +0000
@@ -1385,6 +1385,7 @@
 
 void cmdDisplay (bool force, bool showButtons){
     tt.set_font((unsigned char*) Arial24x23);
+    tt.background(Navy);
     if(force){
         tt.cls();
     }
@@ -1447,7 +1448,8 @@
     }
     tt.locate(10,154);
     printf("msgData: %02x%02x%02x%02x\n",uCmdData[4],uCmdData[5],uCmdData[6],uCmdData[7]);    
-    showButton(3,0," Send"," Cmd",4,4);               
+    if (debugMode)
+        showButton(3,0," Send"," Cmd",4,4);               
 }
 
 void watchDisplay (bool force, bool showButtons){
--- a/main.cpp	Sat Aug 16 02:41:28 2014 +0000
+++ b/main.cpp	Wed Aug 20 02:09:21 2014 +0000
@@ -12,8 +12,8 @@
 // * fix bug where charging while on screws up efficiency computation
 // * find better kWh estimate than gids
 
-// rev197
-// Added cmd Screen to send arbitrary commands
+// rev198
+// Fixed false long touch bug
 
 // Include this before other header files
 #include "precompile.h"
@@ -27,7 +27,7 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "197";
+char revStr[7] = "198";
 unsigned long maxTarget = 1000;
 FATFS USBdrive;
 LocalFileSystem local("local");
@@ -508,6 +508,7 @@
                         uidx=99;
                     }
                 }
+                secsTouch=0;
             } else if (secsNoTouch<2) {// Recently touched
                 secsNoTouch +=2; // increment to prevent double touch
                 if (sMode==0) sMode = 1; //Go to select mode1 unless already in select mode2
@@ -648,15 +649,24 @@
                                     sMode=0;
                                 } else if (dMode[whichTouched] == watchScreen) { 
                                     clearTest=true;
-                                } else if (dMode[whichTouched] == cmdScreen) {
+                                } else if ((dMode[whichTouched] == cmdScreen)&&debugMode) {
                                     if (uCmdBus==1) { // EVcan
+                                        can1.monitor(false); // set to active mode
                                         can1.write(CANMessage(uCmdId, uCmdData, uCmdLen));
+                                        wait_ms(50);
+                                        if (reqMsgCnt==99)
+                                            can1.monitor(true); // restore to snoop unless other message outstanding
                                     } else if (uCmdBus==2){
+                                        can2.monitor(false); // set to active mode
                                         can2.write(CANMessage(uCmdId, uCmdData, uCmdLen));
+                                        wait_ms(50);
+                                        if (reqMsgCnt==99)
+                                            can2.monitor(true); // restore to snoop unless other message outstanding
                                     }
                                 } else { // top-right corner always mute/unmute unless used by specific screen
                                     enableSound = !enableSound;
                                     if(!enableSound) spkr=0;
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
 
                                 break;
@@ -894,6 +904,7 @@
                                     lastDMode[0]=99;
                                     lastDMode[1]=99;
                                     uidx=99;
+                                    longTouch=false;
                                     break;
                                 default:
                                     break;
@@ -908,7 +919,7 @@
             } //recently touched
         } else if(sMode<2) { // userIdle if not in hex entry mode
             sMode=0;
-            lastDMode[whichTouched]=99;
+            //lastDMode[whichTouched]=99;
         } //!userIdle
 
         // Sound tone on power reversal
@@ -930,11 +941,11 @@
                 if(checkFWupdate){
                     updateFirmware();
                 }
-                longTouch = (++secsTouch>1);
             }else{
-                userIdle=(++secsNoTouch>userTimeout)?true:false;
+                //userIdle=(++secsNoTouch>userTimeout)?true:false;
                 secsTouch = 0;
             }
+            longTouch = (++secsTouch>2);
             checkFWupdate=false; // Only check once at first poweron
             lCCon = CCon;
             CCkW = (lastMsg[indexLastMsg[0x510]].data[3]&0x7f)*0.125;
@@ -966,7 +977,7 @@
             if (laccOn&&!accOn){ // Car turned off
                 dailyGids += startGids-((lastMsg[indexLastMsg[0x5bc]].data[0]<<2)+(lastMsg[indexLastMsg[0x5bc]].data[1]>>6));
                 lHeaterOn=false;
-                if (showHealth&&!playbackOpen&&false){ //blah false
+                if (showHealth&&!playbackOpen){
                     if (saveDmode[0]==99){
                         saveDmode[0]=dMode[0];
                         saveDmode[1]=dMode[1];
@@ -1063,7 +1074,7 @@
                     }
                 } // Charged since last trip
                 wait5secs=5;
-                if (showHealth&&!playbackOpen&&false){ //blah false
+                if (showHealth&&!playbackOpen){
                     if (saveDmode[0]==99){
                         saveDmode[0]=dMode[0];
                     }
--- a/utility.cpp	Sat Aug 16 02:41:28 2014 +0000
+++ b/utility.cpp	Wed Aug 20 02:09:21 2014 +0000
@@ -13,7 +13,7 @@
     timer.reset(); // zero ms at the-seconds-tic
     //carCanIdle=(++secsNoCarCanMsg>canTimeout)?true:false;
     //evCanIdle=(++secsNoEvCanMsg>canTimeout)?true:false;
-    //userIdle=(++secsNoTouch>userTimeout)?true:false;
+    userIdle=(++secsNoTouch>userTimeout)?true:false;
     LPC_RTC->ILR |= (1<<0); // clear interrupt to prepare for next
     tick=true;
     // will use this to generate a logTP() just before the next Message received.