Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary by
Diff: main.cpp
- Branch:
- Metric
- Revision:
- 111:d1559bb25c43
- Parent:
- 110:ffddff3ad2f2
- Child:
- 112:b41b35401eb6
diff -r ffddff3ad2f2 -r d1559bb25c43 main.cpp
--- a/main.cpp Sun Jun 30 19:52:38 2013 +0000
+++ b/main.cpp Sun Jun 30 23:04:56 2013 +0000
@@ -2,7 +2,6 @@
//
//To Do:
// * USB device detect
-// * Enable file timestamps
// * Audible friction brake feedback
// * User-configurable watchpoint
// * Add 50% charge option
@@ -11,13 +10,9 @@
// ** Force regen display to zero when in neutral
// * Add coasting regen to regen/braking display
// * Change semilog efficiency graph to linear with 10 minute values
-// * Make display updates interruptable for log writes
// * Add additional 79b bank readouts
// * Add ability to transfer settings config file to/from USB
-// * Add once-on-powerup/powerdown log
// * Move log dump to ISR (but CAN RX at higher priority)
-// * Fix bug preventing setting logEn to true by default
-
#include "mbed.h"
#include "CAN.h"
@@ -29,14 +24,13 @@
#include "displayModes.h"
#include "TOUCH_TFTx2.h"
-char revStr[7] = "110"; // gg - revision string, max 6 characters
+char revStr[7] = "111"; // gg - revision string, max 6 characters
FATFS USBdrive;
LocalFileSystem local("local");
bool waitasec = true;
// to write to USB Flash Drives, or equivalent (SD card in Reader/Writer)
-FRESULT mfr=f_mount(0,&USBdrive);
-
+FRESULT mfr = f_mount(0,&USBdrive);
time_t seconds ;
Ticker autoPoll;
@@ -149,7 +143,6 @@
unsigned char i,j,display=0,lwt=0;
point lastTouch;
float average;
- usbEn=detectUSB();
tt.set_orientation(1);
tt.background(Black);
tt.set_display(2); // select both displays
@@ -182,6 +175,8 @@
// revision
sprintf(sTemp,"CANary firmware rev%s\n", revStr); // gg - for Logging the revision
printMsg(sTemp); // revision
+ //sprintf(sTemp,"free clusters = %d\n", freeClusters);
+ //printMsg(sTemp); // revision
secsNoMsg = 0;
@@ -292,10 +287,9 @@
if (repeatPoll) { // stop autopolling if enabled
autoPoll.detach();
}
- //keep file open when asleep - new lseek not fast
- //if (logOpen){
- // f_close(&efile);
- //} // if (logOpen)*/
+ if (logOpen){ //close file to dump buffer
+ f_close(&efile);
+ } // if (logOpen)
seconds = time(NULL);
t = *localtime(&seconds) ;
strftime(sTemp, 40, "Sleeping: %a %m/%d/%Y %X\n", &t);
@@ -331,9 +325,8 @@
} // if (logOpen)
if (secsNoTouch>100) secsNoTouch = 100; // also mostly reset user Idle counter
} else if (logOpen){ // insert timestamp on each wake if logging enabled (disabled for now)
- //file kept open
- //efr = f_open(&efile,fileName,FA_WRITE|FA_OPEN_ALWAYS);
- //f_lseek(&efile,0xffffffff); // goto end of file (append existing)
+ efr = f_open(&efile,fileName,FA_WRITE|FA_OPEN_ALWAYS);
+ f_lseek(&efile,0xffffffff); // goto end of file (append existing)
logEvent("WakingUp"); // gg - use messeges
logTS(); // Date-Time at wakeup
}
@@ -483,12 +476,6 @@
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");
- //printMsg(sTemp); /// changed skin - for debug
- //saveConfig();
- //spkr.beep(2000,0.25);
-
} else if (dMode[whichTouched] == indexScreen) { // gg - index
dMode[whichTouched] = dteScreen ; // GoTo DTE Screen
sMode=0;
@@ -685,7 +672,6 @@
}
if(tick){ // Executes once a second
- waitasec=false; // work around to avoid hang when USB tries to init immediately
tick=false;
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
@@ -780,6 +766,7 @@
if(!usbEn){
usbEn=detectUSB(); // Keep looking if none found
}
+ waitasec=false; // work around to avoid hang when USB tries to init immediately
}
display=display<1?display+1:0; // toggle display
