test fork

Dependencies:   SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary_9341 by Tick Tock

Revision:
130:1a9d2a6d99ce
Parent:
129:8991d0de01ab
Child:
131:0d926c080a65
--- a/main.cpp	Sun Jul 21 23:59:00 2013 +0000
+++ b/main.cpp	Mon Jul 22 00:02:51 2013 +0000
@@ -4,11 +4,12 @@
 // * Audible friction brake feedback
 // * User-configurable watchpoint
 // * Add 50% charge option
+// * Tire Pressure Sensor display
+// * Fix bug in playback while connected to canbus (hangs)
 // * Add coasting regen to regen/braking display
 // * Change semilog efficiency graph to linear with 10 minute values
 // * Add additional 79b bank readouts
 // * Add ability to transfer settings config file to/from USB
-// * Subtract accessory power from efficiency history (add back in when displaying)
 
 #include "mbed.h"
 #include "CAN.h"
@@ -20,7 +21,7 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "128b"; // gg - revision string, max 6 characters
+char revStr[7] = "130"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");
@@ -53,7 +54,7 @@
 
 bool debugMode = false;
 bool usbEn = false;
-bool logEn = false;
+bool logEn = true;
 bool logOpen = false; 
 bool yesBattLog = true; // gg - Batt Log
 unsigned char tNavRow = 3; // gg - 4x4 touch
@@ -83,7 +84,7 @@
 unsigned char dMode[2] = {mainScreen,brakeScreen}; //display mode
 unsigned char sMode = 0; // setup mode
 unsigned char lastDMode[2] = {0,0}; //last screen mode
-unsigned char dtMode = 0;
+unsigned char dtMode = 6;
 char displayLog[20][40];
 unsigned char displayLoc = 0;
 unsigned int fwCount=1;
@@ -138,9 +139,6 @@
 bool metric = false;
 bool shunt[96]={0};
 bool charging=false;
-bool showHealth=false;
-unsigned char saveDmode=99;
-bool moving=false;
 
 int main() {
     //can1SleepMode.mode(OpenDrain);
@@ -226,7 +224,7 @@
     secsNoTouch=2;
     while (true) {
         if (!logOpen) { // Open new file if one is not already open
-            if(logEn&&usbEn){ //logging enabled and USB device detected
+            if(logEn&&usbEn){ //logging enables and USB device detected
                 strftime(fileName, 32, "%m%d%H%M.alc", &t); //mmddhhmm.alc
                 efr = f_open(&efile,fileName,FA_WRITE|FA_OPEN_ALWAYS);
                 seconds = time(NULL);
@@ -494,7 +492,7 @@
                                     dMode[whichTouched] = cpScreen ; // GoTo CP Data Screen                                
                                     sMode=0;
                                 } else if (dMode[whichTouched]==dateScreen){
-                                    dtMode=(dtMode<5)?dtMode+1:0;
+                                    dtMode=(dtMode<6)?dtMode+1:0;
                                     lastDMode[whichTouched]=99;
                                 } else {
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
@@ -516,9 +514,7 @@
                                 } else if (dMode[whichTouched]==playbackScreen) {
                                     // Start/stop playback
                                     if(!playbackOpen){
-                                        if(!canIdle){
-                                            printMsg("Cannot playback while connected to canbus\n");
-                                        }else if(!logOpen){
+                                        if(!logOpen){
                                             efr = f_open(&efile,"playback.alc",FA_READ|FA_OPEN_EXISTING);
                                             lastDMode[whichTouched]=99;//force refresh
                                             if(efr != FR_OK){
@@ -596,7 +592,7 @@
                                 break;
                                 
                              case 12: // left-middle col, bottom row (not nav)
-                                if (dMode[whichTouched] == configScreen) { // gg - index
+                                if (dMode[whichTouched] == indexScreen) { // gg - index
                                     dMode[whichTouched] = dateScreen ; // GoTo Set Date/Time Screen  
                                 } else {
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
@@ -606,8 +602,6 @@
                              case 22: // right-middle col, bottom row (not nav)
                                 if (dMode[whichTouched] == indexScreen) { // gg - index
                                     dMode[whichTouched] = logScreen ;    
-                                } else if (dMode[whichTouched]==configScreen) {
-                                    showHealth = !showHealth;
                                 } else {
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
                                 } 
@@ -679,8 +673,7 @@
             headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false;  // headlight/turn signal indicator
             accV=floor(mon12V*scale12V*10+0.5)/10; //Round to nearest 10th
             accOn=(accV>5)?true:false;
-            moving=(mph[0]>0.1);
-            charging=!moving&&(kW[0]<-1); // not moving and generating energy so must be charging
+            charging=(mph[0]<0.1)&&(kW[0]<-1); // not moving and generating energy so much be charging
             if(laccOn&&!accOn){ // Car turned off
                 if (repeatPoll) { // Log on shutdown if autopoll enabled
                     tripLog(); // Write trip log on powerdown
@@ -698,10 +691,6 @@
                 miles_trip[0]=0;
                 kWh_trip[0]=0;
                 wait5secs=5;
-                if(showHealth){
-                    saveDmode=dMode[0];
-                    dMode[0]=healthScreen;
-                }
             }
             laccOn=accOn;
             if(!accOn&&!logEn&&userIdle&&!playbackEn){ // Car off and logging disabled and no user activity
@@ -719,10 +708,6 @@
                     msgReq.attach(&sendReq,0.015);
                 }
             }
-            if(moving&&(saveDmode<99)&&(wait5secs==0)){
-                dMode[0]=saveDmode;
-                saveDmode=99;
-            }
 
             //compute historic efficiency
             if(numSsamples>0){ // Avoid div0