test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: displayModes.cpp
- Revision:
- 156:4e5d30535cf9
- Parent:
- 155:f31006516956
- Child:
- 157:1a100a5ed06f
--- a/displayModes.cpp Sat Oct 19 15:38:44 2013 +0000 +++ b/displayModes.cpp Thu Oct 24 19:51:31 2013 +0000 @@ -22,10 +22,6 @@ packV_x2 = (msg.data[2]<<2)+(msg.data[3]>>6); msg = lastMsg[indexLastMsg[0x54c]]; //Get ambient aTemp = msg.data[6]-56; - //msg = lastMsg[indexLastMsg[0x79a]]; //Get ambient and cabin temperature - //aTemp = msg.data[5]-41; // Need to add convertsion to C if metric - //c1Temp = msg.data[4]-41; - //c2Temp = msg.data[6]-41; msg = lastMsg[indexLastMsg[0x385]]; //Get tire pressure tireP = msg.data[2]+msg.data[3]+msg.data[4]+msg.data[5]; @@ -500,14 +496,11 @@ } } - msg = lastMsg[indexLastMsg[0x1d5]]; //Get Regen + msg = lastMsg[indexLastMsg[0x1cb]]; + targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); //Get target total braking force + //regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); //Get target regen portion + msg = lastMsg[indexLastMsg[0x1d5]]; //Get regen portion - seems to be actual regen versus target regen regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); - msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target - targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); - msg = lastMsg[indexLastMsg[0x421]]; //Get Drive Mode - if (msg.data[0]==0x18) { // In Neutral - regenBraking = 0; // No regen when in Neutral - } if (targetBraking<2045){ if ((targetBraking>50)&&(regenBraking>50)){ @@ -867,9 +860,7 @@ printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %2.0f%s %2.0f%s %2.0f%s %2.0f%s\n\n", max,min,avg,jv, convertC(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+8]),sTemperatureUnit, convertC(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+14]),sTemperatureUnit); - //printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n", - // max,min,avg,jv, battData[BatDataBaseG2*7+BatDataBaseG4*7+5],battData[BatDataBaseG2*7+BatDataBaseG4*7+8], battData[BatDataBaseG2*7+BatDataBaseG4*7+11],battData[BatDataBaseG2*7+BatDataBaseG4*7+14]); - + //--------------- // show the bars int nBarWidth = 3 ; @@ -994,7 +985,6 @@ } void showDateTime(bool force, bool showButtons){ - //unsigned char year, month, day, hour, minute, second; CANMessage msg; struct tm t; // pointer to a static tm structure time_t seconds ; @@ -1002,18 +992,6 @@ tt.background(Black); if (force||tock) { tt.cls(); - - // Read time from car - /*msg = lastMsg[indexLastMsg[0x5fa]]; - month = msg.data[5]>>4; - day = msg.data[2]>>3; - msg = lastMsg[indexLastMsg[0x5fb]]; - year = msg.data[1]; - msg = lastMsg[indexLastMsg[0x5fc]]; - hour = msg.data[0]>>3; - minute = (msg.data[1]<<4&0x30)+(msg.data[2]>>4); - second = msg.data[1]>>2;*/ - tt.locate(10,10); tt.set_font((unsigned char*) Arial12x12); if(accOn){ @@ -1039,7 +1017,6 @@ } strftime(sTemp1, 32, "%a %m/%d/%Y %X \n", &t); - //printf("Leaf: %02d:%02d:%02d %02d/%02d/%03d\n",hour,minute,second,month,day,year); printf("Leaf: %s",sTemp1); } seconds = time(NULL); @@ -1092,7 +1069,8 @@ static unsigned char leff[39]={0}; CANMessage msg; unsigned long targetBraking, regenBraking, temp; - static unsigned long maxTarget = 1000, maxRegen = 1000, tardivreg_x1000 = 1000; + //static unsigned long maxTarget = 1000, maxRegen = 1000, tardivreg_x1000 = 1000; + static unsigned long maxTarget = 1000, tardivreg_x1000 = 1400; static unsigned char lr=0, lt=0; msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids @@ -1247,23 +1225,26 @@ leff[i-1]=y; } - msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen - regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); + msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target total braking targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); - msg = lastMsg[indexLastMsg[0x421]]; //Get Drive Mode - if (msg.data[0]==0x18) { // In Neutral - regenBraking = 0; // No regen when in Neutral + + msg = lastMsg[indexLastMsg[0x1d4]]; //Get Motor Amps - simlar to 1d5/1.4 but includes coast regen + temp = (msg.data[2]<<4)+(msg.data[3]>>4); + if(temp>0x7ff){ // invert and chop positive current + regenBraking=0x1000-temp; + }else{ + regenBraking=0; } if (targetBraking<2045){ - if ((targetBraking>50)&&(regenBraking>50)){ - temp = targetBraking; - temp *= 1000; - temp /= regenBraking; - if (temp<tardivreg_x1000) tardivreg_x1000=temp; - } + //if ((targetBraking>50)&&(regenBraking>50)){ + // temp = targetBraking; + // temp *= 1000; + // temp /= regenBraking; + // if (temp<tardivreg_x1000) tardivreg_x1000=temp; + //} if (targetBraking>maxTarget) maxTarget=targetBraking; - if (regenBraking>maxRegen) maxRegen=regenBraking; + //if (regenBraking>maxRegen) maxRegen=regenBraking; temp = targetBraking; temp *=200;