Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller
Dependencies: SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed
Fork of CANary by
Diff: utility.cpp
- Revision:
- 149:e9739523109f
- Parent:
- 148:6e3b9135fad2
- Child:
- 150:ef46ce63345c
--- a/utility.cpp Thu Sep 12 14:42:22 2013 +0000 +++ b/utility.cpp Wed Sep 25 03:33:18 2013 +0000 @@ -517,7 +517,7 @@ char buffer[bufSize]; cfile = fopen("/local/config.txt", "w"); - fprintf(cfile,"format 7\r\n"); + fprintf(cfile,"format 8\r\n"); fprintf(cfile,"x0_off %d\r\n",tt.x0_off); fprintf(cfile,"y0_off %d\r\n",tt.y0_off); fprintf(cfile,"x0_pp %d\r\n",tt.x0_pp); @@ -547,7 +547,10 @@ fprintf(cfile,"showHealth %d\r\n",(showHealth?1:0)); fprintf(cfile,"brakeMon %d\r\n",(brakeMon?1:0)); fprintf(cfile,"brkMonRate %d\r\n", brkMonRate ); - fprintf(cfile,"brkMonThr %d\r\n", brkMonThr ); + fprintf(cfile,"brkMonThr %d\r\n", brkMonThr ); + for(char i=0;i<8;i++){ + fprintf(cfile,"usrMsgId %4x\r\n", i, uMsgId[i] ); + } fclose(cfile); // Make copy of CONFIG.TXT @@ -631,8 +634,13 @@ fscanf(cfile, "brkMonRate %d\r\n", &brkMonRate ); fscanf(cfile, "brkMonThr %d\r\n", &brkMonThr ); } + if(ff>7){ + for(char i=0;i<8;i++){ + fscanf(cfile, "usrMsgId %4x\r\n", &uMsgId[i] ); + } + } 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 + if((ff>8)||(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); @@ -661,7 +669,16 @@ brakeMon=true; brkMonRate=400000; brkMonThr=4000; + uMsgId[0]=0x5103; + uMsgId[1]=0x50a3; + uMsgId[2]=0x54a4; + uMsgId[3]=0x54b4; + uMsgId[4]=0x54c0; + uMsgId[5]=0x55b4; + uMsgId[6]=0x0000; + uMsgId[7]=0x0000; } + if(ff<7){//If not latest format, save as latest format saveConfig(); printMsg("Config file format updated.\n"); // config forat updates @@ -981,6 +998,20 @@ } } +float airDrag(float F) +{ + float drag_F[16] = {1.47,1.39,1.363,1.337,1.312,1.288,1.265,1.243,1.221,1.2,1.18,1.161,1.142,1.124,1.106,1.034}; + float temp_F[16] = {-31,-4,5,14,23,32,41,50,59,68,77,86,95,104,113,149}; + char ii=0; + float drag; + while(ambient_F<=temp_F[++ii]) { } // Find section in table + drag=(ambient_F-temp_F[ii]); + drag/=(temp_F[ii-1]-temp_F[ii]); + drag*=(drag_F[ii-1]-drag_F[ii]); + drag+=drag_F[ii]; + return drag; +} + //Sample CONFIG.TXT /* format 7 @@ -1008,4 +1039,4 @@ brakeMon 1 brkMonRate 400000 brkMonThr 4000 -*/ \ No newline at end of file +*/