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:
TickTock
Date:
Wed Oct 30 03:16:51 2013 +0000
Parent:
156:4e5d30535cf9
Child:
158:059abeb44ba1
Commit message:
// Added trip max/min efficiency reset; // Added second config screen and RegenMon enable/disable

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
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/common.h	Thu Oct 24 19:51:31 2013 +0000
+++ b/common.h	Wed Oct 30 03:16:51 2013 +0000
@@ -12,11 +12,12 @@
 #define playbackScreen 11
 #define dateScreen 12
 #define configScreen 13
-#define indexScreen 14
-#define tripScreen 15
-#define healthScreen 16
-#define testScreen 17
-#define maxScreens 17
+#define config2Screen 14
+#define indexScreen 15
+#define tripScreen 16
+#define healthScreen 17
+#define testScreen 18
+#define maxScreens 19
 
 #define btnGap 10
 #define ttSkin 0
--- a/displayModes.cpp	Thu Oct 24 19:51:31 2013 +0000
+++ b/displayModes.cpp	Wed Oct 30 03:16:51 2013 +0000
@@ -640,7 +640,7 @@
         showButton(2,1," GoTo","CP Bars",4,4);     
         showButton(3,1," GoTo"," Config",4,4);               
         // bottom (not Nav) row        
-        showButton(0,2," GoTo","Playback",4,4);               
+        showButton(0,2," GoTo","Playback",4,4);
         //showButton(1,2," GoTo","Set Time",4,4);             
         showButton(2,2," GoTo"," Log",4,4);     
         showButton(3,2," GoTo"," Trip",4,4);     
@@ -897,19 +897,19 @@
         tt.cls();
     }
     //-------- top row --------
-    showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4
+    //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 ;
+    //unsigned int nextSkin = skin + 1 ;
+    //if( nextSkin > maxSkin ) nextSkin = 0 ;
     
-    if( nextSkin == ttSkin ) sprintf(sTemp1,"Skin TT");
-    else if( nextSkin == ggSkin ) sprintf(sTemp1,"Skin GG");
-    else sprintf(sTemp1,"Skin %d",nextSkin);
+    //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);
+    //showButton(3,0,"  Use",sTemp1,4,4);
     
     //------- second row -----
     if (logEn&&usbEn) {
@@ -935,17 +935,89 @@
     showButton(2,1,sTemp1,"Batt Log",4,4);
     
     // add Enable/Disable Debug - debugMode
+    //if (debugMode) {
+    //    sprintf(sTemp1," Disable");
+    //} else {
+    //    sprintf(sTemp1," Enable");
+    //}
+    //showButton(3,1,sTemp1," Debug",4,4);    
+
+    if(brakeMon)
+        showButton(0,2,"Disable","BrkMon",4,4);
+    else
+        showButton(0,2," Enable"," BrkMon",4,4);
+
+    if(regenMon)
+        showButton(1,2,"Disable","RegMon",4,4);
+    else
+        showButton(1,2," Enable"," RegMon",4,4);
+    
+    //showButton(1,2,"  Set"," Time",4,4);
+    //if (showHealth) {
+    //    sprintf(sTemp1," Hide");
+    //} else {
+    //    sprintf(sTemp1," Show");
+    //}
+    //showButton(2,2,sTemp1," Health",4,4);
+    //showButton(3,2,"Update","Firmware",4,4);
+    
+}
+
+void config2(bool force, bool showButtons){
+    if (force) {
+        tt.background(Black);
+        tt.cls();
+    }
+    //-------- top row --------
+    showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4
+    showButton(1,0," Reset","  DTE",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 ;
+    
+    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&&usbEn) {
+    //    sprintf(sTemp1,"Disable");
+    //} else {
+    //    sprintf(sTemp1,"Enable");
+    //}
+    //showButton(0,1,sTemp1,"Logging",4,4);
+    
+    //if (repeatPoll) {
+    //    sprintf(sTemp1,"Disable");
+    //} else {
+    //    sprintf(sTemp1,"Enable");
+    //}
+    //showButton(1,1,sTemp1,"Auto CP",4,4);
+    
+    // add Enable/Disable Batt Log gg - yesBattLog
+    //if (yesBattLog) {
+    //    sprintf(sTemp1,"Disable");
+    //} else {
+    //    sprintf(sTemp1,"Enable");
+    //}
+    //showButton(2,1,sTemp1,"Batt Log",4,4);
+    
+    // add Enable/Disable Debug - debugMode
     if (debugMode) {
         sprintf(sTemp1," Disable");
     } else {
         sprintf(sTemp1," Enable");
     }
     showButton(3,1,sTemp1," Debug",4,4);    
-    
-    if(brakeMon)
-        showButton(0,2,"Disable","BrkMon",4,4);
-    else
-        showButton(0,2," Enable"," BrkMon",4,4);
+
+    //if(brakeMon)
+    //    showButton(0,2,"Disable","BrkMon",4,4);
+    //else
+    //    showButton(0,2," Enable"," BrkMon",4,4);
     
     showButton(1,2,"  Set"," Time",4,4);
     if (showHealth) {
@@ -1337,6 +1409,9 @@
         case configScreen:
             config(changed,showButtons);
             break;
+        case config2Screen:
+            config2(changed,showButtons);
+            break;
         case playbackScreen:
             pbScreen(changed,showButtons);
             break;
@@ -1423,6 +1498,9 @@
                     case configScreen:
                         sprintf(sTemp2," Config");
                         break;          
+                    case config2Screen:
+                        sprintf(sTemp2,"Config2");
+                        break;          
                     case playbackScreen:
                         showButton(3,0,sTemp1,"",4,4);
                         sprintf(sTemp2,"Playback");
--- a/displayModes.h	Thu Oct 24 19:51:31 2013 +0000
+++ b/displayModes.h	Wed Oct 30 03:16:51 2013 +0000
@@ -60,7 +60,7 @@
 extern signed short Imax, Imin;
 extern bool showHealth;
 extern float maxTripEff, minTripEff;
-extern bool brakeMon;
+extern bool brakeMon, regenMon;
 extern float curEff;
 extern unsigned short uMsgId[8];
 extern bool accOn;
--- a/main.cpp	Thu Oct 24 19:51:31 2013 +0000
+++ b/main.cpp	Wed Oct 30 03:16:51 2013 +0000
@@ -9,11 +9,11 @@
 // * Change pack volt color when CVLI fails
 // * Add tire pressure cal (40psi for me = FR 38, RR 38.2, FL 37.8, RL 38 - maybe 2psi error on my tire gauge?)
 // * Add heater activation warning message
-// * Add trip max/min efficiency reset
+
 
-// rev156
-// Changed efficency screen braking monitor to use actual motor amps instead of target regen signal
-// Changed braking screen to use actual regen signal instead of target regen signal
+// rev157
+// Added trip max/min efficiency reset
+// Added second config screen and RegenMon enable/disable
 
 #include "mbed.h"
 #include "CAN.h"
@@ -23,7 +23,7 @@
 #include "utility.h"
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
-char revStr[7] = "156"; // gg - revision string, max 6 characters
+char revStr[7] = "157"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");
@@ -430,7 +430,7 @@
                                 } else if (dMode[whichTouched] == indexScreen) { // gg - index
                                     dMode[whichTouched] = mainScreen ; // GoTo Main Screen
                                     sMode=0;
-                                } else if (dMode[whichTouched]==configScreen) {
+                                } else if (dMode[whichTouched]==config2Screen) {
                                     wait_ms(500);
                                     tt.background(Black);
                                     tt.calibrate();
@@ -463,6 +463,9 @@
                                     msgReq.attach(&sendReq,0.015);
                                 } else if (dMode[whichTouched]==configScreen) {
                                     mbed_reset();
+                                } else if (dMode[whichTouched]==config2Screen) { // reset DTE Max/Min
+                                    maxTripEff = 4;
+                                    minTripEff = 4;
                                 } else if (dMode[whichTouched]==playbackScreen) { // pause/unpause
                                     playbackEn=!playbackEn;
                                     if(playbackEn){
@@ -502,7 +505,7 @@
                                 
                             case 30: // right-most on top row
                                 
-                                if (dMode[whichTouched]==configScreen) {
+                                if (dMode[whichTouched]==config2Screen) {
                                     // step through skins
                                     if( skin < maxSkin ) skin += 1 ;
                                     else skin = 0 ;
@@ -605,7 +608,7 @@
                                 break;
                                 
                             case 31: // col 3 row 1
-                                if (dMode[whichTouched]==configScreen) { // gg - Batt Log Enable Button
+                                if (dMode[whichTouched]==config2Screen) { // gg - Batt Log Enable Button
                                     debugMode = !debugMode;                                
                                 } else if (dMode[whichTouched] == indexScreen) { // gg - index
                                     dMode[whichTouched] = configScreen ; // GoTo Config Screen
@@ -634,8 +637,10 @@
                                 break;
                                 
                              case 12: // left-middle col, bottom row (not nav)
-                                if (dMode[whichTouched] == configScreen) { // gg - index
+                                if (dMode[whichTouched] == config2Screen) { // gg - index
                                     dMode[whichTouched] = dateScreen ; // GoTo Set Date/Time Screen  
+                                } else if (dMode[whichTouched]==configScreen) {
+                                    regenMon = !regenMon;                                
                                 } else {
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
                                 } 
@@ -644,7 +649,7 @@
                              case 22: // right-middle col, bottom row (not nav)
                                 if (dMode[whichTouched] == indexScreen) { // gg - index
                                     dMode[whichTouched] = logScreen ;    
-                                } else if (dMode[whichTouched]==configScreen) {
+                                } else if (dMode[whichTouched]==config2Screen) {
                                     showHealth = !showHealth;
                                 } else {
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
@@ -652,7 +657,7 @@
                                 break;
 
                              case 32: // right col, bottom row (not nav)  
-                                if (dMode[whichTouched] == configScreen) {
+                                if (dMode[whichTouched] == config2Screen) {
                                     logEn=false;
                                     updateFirmware();
                                 } else if (dMode[whichTouched] == tripScreen) {