Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Wed Apr 10 12:55:22 2013 +0000
Parent:
61:3ab6a40a1086
Child:
63:aa3bf6a33635
Commit message:
Merged with Gary's edit

Changed in this revision

displayModes.cpp Show annotated file Show diff for this revision Revisions of this file
displayModes.h 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
--- a/displayModes.cpp	Wed Apr 10 04:20:44 2013 +0000
+++ b/displayModes.cpp	Wed Apr 10 12:55:22 2013 +0000
@@ -985,43 +985,23 @@
 
 //---------------------
 // gg - highlight
-//void highlightButton(unsigned char column, unsigned char row, char * text1, char * text2, unsigned char columns, unsigned char rows){
-void highlightButton(unsigned char column, unsigned char row, unsigned char tScn, unsigned char cScn, unsigned char columns, unsigned char rows){
-    
-    // tScn is the screen number derived from the touch location, is 0 or 1
-    // cScn is the whichTouched screen value, apparently also 0 and 1
-    
+void highlightButton(unsigned char column, unsigned char row, unsigned char tScn, unsigned char columns, unsigned char rows){
+
     unsigned short x1,x2,y1,y2;
     
     x1=column*(320/columns)+btnGap/2;
     x2=(column+1)*(320/columns)-btnGap/2;
     y1=row*(240/rows)+btnGap/2;
     y2=(row+1)*(240/rows)-btnGap/2;
-    
-    tt.set_display( cScn ) ;
-    
-    if( tScn == cScn ){
-      // screens match
-      if( tScn == 0 )
+    /*if( tScn == 0 )
         // paint the whole button box
         tt.fillrect(x1,y1,x2,y2,White); // DarkCyan);
-      else
-        tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
-    } else {
-      // screens do not match
-      tt.fillrect(x1,y1,x2,y2,Red); // DarkCyan);      
-    }
+    else
+        tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);*/
 
     // paint the outer pixel as a yellow frame
+    tt.set_display(tScn);
     tt.rect(x1,y1,x2,y2,Yellow) ; // DarkCyan);
-    
-    
-    // adapt formatting of text to the smaller 4x4 box
-    //tt.locate(x1+btnGap/2,y1+btnGap); // gg - 4x4
-    //printf("%s\n",text1);
-    
-    //tt.locate(x1+btnGap/2,y1+btnGap+20);
-    //printf("%s\n",text2);
 }
 
 //---------------------
--- a/displayModes.h	Wed Apr 10 04:20:44 2013 +0000
+++ b/displayModes.h	Wed Apr 10 12:55:22 2013 +0000
@@ -49,6 +49,6 @@
     void showDateTime(bool force, bool showButtons);
     void updateDisplay(char display);
     void showButton(unsigned char column, unsigned char row, char * text1, char * text2, unsigned char columns, unsigned char rows);
-    void highlightButton(unsigned char column, unsigned char row, unsigned char tScn, unsigned char cScn, unsigned char columns, unsigned char rows);
+    void highlightButton(unsigned char column, unsigned char row, unsigned char tScn, unsigned char columns, unsigned char rows);
 
 }
\ No newline at end of file
--- a/main.cpp	Wed Apr 10 04:20:44 2013 +0000
+++ b/main.cpp	Wed Apr 10 12:55:22 2013 +0000
@@ -156,18 +156,8 @@
     strftime(sTemp, 32, "%a %m/%d/%Y %X\n", &t);
     logMsg(sTemp);
     
-    // revisions
-    // sprintf(sTemp,"CANary firmware rev51-gg1\n"); // gg - shows 4x4 buttons, 
-            // but the touch areas are still 3x3 
-    //sprintf(sTemp,"CANary firmware rev51-gg2\n"); // gg - decodes 4x4 button touches, 
-    //sprintf(sTemp,"CANary firmware rev51-gg3\n"); // gg - cleaned 4x4 button and touches, 
-    //sprintf(sTemp,"CANary firmware rev52\n"); 
-    //sprintf(sTemp,"CANary firmware rev54\n"); // merged 53 (51-gg3) and 52
-    //sprintf(sTemp,"CANary firmware rev57\n");
-    //sprintf(sTemp,"CANary firmware rev57-gg1\n"); // gg - highlight experiment
-    //sprintf(sTemp,"CANary firmware rev58\n"); // gg - highlight experiment commit and publish
-    //sprintf(sTemp,"CANary firmware rev59\n"); // gg - highlight buttons with set_display
-    sprintf(sTemp,"CANary firmware rev61\n"); // gg - merge with v60
+    // revision
+    sprintf(sTemp,"CANary firmware rev59\n");
     logMsg(sTemp);
 
     // Look for new binary on thumbdrive
@@ -356,7 +346,7 @@
         }
         //---------------
         // gg - 4x4 touch
-        unsigned char tScrn = 0 ; // screen 0
+        //unsigned char tScrn = 0 ; // screen 0
         unsigned char tCol ;                        
         unsigned char tRow ;
                         
@@ -376,16 +366,12 @@
                         //--------------
                         // gg - 4x4 touch
                         tCol = buttonX(lastTouch.x,4) ;
-                        if( tCol >= 4 ){ tCol -= 4; tScrn = 1 ; } // touch is on screen 1
-                        //if( tCol >= 4 ){ tCol -= 4; } // touch is on screen 1
+                        //if( tCol >= 4 ){ tCol -= 4; tScrn = 1 ; } // touch is on screen 1
+                        if( tCol >= 4 ){ tCol -= 4; } // touch is on screen 1
                         
                         tRow = buttonY(lastTouch.y,4) ;
                         
-                        // highlight the button (what screen?)
-                        // different highlight for tScrn, whichTouched combinations, for debugging
-                        highlightButton( tCol,tRow, tScrn, whichTouched, 4,4) ; // g - highlight
-                        // usually the screen is re-drawn after 
-                        // for now, this gives us good feedback that we can use 
+                        highlightButton( tCol,tRow, whichTouched, 4,4) ; // g - highlight
                         
                         if( tRow == tNavRow ) tRow = 7 ; //                    
                         switch ( (tCol*10) + tRow ) {
@@ -403,6 +389,8 @@
                                         playback.detach();
                                         playback.attach(&playbackISR,playbackInt);
                                     }
+                                } else {
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
                                 break;
                             //-----------------------------------------------
@@ -422,10 +410,13 @@
                                     playbackEn=!playbackEn;
                                     if(playbackEn){
                                         playback.attach(&playbackISR,playbackInt);
-                                    }else{
+                                    } else {
                                         playback.detach();
                                     }
+                                } else {
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
+
                                 break;
                             //--------------------------------------
                             case 20: // col 2 and row 0 on either screen 0 or 1
@@ -444,7 +435,10 @@
                                             playback.attach(&playbackISR,playbackInt);
                                         }
                                     }
+                                }else{
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
+
                                 break;
                             //----------------------------------
                             //----------------------------------
@@ -455,7 +449,10 @@
                                 } else if (dMode[whichTouched]==dateScreen){
                                     dtMode=(dtMode<6)?dtMode+1:0;
                                     lastDMode[whichTouched]=99;
+                                } else {
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
+
                                 break;
                             //------------------------------
                             case 11:
@@ -502,7 +499,10 @@
                                 } else if (dMode[whichTouched]==dateScreen){
                                     upDate(dtMode,true);
                                     lastDMode[whichTouched]=99;
+                                } else {
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
+
                                 break;
                             //---------------------------------
                             case 21: // col 2 row 1
@@ -512,7 +512,10 @@
                                 } else if (dMode[whichTouched]==dateScreen){
                                     upDate(dtMode,false);
                                     lastDMode[whichTouched]=99;
+                                } else {
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
+
                                 break;
                                 
                             //-----------------------------------
@@ -541,6 +544,7 @@
                             //------------------------------------
                             //------------------------------------
                             default:
+                                lastDMode[whichTouched]=99;//repaint to clear highlight
                                 break;
                         }
                         break;