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:
Sat Aug 16 01:35:36 2014 +0000
Parent:
195:ef0af84a4340
Child:
197:f566f65ff034
Commit message:
Fixed bug causing lag during long press

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	Thu Aug 14 23:08:10 2014 +0000
+++ b/displayModes.cpp	Sat Aug 16 01:35:36 2014 +0000
@@ -1384,7 +1384,7 @@
 }
 
 void testDisplay (bool force, bool showButtons){
-    //static unsigned short maxPS=0;
+    static unsigned short maxPS=0;
     static unsigned short oldData[8]={0};
     unsigned char i, uData[8];//, year, month, day, hour, minute, second;
     CANMessage msg;
@@ -1395,18 +1395,15 @@
     if(force){
         tt.cls();
     }
-    /*if(logEn){
+    if(logEn&&debugMode){
         if(pointerSep>maxPS){maxPS=pointerSep;}
-        tt.locate(10,10);
+        tt.locate(1,1);
         printf("%3d sep %3d max\n",pointerSep,maxPS);
-    }else{
-        tt.locate(10,10);
-        printf("%d maxT\n",maxTarget);
-    }*/
+    }
 
     for (i=0; i<8; i++){
-        msg = lastMsg[indexLastMsg[(uMsgId[i]>>4)]];
-        uData[i] = msg.data[(uMsgId[i]&0x000f)];
+        msg = lastMsg[indexLastMsg[((uMsgId[i]&0x7ff0)>>4)]];
+        uData[i] = msg.data[(uMsgId[i]&0x0007)];
         if(i%2==0){
             tt.locate(10,64+(i/2)*30);
         }else{
@@ -1418,7 +1415,7 @@
             oldData[i]=99;
         }
         if(clearTest){
-            //maxPS=0;
+            maxPS=0;
             oldData[i]=uData[i];
             tt.foreground(Yellow);
             tt.background(Navy);
--- a/main.cpp	Thu Aug 14 23:08:10 2014 +0000
+++ b/main.cpp	Sat Aug 16 01:35:36 2014 +0000
@@ -13,7 +13,7 @@
 // * find better kWh estimate than gids
 
 // rev195
-
+// Added in-device watchpoint editor
 
 // Include this before other header files
 #include "precompile.h"
@@ -59,7 +59,6 @@
 #else
 TOUCH_TFTx2 tt(p16, p17, p19, p20, p11, p12, p13, p6, p7, p5, "TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs0, cs1, reset
 #endif
-//TOUCH_TFTx2 tt(p16, p17, p19, p20, p11, p12, p13, p6, p7, p5, "TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs0, cs1, reset
 PwmOut dled(p23);
 PwmOut spkr(p21);
 
@@ -473,9 +472,10 @@
         unsigned char tRow ;
                         
         if (!userIdle) {
-            if(longTouch){ //long touch
+            if(longTouch&&(sMode<2)){ //long touch
                 if (dMode[whichTouched]==testScreen) {
                     whichTouched = whichTouched ^ 1; //long press opens keypad on *other* screen
+                    lwt=whichTouched;
                     saveDmode[0]=dMode[0];
                     saveDmode[1]=dMode[1];
                     dMode[whichTouched]=offScreen;
@@ -490,7 +490,6 @@
                     }else{
                         uidx=99;
                     }
-                    lwt=whichTouched;
                 }
             } else if (secsNoTouch<2) {// Recently touched
                 secsNoTouch +=2; // increment to prevent double touch
@@ -884,7 +883,7 @@
                         break;
                 } // case sMode
             } //recently touched
-        } else if(sMode<2){ // userIdle if not in hex entry mode
+        } else if(sMode<2) { // userIdle if not in hex entry mode
             sMode=0;
             lastDMode[whichTouched]=99;
         } //!userIdle
@@ -902,19 +901,22 @@
 
         if(tick){ // Executes once a second
             tick=false;
+            carCanIdle=(++secsNoCarCanMsg>canTimeout)?true:false;
+            evCanIdle=(++secsNoEvCanMsg>canTimeout)?true:false;
             if(tt.is_touched()){
                 if(checkFWupdate){
                     updateFirmware();
                 }
-                longTouch = (++secsTouch>2);
+                longTouch = (++secsTouch>1);
             }else{
+                userIdle=(++secsNoTouch>userTimeout)?true:false;
                 secsTouch = 0;
             }
             checkFWupdate=false; // Only check once at first poweron
             lCCon = CCon;
             CCkW = (lastMsg[indexLastMsg[0x510]].data[3]&0x7f)*0.125;
             if(lastMsg[indexLastMsg[0x510]].data[3]&0x80){
-                 CCon=true; // On when button pushed
+                CCon=true; // On when button pushed
             } else if(CCkW==0) {
                 CCon=false; // Off when power drops back to zero
             }
@@ -929,7 +931,6 @@
             heaterOn =((lastMsg[indexLastMsg[0x54f]].data[5]&0x3f)>2)?true:false;
             if(heaterMon && heaterOn && !lHeaterOn){ //Heat on alarm
                 beep3(800,0.25,1200,0.25,1600,0.25);
-                //beep(1600,0.5);
             }
             if(accOn&&indexLastMsg[0x355]>0){
                 miles_kmbar = (lastMsg[indexLastMsg[0x355]].data[4]&0x20)?true:false;  // indicates selected distance units
--- a/utility.cpp	Thu Aug 14 23:08:10 2014 +0000
+++ b/utility.cpp	Sat Aug 16 01:35:36 2014 +0000
@@ -11,9 +11,9 @@
 
 void RTC_IRQHandler() {
     timer.reset(); // zero ms at the-seconds-tic
-    carCanIdle=(++secsNoCarCanMsg>canTimeout)?true:false;
-    evCanIdle=(++secsNoEvCanMsg>canTimeout)?true:false;
-    userIdle=(++secsNoTouch>userTimeout)?true:false;
+    //carCanIdle=(++secsNoCarCanMsg>canTimeout)?true:false;
+    //evCanIdle=(++secsNoEvCanMsg>canTimeout)?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.