Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller

Dependencies:   SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
garygid
Date:
Wed Apr 10 15:08:38 2013 +0000
Parent:
63:aa3bf6a33635
Child:
66:b7476ce7a59e
Child:
67:2022fce701d0
Commit message:
Added Skin-Changing button on Config screen and
; full-button highlight in the GG skin mode - GG v64

Changed in this revision

common.h Show annotated file Show diff for this revision Revisions of this file
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
--- a/common.h	Wed Apr 10 13:08:54 2013 +0000
+++ b/common.h	Wed Apr 10 15:08:38 2013 +0000
@@ -18,6 +18,7 @@
 #define btnGap 10
 #define ttSkin 0
 #define ggSkin 1
+#define maxSkin 1
 
 #define maxBufLen 512
 #define canTimeout 5
--- a/displayModes.cpp	Wed Apr 10 13:08:54 2013 +0000
+++ b/displayModes.cpp	Wed Apr 10 15:08:38 2013 +0000
@@ -599,11 +599,20 @@
     tt.background(DarkCyan);
     tt.set_font((unsigned char*) Arial12x12);
  
+    //-------- top row --------
     showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4
-    
     showButton(1,0," Reset","",4,4);
+    showButton(2,0," Save"," Config",4,4);
+           
+    // a button to step to the next skin
+    unsigned int nextSkin = skin + 1 ;
+    if( nextSkin > maxSkin ) nextSkin = 0 ;
     
-    showButton(2,0," Save"," Config",4,4);
+    if( nextSkin == ttSkin ) sprintf(sTemp1,"Skin TT");
+    else if( nextSkin == ggSkin ) sprintf(sTemp1,"Skin GG");
+    else sprintf(sTemp1,"Skin %d",nextSkin);
+
+    showButton(3,0," Use",sTemp1,4,4);
     
     //------- second row -----
     if (logEn) {
@@ -993,14 +1002,19 @@
     x2=(column+1)*(320/columns)-btnGap/2;
     y1=row*(240/rows)+btnGap/2;
     y2=(row+1)*(240/rows)-btnGap/2;
-    /*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);*/
+    
+    tt.set_display(tScn);
+
+    if( skin == ggSkin ){
+        // paint the whole button box, for a better visual effect
+        //  especially on a screen with a yellow background
+        if( tScn == 0 )
+            tt.fillrect(x1,y1,x2,y2,White); // 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);
 }
 
--- a/main.cpp	Wed Apr 10 13:08:54 2013 +0000
+++ b/main.cpp	Wed Apr 10 15:08:38 2013 +0000
@@ -97,7 +97,7 @@
 char header[5];
 char data[8];
 signed long motorRPM;
-unsigned char skin = 0;
+unsigned char skin = ttSkin ;
 unsigned char dtePeriod = 14; //ten minute averaging interval
 float mph[39]={0};
 float kW[39]={0};
@@ -157,7 +157,8 @@
     logMsg(sTemp);
     
     // revision
-    sprintf(sTemp,"CANary firmware rev62\n");
+    //sprintf(sTemp,"CANary firmware rev62\n"); // wrong rev, should be rev63
+    sprintf(sTemp,"CANary firmware rev64\n");
     logMsg(sTemp);
 
     // Look for new binary on thumbdrive
@@ -436,6 +437,29 @@
                                 }
 
                                 break;
+                                
+                            case 30: // rightmost on top row
+                                
+                                if (dMode[whichTouched]==config1Screen) {
+                                    // step through skins
+                                    if( skin < maxSkin ) skin += 1 ;
+                                    else skin = 0 ;
+                                    
+                                    // repaint both screens, I think
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
+                                    // and re-paint the other screen too, to see new skin there
+                                    lastDMode[whichTouched ^ 1]=99; // repaint other screen (^ = XOR)
+                                    
+                                    //sprintf(sTemp,"Changed Skin to %d.\n");
+                                    //logMsg(sTemp);
+                                    //saveConfig();
+                                    //spkr.beep(2000,0.25);
+                               
+                                }else{
+                                    lastDMode[whichTouched]=99;//repaint to clear highlight
+                                }
+
+                                break;
                             //----------------------------------
                             //----------------------------------
                             case 01: // col 0 row 1