test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: utility.cpp
- Revision:
- 148:6e3b9135fad2
- Parent:
- 147:e0f1c84c62a6
- Child:
- 149:e9739523109f
diff -r e0f1c84c62a6 -r 6e3b9135fad2 utility.cpp --- a/utility.cpp Wed Aug 07 13:36:13 2013 +0000 +++ b/utility.cpp Thu Sep 12 14:42:22 2013 +0000 @@ -354,14 +354,15 @@ } motorRPM+=imotorRPM; numSsamples++; - }else if((mType==2)&&(canRXmsg.id==0x1ca)){ //Brake Pressure +// }else if((mType==2)&&(canRXmsg.id==0x1ca)){ //Brake Pressure + }else if((mType==2)&&(canRXmsg.id==0x292)){ //Brake Pressure if(brakeMon){ if(canRXmsg.data[0]<0xff){ - if((canRXmsg.data[0]*imotorRPM)<brkMonThr){ + if((canRXmsg.data[6]*imotorRPM)<brkMonThr){ chirpInt=0; }else{ chirpInt=brkMonRate/imotorRPM; - chirpInt/=canRXmsg.data[0]; + chirpInt/=canRXmsg.data[6]; } } } @@ -631,6 +632,36 @@ fscanf(cfile, "brkMonThr %d\r\n", &brkMonThr ); } fclose(cfile); + if((ff>7)||(ff<1)||(ledHi<0.1)||(scale12V<10)||(tt.x_mid<16000)||(ledHi>1)||(ledLo>1)||(dMode[0]>maxScreens)||(dMode[1]>maxScreens)){ //Sanity check a few things + //Something wrong. Load defaults + printf("Invalid config file. Loading defaults.\n"); + wait(3); + ff=8; + tt.x0_off=5732; + tt.y0_off=34009; + tt.x0_pp=77; + tt.y0_pp=106; + tt.x1_off=33955; + tt.y1_off=6310; + tt.x1_pp=80; + tt.y1_pp=104; + tt.x_mid=31986; + dMode[0]=4; + dMode[1]=2; + ledHi=0.800; + ledLo=0.100; + pollInt=300; + scale12V=16.20; + skin=0; + dtePeriod=14; + debugMode=false; + metric=false; + fwCount=1; + showHealth=true; + brakeMon=true; + brkMonRate=400000; + brkMonThr=4000; + } if(ff<7){//If not latest format, save as latest format saveConfig(); printMsg("Config file format updated.\n"); // config forat updates @@ -806,7 +837,7 @@ f_lseek(&bfile,0xffffffff); // go to end of file to append strftime(sTemp, 40, "%a %m/%d/%Y %X", &t); f_printf(&bfile,"%s,",sTemp); - sprintf(sTemp,"%d,%3.1f,%d,%5.1f%%,%5.1f%%,%4.2f,%5.1f,%4.1f,%d,%d,%d,%d,%d,%4.1f,%4.1f",odo,accV,gids,(float)SOC/10, (float)SOH2_x100/100,(float)Ah_x10000/10000,(float)packV_x2/2,(float)packA_x2/2,max,min,avg,max-min,jv,miles_trip[0],kWh_trip[0]); + sprintf(sTemp,"%d,%3.1f,%d,%5.1f%%,%5.1f%%,%4.2f,%5.1f,%4.1f,%4.1f,%d,%d,%d,%d,%d,%4.1f,%4.1f",odo,accV,gids,(float)SOC/10, (float)SOH2_x100/100,(float)Ah_x10000/10000,(float)packV_x2/2,(float)packA_x2/2,Resr,max,min,avg,max-min,jv,miles_trip[0],kWh_trip[0]); f_printf(&bfile,"%s,",sTemp); f_printf(&bfile,"%d,%d,%d,%d,",(battData[(BatDataBaseG4*7)+ 3]<<8)+battData[(BatDataBaseG4*7)+ 4],battData[(BatDataBaseG4*7)+ 5],(battData[(BatDataBaseG4*7)+ 6]<<8)+battData[(BatDataBaseG4*7)+ 7],battData[(BatDataBaseG4*7)+ 8]); f_printf(&bfile,"%d,%d,%d,%d", (battData[(BatDataBaseG4*7)+ 9]<<8)+battData[(BatDataBaseG4*7)+10],battData[(BatDataBaseG4*7)+11],(battData[(BatDataBaseG4*7)+12]<<8)+battData[(BatDataBaseG4*7)+13],battData[(BatDataBaseG4*7)+14]); @@ -853,6 +884,7 @@ fclose(lfile); } f_close(&efile); + readConfig(); wait(2); } @@ -865,9 +897,7 @@ return; } fwCount ++; - saveConfig(); - tt.cls(); - printf("Saved Configuration\n"); + saveConfig(); //delete all bin files in /local DIR *dir; struct dirent *ent; @@ -946,6 +976,8 @@ spkr.beep(500,0.015); counter=0; } + }else{ + counter=0; } } @@ -971,7 +1003,7 @@ dtePeriod 14 DebugMode 0 metric 0 -firmware 11 +firmware 1 showHealth 1 brakeMon 1 brkMonRate 400000