Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary by
Diff: displayModes.cpp
- Revision:
- 152:a4d66901785d
- Parent:
- 151:3047ebb3c9a8
- Child:
- 153:e94cfe3c339c
diff -r 3047ebb3c9a8 -r a4d66901785d displayModes.cpp --- a/displayModes.cpp Mon Sep 30 15:31:01 2013 +0000 +++ b/displayModes.cpp Sun Oct 06 14:49:09 2013 +0000 @@ -296,6 +296,7 @@ void tripDisplay (bool force, bool showButtons){ static float lkWh=0; + float mpkwh_f; tt.background(White); if(force){ tt.cls(); @@ -306,8 +307,13 @@ tt.locate(6,210); printf("kWh : %s : Eff\n",distanceUnit()); for(int i=0; i<3; i++){ + if(kWh_trip[i]>0.01){ + mpkwh_f = convertDistance(miles_trip[i])/kWh_trip[i]; + } else { + mpkwh_f = 0; + } tt.locate(6,20+i*60); - printf("%3.2f : %3.1f : %2.1f \n",kWh_trip[i],convertDistance(miles_trip[i]),convertDistance(miles_trip[i])/kWh_trip[i]); + printf("%3.2f : %3.1f : %2.1f \n",kWh_trip[i],convertDistance(miles_trip[i]),mpkwh_f); } tt.foreground(Navy); tt.set_font((unsigned char*) Arial12x12); @@ -987,19 +993,49 @@ } 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 ; tt.foreground(Yellow); tt.background(Black); - if (force) { + if (force||tock) { tt.cls(); - seconds = time(NULL); - t = *localtime(&seconds) ; - + + // 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){ + seconds = time(NULL); + t = *localtime(&seconds); + msg = lastMsg[indexLastMsg[0x5fa]]; + t.tm_mon = (msg.data[5]>>4)-1; + t.tm_mday = msg.data[2]>>3; + msg = lastMsg[indexLastMsg[0x5fb]]; + //t.tm_year = msg.data[1]; + msg = lastMsg[indexLastMsg[0x5fc]]; + t.tm_hour = msg.data[0]>>3; + t.tm_min = (msg.data[1]<<4&0x30)+(msg.data[2]>>4); + t.tm_sec = msg.data[1]>>2; + 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); + t = *localtime(&seconds); strftime(sTemp1, 32, "%a %m/%d/%Y %X \n", &t); - printf("%s",sTemp1); + tt.locate(10,24); + printf("CANary: %s",sTemp1); if(showButtons){ switch(dtMode){ case 0: @@ -1024,8 +1060,16 @@ break; } showButton(0,1,sTemp1,"",4,4); - showButton(1,1," UP","",4,4); - showButton(2,1," DOWN","",4,4); + showButton(1,1," Up","",4,4); + showButton(2,1," Down","",4,4); + if(accOn){ + showButton(3,1," Sync","w/ car",4,4); + } + if(autoSync){ + showButton(3,2,"disable"," auto",4,4); + }else{ + showButton(3,2,"enable"," auto",4,4); + } } } } @@ -1234,13 +1278,9 @@ void testDisplay (bool force, bool showButtons){ static unsigned short maxPS=0; - unsigned char i, uData[8]; + unsigned char i, uData[8], year, month, day, hour, minute, second; CANMessage msg; - for (i=0; i<8; i++){ - msg = lastMsg[indexLastMsg[(uMsgId[i]>>4)]]; //Get ambient - uData[i] = msg.data[(uMsgId[i]&0x000f)]; - } tt.set_font((unsigned char*) Arial24x23); tt.foreground(Yellow); tt.background(Navy); @@ -1250,8 +1290,22 @@ if(pointerSep>maxPS){maxPS=pointerSep;} tt.locate(10,10); printf("%3d sep %3d max\n",pointerSep,maxPS); - tt.locate(10,40); - printf("%4.2fV %4.2fV \n",accV,accV2); + 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(0,40); + printf("%02d%02d%02d %02d%02d%03d\n",hour,minute,second,month,day,year); + //printf("%4.2fV %4.2fV \n",accV,accV2); + for (i=0; i<8; i++){ + msg = lastMsg[indexLastMsg[(uMsgId[i]>>4)]]; + uData[i] = msg.data[(uMsgId[i]&0x000f)]; + } for (i=0; i<4; i++){ tt.locate(10,90+i*30); printf("%4x:%2x %4x:%2x\n",uMsgId[i],uData[i],uMsgId[i+4],uData[i+4]);