Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller

Dependencies:   SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed

Fork of CANary by Tick Tock

Committer:
TickTock
Date:
Tue Dec 24 12:20:50 2013 +0000
Revision:
170:7ee98e3611bc
Parent:
169:84d790ac18a2
Child:
171:355e284f5201
// Added kWperGid scalar to config file.  .075 appears to be too small; // Added CCkWh_trip to TripLog (after kWh_trip); // Added uncalibrated available regen bars to dte screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TickTock 13:62e0f7f39ff5 1 //displayModes.cpp
TickTock 37:fea2c1d52c5f 2 #include "displayModes.h"
TickTock 13:62e0f7f39ff5 3
TickTock 25:ddf0ec209f03 4 char sTemp1[40];
TickTock 24:6cf76ed8c432 5 char sTemp2[16];
TickTock 13:62e0f7f39ff5 6
TickTock 42:4533b13b297d 7 void mainDisplay (bool force, bool showButtons){
TickTock 124:0d622967b764 8 unsigned short gids, SOC_x10, packV_x2, tireP;
TickTock 165:4daa921730dd 9 float dte,total_kW;
TickTock 150:ef46ce63345c 10 unsigned char aTemp;
TickTock 148:6e3b9135fad2 11 static unsigned short lgids=0, lSOC=0, lpackV_x2=0, ltireP=0;
TickTock 148:6e3b9135fad2 12 static unsigned char laTemp=0;
TickTock 165:4daa921730dd 13 static float lmaxTemp=0, lkW=0, laccV=0, lmpkWh=0, useable_kWh=0;
TickTock 131:0d926c080a65 14
TickTock 13:62e0f7f39ff5 15 CANMessage msg;
TickTock 13:62e0f7f39ff5 16
TickTock 13:62e0f7f39ff5 17 msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
TickTock 13:62e0f7f39ff5 18 gids = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 13:62e0f7f39ff5 19 msg = lastMsg[indexLastMsg[0x55b]]; //Get SOC
TickTock 122:138a40892a4c 20 SOC_x10 = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 13:62e0f7f39ff5 21 msg = lastMsg[indexLastMsg[0x1db]]; //Get pack volts
TickTock 119:0e2b641e98a2 22 packV_x2 = (msg.data[2]<<2)+(msg.data[3]>>6);
TickTock 150:ef46ce63345c 23 msg = lastMsg[indexLastMsg[0x54c]]; //Get ambient
TickTock 150:ef46ce63345c 24 aTemp = msg.data[6]-56;
TickTock 124:0d622967b764 25 msg = lastMsg[indexLastMsg[0x385]]; //Get tire pressure
TickTock 124:0d622967b764 26 tireP = msg.data[2]+msg.data[3]+msg.data[4]+msg.data[5];
TickTock 118:02010b18efdc 27
TickTock 13:62e0f7f39ff5 28 tt.background(Navy);
TickTock 38:155ec32c5e91 29 tt.set_font((unsigned char*) Arial28x28);
TickTock 13:62e0f7f39ff5 30 if(force) tt.cls();
TickTock 48:d1ce92104a1f 31 if(skin==ttSkin){
TickTock 165:4daa921730dd 32 if(force||gids!=lgids){
TickTock 166:ec3951ba9701 33 tt.locate(10,4);
TickTock 136:41a204105511 34 tt.foreground(White);
TickTock 165:4daa921730dd 35 printf("%dgids \n",gids);
TickTock 170:7ee98e3611bc 36 useable_kWh = (float)(gids-5)*kWperGid;
TickTock 136:41a204105511 37 if (useable_kWh<0){
TickTock 136:41a204105511 38 useable_kWh=0;
TickTock 136:41a204105511 39 }
TickTock 168:9227024c4e3a 40 tt.locate(181,4);
TickTock 167:58d4edf403d4 41 if (useable_kWh<9.95){
TickTock 168:9227024c4e3a 42 printf("%3.2fkWh\n",useable_kWh);
TickTock 165:4daa921730dd 43 } else {
TickTock 168:9227024c4e3a 44 printf("%3.1fkWh\n",useable_kWh);
TickTock 165:4daa921730dd 45 }
TickTock 165:4daa921730dd 46 }
TickTock 165:4daa921730dd 47 if(force||SOC_x10!=lSOC){
TickTock 166:ec3951ba9701 48 tt.locate(10,34);//216,10
TickTock 165:4daa921730dd 49 tt.foreground(LightGrey);
TickTock 166:ec3951ba9701 50 printf("%2.1f%s\n",(float)SOC_x10/10,"%");
TickTock 165:4daa921730dd 51 lSOC=SOC_x10;
TickTock 165:4daa921730dd 52 }
TickTock 165:4daa921730dd 53 total_kW=kW[0]+CCkW;
TickTock 165:4daa921730dd 54 if(force||total_kW!=lkW){
TickTock 165:4daa921730dd 55 tt.foreground(Yellow);
TickTock 168:9227024c4e3a 56 if(total_kW<=-9.95){ //Right justify
TickTock 168:9227024c4e3a 57 tt.locate(186,34);
TickTock 168:9227024c4e3a 58 printf("%3.1fkW\n",total_kW);
TickTock 165:4daa921730dd 59 } else if (total_kW<0){
TickTock 168:9227024c4e3a 60 tt.locate(186,34);
TickTock 168:9227024c4e3a 61 printf("%3.2fkW\n",total_kW);
TickTock 168:9227024c4e3a 62 } else if (total_kW<9.95){
TickTock 168:9227024c4e3a 63 tt.locate(180,34);
TickTock 168:9227024c4e3a 64 printf(" %3.2fkW\n",total_kW);
TickTock 165:4daa921730dd 65 } else {
TickTock 168:9227024c4e3a 66 tt.locate(180,34);
TickTock 168:9227024c4e3a 67 printf(" %3.1fkW\n",total_kW);
TickTock 165:4daa921730dd 68 }
TickTock 165:4daa921730dd 69 lkW=total_kW;
TickTock 165:4daa921730dd 70 if(CCon){
TickTock 165:4daa921730dd 71 tt.set_font((unsigned char*) Arial12x12);
TickTock 169:84d790ac18a2 72 tt.locate(228,64);
TickTock 169:84d790ac18a2 73 tt.foreground(GreenYellow);
TickTock 169:84d790ac18a2 74 printf(" -%3.2fkW\n",CCkW);
TickTock 165:4daa921730dd 75 tt.set_font((unsigned char*) Arial28x28);
TickTock 165:4daa921730dd 76 }
TickTock 165:4daa921730dd 77 }
TickTock 165:4daa921730dd 78 if(force||gids!=lgids||mpkWh[dtePeriod]!=lmpkWh){
TickTock 132:08748a67280a 79 // Display DTE
TickTock 167:58d4edf403d4 80 // worst-case DTE
TickTock 167:58d4edf403d4 81 // Compute DTE based on worst saved trip efficiency (without climate control) and adding the impact
TickTock 167:58d4edf403d4 82 // of the current climate control power relative to the last 10 minutes of driving
TickTock 167:58d4edf403d4 83 dte=convertDistance((minTripEff-mpkWh_noCC+mpkWh[dtePeriod])*useable_kWh); //LM - add metric conversion
TickTock 136:41a204105511 84 tt.foreground(Green);
TickTock 166:ec3951ba9701 85 tt.locate(10,84);
TickTock 139:ac227b203ef2 86 if(dte>=9.5){
TickTock 163:3b6fab958773 87 printf("%2.0f \n",dte);
TickTock 136:41a204105511 88 }else{
TickTock 163:3b6fab958773 89 printf("%2.1f \n",dte);
TickTock 136:41a204105511 90 }
TickTock 136:41a204105511 91
TickTock 163:3b6fab958773 92 // 10-minute DTE
TickTock 48:d1ce92104a1f 93 tt.set_font((unsigned char*) SCProSB31x55);
TickTock 136:41a204105511 94 tt.foreground(Yellow);
TickTock 163:3b6fab958773 95 dte=convertDistance(mpkWh[dtePeriod]*useable_kWh); //LM - add metric conversion
TickTock 136:41a204105511 96 if(dte>199){
TickTock 136:41a204105511 97 dte=199;
TickTock 136:41a204105511 98 }
TickTock 136:41a204105511 99 // " "=0x10, "."=0x15, #=0x1D
TickTock 139:ac227b203ef2 100 if(dte>=99.5){
TickTock 165:4daa921730dd 101 tt.locate(70,85);
TickTock 163:3b6fab958773 102 printf(" %3.0f\n",dte);
TickTock 139:ac227b203ef2 103 }else if(dte>=9.5){
TickTock 165:4daa921730dd 104 tt.locate(84,85);
TickTock 163:3b6fab958773 105 printf(" %2.0f\n",dte);
TickTock 136:41a204105511 106 }else{
TickTock 165:4daa921730dd 107 tt.locate(79,85);
TickTock 163:3b6fab958773 108 printf(" %2.1f\n",dte);
TickTock 136:41a204105511 109 }
TickTock 136:41a204105511 110 tt.set_font((unsigned char*) Arial28x28);
TickTock 165:4daa921730dd 111 tt.locate(185,106);
TickTock 163:3b6fab958773 112 printf("%s\n",distanceUnit());
TickTock 136:41a204105511 113
TickTock 163:3b6fab958773 114 // No Climate Control DTE
TickTock 163:3b6fab958773 115 tt.set_font((unsigned char*) Arial24x23);
TickTock 164:46ed06263b0e 116 if(CCon) {
TickTock 165:4daa921730dd 117 dte=convertDistance((mpkWh_noCC-mpkWh[dtePeriod])*useable_kWh); //LM - add metric conversion
TickTock 164:46ed06263b0e 118 if(dte>199){
TickTock 164:46ed06263b0e 119 dte=199;
TickTock 164:46ed06263b0e 120 }
TickTock 169:84d790ac18a2 121 tt.foreground(GreenYellow);
TickTock 169:84d790ac18a2 122 if(dte>=9.5){
TickTock 169:84d790ac18a2 123 tt.locate(130,134);
TickTock 169:84d790ac18a2 124 printf("+%2.0f \n",dte);
TickTock 164:46ed06263b0e 125 }else{
TickTock 169:84d790ac18a2 126 tt.locate(130,134);
TickTock 169:84d790ac18a2 127 printf("+%2.1f \n",dte);
TickTock 169:84d790ac18a2 128 }
TickTock 169:84d790ac18a2 129
TickTock 167:58d4edf403d4 130 lmaxTemp=0; //force battery termperature refresh (sometimes overlaps)
TickTock 163:3b6fab958773 131 }
TickTock 163:3b6fab958773 132 // best-case DTE
TickTock 163:3b6fab958773 133 tt.set_font((unsigned char*) Arial28x28);
TickTock 167:58d4edf403d4 134 // Compute DTE based on best saved trip efficiency (without climate control) and adding the impact
TickTock 167:58d4edf403d4 135 // of the current climate control power relative to the last 10 minutes of driving
TickTock 167:58d4edf403d4 136 dte=convertDistance((maxTripEff-mpkWh_noCC+mpkWh[dtePeriod])*useable_kWh); //LM - add metric conversion
TickTock 136:41a204105511 137 tt.foreground(Orange);
TickTock 139:ac227b203ef2 138 if(dte>=99.5){
TickTock 165:4daa921730dd 139 tt.locate(255,84);
TickTock 163:3b6fab958773 140 printf("%3.0f \n",dte);
TickTock 139:ac227b203ef2 141 }else if(dte>=9.5){
TickTock 165:4daa921730dd 142 tt.locate(270,84);
TickTock 163:3b6fab958773 143 printf("%2.0f \n",dte);
TickTock 136:41a204105511 144 }else{
TickTock 165:4daa921730dd 145 tt.locate(265,84);
TickTock 163:3b6fab958773 146 printf("%2.1f \n",dte);
TickTock 136:41a204105511 147 }
TickTock 50:83d5864c64a0 148 lmpkWh=mpkWh[dtePeriod];
TickTock 165:4daa921730dd 149 } //!(force||gids!=lgids||mpkWh[dtePeriod]!=lmpkWh)
TickTock 165:4daa921730dd 150 lgids=gids;
TickTock 136:41a204105511 151 if(force||packV_x2!=lpackV_x2){
TickTock 136:41a204105511 152 tt.locate(210,176);
TickTock 136:41a204105511 153 tt.foreground(Yellow);
TickTock 136:41a204105511 154 printf("%4.1fV\n",(float)packV_x2/2);
TickTock 136:41a204105511 155 lpackV_x2=packV_x2;
TickTock 136:41a204105511 156 ltireP=0;//Force tire pressure redraw, too
TickTock 136:41a204105511 157 }
TickTock 150:ef46ce63345c 158 if(force||aTemp!=laTemp){
TickTock 138:a2f5af85ed0d 159 tt.foreground(Cyan);
TickTock 166:ec3951ba9701 160 tt.locate(10,146);
TickTock 150:ef46ce63345c 161 printf("%2.0f%s\n",convertF(aTemp),temperatureUnit());
TickTock 150:ef46ce63345c 162 laTemp=aTemp;
TickTock 148:6e3b9135fad2 163 }
TickTock 136:41a204105511 164 if(force||maxTemp!=lmaxTemp){
TickTock 136:41a204105511 165 tt.foreground(Cyan);
TickTock 138:a2f5af85ed0d 166 tt.locate(210,146);
TickTock 168:9227024c4e3a 167 if (convertC(maxTemp)<99.5){
TickTock 148:6e3b9135fad2 168 printf(" %3.1f%s\n",convertC(maxTemp),temperatureUnit());
TickTock 136:41a204105511 169 }else{
TickTock 148:6e3b9135fad2 170 printf("%4.1f%s\n",convertC(maxTemp),temperatureUnit());
TickTock 136:41a204105511 171 }
TickTock 136:41a204105511 172 lmaxTemp=maxTemp;
TickTock 136:41a204105511 173 }
TickTock 136:41a204105511 174 if(force||accV!=laccV){
TickTock 166:ec3951ba9701 175 tt.locate(10,176);
TickTock 136:41a204105511 176 tt.foreground(Yellow);
TickTock 148:6e3b9135fad2 177 printf("%3.1fV \n",accV);
TickTock 136:41a204105511 178 laccV=accV;
TickTock 136:41a204105511 179 }
TickTock 131:0d926c080a65 180 if(force||tireP!=ltireP){
TickTock 134:ad243e4f1a17 181 if(msg.data[2]<minTirePressure){
TickTock 134:ad243e4f1a17 182 tt.foreground(Orange); // Hi-light if any are low (<35psi)
TickTock 134:ad243e4f1a17 183 }else{
TickTock 134:ad243e4f1a17 184 tt.foreground(LightGrey);
TickTock 134:ad243e4f1a17 185 }
TickTock 131:0d926c080a65 186 if(msg.data[6]&0x80){
TickTock 134:ad243e4f1a17 187 if(msg.data[2]<minTirePressure){
TickTock 134:ad243e4f1a17 188 tt.foreground(Orange); // Hi-light if any are low (<35psi)
TickTock 134:ad243e4f1a17 189 }else{
TickTock 134:ad243e4f1a17 190 tt.foreground(LightGrey);
TickTock 134:ad243e4f1a17 191 }
TickTock 131:0d926c080a65 192 tt.locate(10,206);
TickTock 131:0d926c080a65 193 printf("%3.1f\n",(float)msg.data[2]/4);
TickTock 131:0d926c080a65 194 }
TickTock 131:0d926c080a65 195 if(msg.data[6]&0x40){
TickTock 134:ad243e4f1a17 196 if(msg.data[3]<minTirePressure){
TickTock 134:ad243e4f1a17 197 tt.foreground(Orange); // Hi-light if any are low (<35psi)
TickTock 134:ad243e4f1a17 198 }else{
TickTock 134:ad243e4f1a17 199 tt.foreground(LightGrey);
TickTock 134:ad243e4f1a17 200 }
TickTock 131:0d926c080a65 201 tt.locate(90,206);
TickTock 131:0d926c080a65 202 printf("%3.1f\n",(float)msg.data[3]/4);
TickTock 131:0d926c080a65 203 }
TickTock 131:0d926c080a65 204 if(msg.data[6]&0x20){
TickTock 134:ad243e4f1a17 205 if(msg.data[4]<minTirePressure){
TickTock 134:ad243e4f1a17 206 tt.foreground(Orange); // Hi-light if any are low (<35psi)
TickTock 134:ad243e4f1a17 207 }else{
TickTock 134:ad243e4f1a17 208 tt.foreground(LightGrey);
TickTock 134:ad243e4f1a17 209 }
TickTock 131:0d926c080a65 210 tt.locate(170,206);
TickTock 131:0d926c080a65 211 printf("%3.1f\n",(float)msg.data[4]/4);
TickTock 131:0d926c080a65 212 }
TickTock 131:0d926c080a65 213 if(msg.data[6]&0x10){
TickTock 134:ad243e4f1a17 214 if(msg.data[5]<minTirePressure){
TickTock 134:ad243e4f1a17 215 tt.foreground(Orange); // Hi-light if any are low (<35psi)
TickTock 134:ad243e4f1a17 216 }else{
TickTock 134:ad243e4f1a17 217 tt.foreground(LightGrey);
TickTock 134:ad243e4f1a17 218 }
TickTock 131:0d926c080a65 219 tt.locate(250,206);
TickTock 131:0d926c080a65 220 printf("%3.1f\n",(float)msg.data[5]/4);
TickTock 131:0d926c080a65 221 }
TickTock 131:0d926c080a65 222 ltireP=tireP;
TickTock 102:fd19f777a0b4 223 }
TickTock 48:d1ce92104a1f 224 }else {//if(skin==ggSkin){
TickTock 48:d1ce92104a1f 225 if(force||gids!=lgids){
TickTock 48:d1ce92104a1f 226 tt.locate(10,10);
TickTock 48:d1ce92104a1f 227 printf("%4d GIDs \n",gids);
TickTock 48:d1ce92104a1f 228
TickTock 48:d1ce92104a1f 229 tt.locate(40,40); // gg - add GIDs Percent of 281
TickTock 48:d1ce92104a1f 230 printf("%4.1f%s \n", (float)gids*0.355872, "% ") ;
TickTock 48:d1ce92104a1f 231 tt.locate(20,70);
TickTock 170:7ee98e3611bc 232 printf("%4.1f kwh \n",(float)gids*kWperGid); // gg - closer to usable
TickTock 48:d1ce92104a1f 233
TickTock 48:d1ce92104a1f 234 tt.set_font((unsigned char*) SCProSB31x55);
TickTock 48:d1ce92104a1f 235 tt.foreground(Green);
TickTock 48:d1ce92104a1f 236 //tt.locate(60,96);
TickTock 48:d1ce92104a1f 237 tt.locate(60,116); // gg - move down a little
leafman 98:9f8bab96edff 238 printf("%4.1f %s \n",convertDistance((float)(gids-5)*0.31),distanceUnit()); // Approx for now - LM added metric
TickTock 48:d1ce92104a1f 239 lgids=gids;
TickTock 48:d1ce92104a1f 240 tt.foreground(Yellow);
TickTock 48:d1ce92104a1f 241 tt.set_font((unsigned char*) Arial28x28);
TickTock 48:d1ce92104a1f 242 }
TickTock 48:d1ce92104a1f 243
TickTock 122:138a40892a4c 244 if(force||SOC_x10!=lSOC){
TickTock 48:d1ce92104a1f 245 tt.locate(200,10);
TickTock 122:138a40892a4c 246 printf("%4.1f%s\n",(float)SOC_x10/10,"% ");
TickTock 122:138a40892a4c 247 lSOC=SOC_x10;
TickTock 48:d1ce92104a1f 248 }
TickTock 119:0e2b641e98a2 249 if(force||packV_x2!=lpackV_x2){
TickTock 48:d1ce92104a1f 250 tt.locate(200,200);
TickTock 119:0e2b641e98a2 251 printf("%4.1fV \n",(float)packV_x2/2);
TickTock 119:0e2b641e98a2 252 lpackV_x2=packV_x2;
TickTock 48:d1ce92104a1f 253 }
TickTock 48:d1ce92104a1f 254 if(force||accV!=laccV){
TickTock 48:d1ce92104a1f 255 tt.locate(20,200);
TickTock 48:d1ce92104a1f 256 printf("%3.1fV \n",accV);
TickTock 48:d1ce92104a1f 257 laccV=accV;
TickTock 48:d1ce92104a1f 258 }
TickTock 161:71ac85d11f03 259 total_kW=kW[0]+CCkW;
TickTock 161:71ac85d11f03 260 if(force||total_kW!=lkW){
TickTock 48:d1ce92104a1f 261 tt.locate(160,40); // gg - move left to keep from wrap
TickTock 161:71ac85d11f03 262 printf("%3.2fkw \n",total_kW); // use small w to save space
TickTock 161:71ac85d11f03 263 lkW=total_kW;
TickTock 48:d1ce92104a1f 264 }
TickTock 35:5acbd8a64a89 265 }
TickTock 108:29b5a760adc2 266 if(led4){
TickTock 106:f016912a03db 267 tt.fillcircle(310,10,6,Red);
TickTock 106:f016912a03db 268 }else{
TickTock 106:f016912a03db 269 tt.fillcircle(310,10,6,Navy);
TickTock 106:f016912a03db 270 }
TickTock 13:62e0f7f39ff5 271 }
TickTock 13:62e0f7f39ff5 272
TickTock 42:4533b13b297d 273 void printLast (bool force, bool showButtons){
TickTock 13:62e0f7f39ff5 274 CANMessage msg;
TickTock 13:62e0f7f39ff5 275 tt.locate(0,6);
TickTock 13:62e0f7f39ff5 276 tt.foreground(Red);
TickTock 13:62e0f7f39ff5 277 tt.background(Yellow);
TickTock 13:62e0f7f39ff5 278 if(force) tt.cls(); // Just clear screen if forced - always update display
TickTock 13:62e0f7f39ff5 279 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 13:62e0f7f39ff5 280 for(int i=0; i<19; i++){
TickTock 13:62e0f7f39ff5 281 msg = lastMsg[i+indexOffset];
TickTock 13:62e0f7f39ff5 282 printf("%03x : %02x %02x %02x %02x %02x %02x %02x %02x \n",msg.id,msg.data[0],msg.data[1],msg.data[2],msg.data[3],msg.data[4],msg.data[5],msg.data[6],msg.data[7]);
TickTock 13:62e0f7f39ff5 283 }
TickTock 122:138a40892a4c 284 if(showButtons){
garygid 54:6ce808d0995e 285 showButton(0,0," <up>","",4,4);
garygid 54:6ce808d0995e 286 showButton(2,0,"<down>","",4,4);
TickTock 25:ddf0ec209f03 287 }
TickTock 13:62e0f7f39ff5 288 }
TickTock 13:62e0f7f39ff5 289
TickTock 42:4533b13b297d 290 void printChanged (bool force, bool showButtons){
TickTock 13:62e0f7f39ff5 291 CANMessage msg;
TickTock 13:62e0f7f39ff5 292 unsigned char i,j;
TickTock 13:62e0f7f39ff5 293 tt.locate(0,6);
TickTock 13:62e0f7f39ff5 294 tt.foreground(Red);
TickTock 13:62e0f7f39ff5 295 tt.background(Yellow);
TickTock 13:62e0f7f39ff5 296 if(force) tt.cls(); // Just clear screen if forced - always update display
TickTock 13:62e0f7f39ff5 297 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 13:62e0f7f39ff5 298 i=0;
TickTock 13:62e0f7f39ff5 299 j=indexOffset;
TickTock 13:62e0f7f39ff5 300 do{
TickTock 13:62e0f7f39ff5 301 j=j<99?j+1:j;
TickTock 13:62e0f7f39ff5 302 if(msgChanged[j]>0){
TickTock 13:62e0f7f39ff5 303 msg = lastMsg[j];
TickTock 13:62e0f7f39ff5 304 printf("%03x : %02x %02x %02x %02x %02x %02x %02x %02x \n",msg.id,msg.data[0],msg.data[1],msg.data[2],msg.data[3],msg.data[4],msg.data[5],msg.data[6],msg.data[7]);
TickTock 13:62e0f7f39ff5 305 i++;
TickTock 13:62e0f7f39ff5 306 }// if changed
TickTock 13:62e0f7f39ff5 307 }while(i<19&&j<99);
TickTock 122:138a40892a4c 308 if(showButtons){
garygid 54:6ce808d0995e 309 showButton(0,0," <up>","",4,4);
garygid 54:6ce808d0995e 310 showButton(2,0," <down>","",4,4);
garygid 54:6ce808d0995e 311 showButton(1,0," Reset","Baseline",4,4);
TickTock 40:0e6e71a7323f 312 }
TickTock 13:62e0f7f39ff5 313 }
TickTock 13:62e0f7f39ff5 314
TickTock 42:4533b13b297d 315 void printLog (bool force, bool showButtons){
TickTock 118:02010b18efdc 316 static unsigned char lastldl = 0;
TickTock 118:02010b18efdc 317 unsigned char ldl=displayLoc;
TickTock 118:02010b18efdc 318 if(force||ldl!=lastldl){ //only update if changed
TickTock 13:62e0f7f39ff5 319 tt.foreground(Amber);
TickTock 13:62e0f7f39ff5 320 tt.background(Black);
TickTock 13:62e0f7f39ff5 321 tt.cls();
TickTock 13:62e0f7f39ff5 322 tt.locate(0,6);
TickTock 13:62e0f7f39ff5 323 tt.set_font((unsigned char*) Arial12x12);
TickTock 13:62e0f7f39ff5 324 for(int i=0; i<19; i++){
TickTock 118:02010b18efdc 325 printf("%s",displayLog[ldl]);
TickTock 118:02010b18efdc 326 ldl=ldl>17?0:ldl+1;
TickTock 13:62e0f7f39ff5 327 }
TickTock 13:62e0f7f39ff5 328 }
TickTock 118:02010b18efdc 329 lastldl=ldl;
TickTock 13:62e0f7f39ff5 330 }
TickTock 13:62e0f7f39ff5 331
TickTock 168:9227024c4e3a 332 void tripDisplay (bool force, bool showButtons, bool inclCC){
TickTock 168:9227024c4e3a 333 static int lkWh=0;
TickTock 168:9227024c4e3a 334 float mpkWh_f, kWh_f;
TickTock 118:02010b18efdc 335 tt.background(White);
TickTock 118:02010b18efdc 336 if(force){
TickTock 118:02010b18efdc 337 tt.cls();
TickTock 118:02010b18efdc 338 }
TickTock 168:9227024c4e3a 339 if(force||(lkWh!=(int)(kWh_trip[0]*100))){ //only update if changed
TickTock 118:02010b18efdc 340 tt.foreground(Navy);
TickTock 118:02010b18efdc 341 tt.set_font((unsigned char*) Arial28x28);
TickTock 118:02010b18efdc 342 tt.locate(6,210);
TickTock 169:84d790ac18a2 343 printf("kWh : %s : Eff\n",distanceUnit());
TickTock 169:84d790ac18a2 344 tt.set_font((unsigned char*) Arial12x12);
TickTock 169:84d790ac18a2 345 tt.locate(260,220);
TickTock 168:9227024c4e3a 346 if(inclCC){
TickTock 169:84d790ac18a2 347 printf(" (+CC)\n");
TickTock 168:9227024c4e3a 348 } else {
TickTock 169:84d790ac18a2 349 printf("(noCC)\n");
TickTock 168:9227024c4e3a 350 }
TickTock 169:84d790ac18a2 351 tt.set_font((unsigned char*) Arial28x28);
TickTock 118:02010b18efdc 352 for(int i=0; i<3; i++){
TickTock 168:9227024c4e3a 353 kWh_f = kWh_trip[i];
TickTock 168:9227024c4e3a 354 if(inclCC){
TickTock 168:9227024c4e3a 355 kWh_f += CCkWh_trip[i];
TickTock 168:9227024c4e3a 356 }
TickTock 168:9227024c4e3a 357 if(kWh_f>0.01){
TickTock 168:9227024c4e3a 358 mpkWh_f = convertDistance(miles_trip[i])/kWh_f;
TickTock 152:a4d66901785d 359 } else {
TickTock 168:9227024c4e3a 360 mpkWh_f = 0;
TickTock 152:a4d66901785d 361 }
TickTock 118:02010b18efdc 362 tt.locate(6,20+i*60);
TickTock 168:9227024c4e3a 363 printf("%3.2f : %3.1f : %2.1f \n",kWh_f,convertDistance(miles_trip[i]),mpkWh_f);
TickTock 118:02010b18efdc 364 }
TickTock 151:3047ebb3c9a8 365 tt.foreground(Navy);
TickTock 151:3047ebb3c9a8 366 tt.set_font((unsigned char*) Arial12x12);
TickTock 151:3047ebb3c9a8 367 tt.locate(274,18);
TickTock 151:3047ebb3c9a8 368 printf("per\n");
TickTock 151:3047ebb3c9a8 369 tt.locate(274,33);
TickTock 151:3047ebb3c9a8 370 printf("trip\n");
TickTock 151:3047ebb3c9a8 371 tt.locate(274,78);
TickTock 151:3047ebb3c9a8 372 printf("per\n");
TickTock 151:3047ebb3c9a8 373 tt.locate(265,93);
TickTock 151:3047ebb3c9a8 374 printf("charge\n");
TickTock 151:3047ebb3c9a8 375 tt.locate(265,145);
TickTock 151:3047ebb3c9a8 376 printf("custom\n");
TickTock 168:9227024c4e3a 377 lkWh=(int)(kWh_trip[0]*100);
TickTock 122:138a40892a4c 378 }
TickTock 122:138a40892a4c 379 if(showButtons){
TickTock 151:3047ebb3c9a8 380 showButton(3,2," Reset"," ",4,4);
TickTock 118:02010b18efdc 381 }
TickTock 118:02010b18efdc 382 }
TickTock 118:02010b18efdc 383
TickTock 118:02010b18efdc 384 void healthDisplay (bool force, bool showButtons){
TickTock 131:0d926c080a65 385 unsigned short gids, SOC_x10, SOH_x2;
TickTock 118:02010b18efdc 386 static unsigned short lgids=0, lSOC=0, lSOH=0;
TickTock 124:0d622967b764 387 static float lmaxTemp=0, lresr=0, lunlV=0;
TickTock 118:02010b18efdc 388 static unsigned long lAh=0;
TickTock 13:62e0f7f39ff5 389 CANMessage msg;
TickTock 13:62e0f7f39ff5 390
TickTock 13:62e0f7f39ff5 391 msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
TickTock 13:62e0f7f39ff5 392 gids = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 13:62e0f7f39ff5 393 msg = lastMsg[indexLastMsg[0x55b]]; //Get SOC
TickTock 122:138a40892a4c 394 SOC_x10 = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 131:0d926c080a65 395 msg = lastMsg[indexLastMsg[0x5b3]]; //Get SOH
TickTock 131:0d926c080a65 396 SOH_x2 = msg.data[1];
TickTock 13:62e0f7f39ff5 397
TickTock 118:02010b18efdc 398 tt.background(Blue);
TickTock 38:155ec32c5e91 399 tt.foreground(Yellow);
TickTock 38:155ec32c5e91 400 tt.set_font((unsigned char*) Arial28x28);
TickTock 13:62e0f7f39ff5 401 if(force) tt.cls();
TickTock 121:553faf139a20 402
TickTock 121:553faf139a20 403 /*if(force||tock){ // for esr debug
TickTock 121:553faf139a20 404 tt.locate(10,10);
TickTock 121:553faf139a20 405 printf("%d %d amps\n",Imax,Imin);
TickTock 121:553faf139a20 406 tt.locate(10,40);
TickTock 121:553faf139a20 407 printf(" %4.1f %4.1f\n",incRmax/2,incRmin/2);
TickTock 121:553faf139a20 408 tt.locate(10,70);
TickTock 121:553faf139a20 409 printf(" %4.1f %4.1f\n",redRmax/2,redRmin/2);
TickTock 121:553faf139a20 410 tt.locate(10,100);
TickTock 121:553faf139a20 411 printf(" %4.1f %4.1f\n",curRmax/2,curRmin/2);
TickTock 121:553faf139a20 412 //tt.locate(10,130);
TickTock 121:553faf139a20 413 curRmin=1000;
TickTock 121:553faf139a20 414 curRmax=0;
TickTock 121:553faf139a20 415 incRmin=1000;
TickTock 121:553faf139a20 416 incRmax=0;
TickTock 121:553faf139a20 417 redRmin=1000;
TickTock 121:553faf139a20 418 redRmax=0;
TickTock 121:553faf139a20 419 Imax=-1000;
TickTock 121:553faf139a20 420 Imin=1000;
TickTock 121:553faf139a20 421 }*/
TickTock 118:02010b18efdc 422 if(force||gids!=lgids){
TickTock 118:02010b18efdc 423 tt.locate(10,10);
TickTock 170:7ee98e3611bc 424 if(gids>startGids){ // If not start of trip print kWh/gid too
TickTock 170:7ee98e3611bc 425 printf("%4d gids %4.3f kW/gid\n",gids,(float)(kWh_trip[0]+CCkWh_trip[0])/(gids-startGids));
TickTock 170:7ee98e3611bc 426 }else{
TickTock 170:7ee98e3611bc 427 printf("%4d gids \n",gids);
TickTock 170:7ee98e3611bc 428 }
TickTock 119:0e2b641e98a2 429 lgids=gids;
TickTock 118:02010b18efdc 430 }
TickTock 122:138a40892a4c 431 if(force||SOC_x10!=lSOC){
TickTock 119:0e2b641e98a2 432 tt.locate(10,40);
TickTock 122:138a40892a4c 433 printf(" %4.1f%s \n",(float)SOC_x10/10,"% SOC");
TickTock 122:138a40892a4c 434 lSOC=SOC_x10;
TickTock 118:02010b18efdc 435 }
TickTock 143:88b5155622a5 436 if(force||SOH2_x100!=lSOH){
TickTock 118:02010b18efdc 437 tt.locate(10,70);
TickTock 170:7ee98e3611bc 438 printf(" %d%s,%3.1f%s \n",SOH_x2/2,"% SOH",(float)SOH2_x100/100," Hx");
TickTock 143:88b5155622a5 439 lSOH=SOH2_x100;
TickTock 118:02010b18efdc 440 }
TickTock 118:02010b18efdc 441 if(force||Ah_x10000!=lAh){
TickTock 118:02010b18efdc 442 tt.locate(10,100);
TickTock 120:041edeec08f5 443 printf(" %4.2f Ah cap \n",(float)Ah_x10000/10000);
TickTock 118:02010b18efdc 444 lAh=Ah_x10000;
TickTock 118:02010b18efdc 445 }
TickTock 124:0d622967b764 446 if(force||maxTemp!=lmaxTemp){
TickTock 124:0d622967b764 447 tt.locate(10,130);
TickTock 148:6e3b9135fad2 448 printf(" %4.1f %s (max) \n",convertC(maxTemp),temperatureUnit());
TickTock 124:0d622967b764 449 lmaxTemp=maxTemp;
TickTock 124:0d622967b764 450 }
TickTock 123:a8c0042df617 451 if(force||unloadedV_x2!=lunlV){
TickTock 124:0d622967b764 452 tt.locate(10,160);
TickTock 120:041edeec08f5 453 printf(" %4.1f V \n",unloadedV_x2/2);
TickTock 119:0e2b641e98a2 454 lunlV=unloadedV_x2;
TickTock 118:02010b18efdc 455 }
TickTock 118:02010b18efdc 456 if(force||Resr!=lresr){
TickTock 124:0d622967b764 457 tt.locate(10,190);
TickTock 120:041edeec08f5 458 printf(" %3.0f mOhms \n",Resr*1000);
TickTock 118:02010b18efdc 459 lresr=Resr;
TickTock 35:5acbd8a64a89 460 }
TickTock 13:62e0f7f39ff5 461 }
TickTock 13:62e0f7f39ff5 462
TickTock 42:4533b13b297d 463 void braking (bool force, bool showButtons, bool prdata=false){
TickTock 28:f24ac05645d9 464 unsigned long targetBraking, regenBraking;
TickTock 170:7ee98e3611bc 465 //static unsigned long maxTarget = 1000, maxRegen = 1000, tardivreg_x1000 = 1000;
TickTock 170:7ee98e3611bc 466 static unsigned long maxRegen = 1000, tardivreg_x1000 = 1000;
TickTock 28:f24ac05645d9 467 unsigned long temp;
TickTock 28:f24ac05645d9 468 static unsigned char lastPressure[4] = {200,200,200,200};
TickTock 28:f24ac05645d9 469 unsigned char i,r,t;
TickTock 37:fea2c1d52c5f 470 static unsigned char lr=0, lt=0;
TickTock 37:fea2c1d52c5f 471 signed short steering;
TickTock 37:fea2c1d52c5f 472 unsigned short s;
TickTock 37:fea2c1d52c5f 473 static unsigned short ls;
TickTock 37:fea2c1d52c5f 474 unsigned char throttle;
TickTock 37:fea2c1d52c5f 475 static unsigned char lthrottle;
TickTock 48:d1ce92104a1f 476 short steerOutBounds = 0 ;
TickTock 28:f24ac05645d9 477 CANMessage msg;
TickTock 28:f24ac05645d9 478
TickTock 48:d1ce92104a1f 479 //---------------
TickTock 37:fea2c1d52c5f 480 msg = lastMsg[indexLastMsg[0x180]]; //Get Throttle position
TickTock 37:fea2c1d52c5f 481 throttle = msg.data[5];
TickTock 48:d1ce92104a1f 482
TickTock 48:d1ce92104a1f 483 // ---- steering ----
TickTock 37:fea2c1d52c5f 484 msg = lastMsg[indexLastMsg[0x002]]; //Get Steering angle
TickTock 37:fea2c1d52c5f 485 steering = (msg.data[1]<<8)+msg.data[0];
TickTock 48:d1ce92104a1f 486
TickTock 48:d1ce92104a1f 487 if(skin==ttSkin){
TickTock 66:b7476ce7a59e 488 s= (unsigned short) ((steering/10)+155)%310; // this modulo wraps display
TickTock 48:d1ce92104a1f 489 }else{// if(skin==ggSkin){
TickTock 48:d1ce92104a1f 490 // do not go off screen left or right. gg - steering
TickTock 48:d1ce92104a1f 491 short ss = (short) ((steering/15)+160); // less gain 10 -> 15
TickTock 48:d1ce92104a1f 492 if(ss<0) { ss=0; steerOutBounds = 1; }
TickTock 48:d1ce92104a1f 493 if(ss>310) { ss=310; steerOutBounds = 1; }
TickTock 48:d1ce92104a1f 494 s = (unsigned short) ss;
TickTock 48:d1ce92104a1f 495 }
TickTock 48:d1ce92104a1f 496
TickTock 48:d1ce92104a1f 497 //--------------
TickTock 28:f24ac05645d9 498 msg = lastMsg[indexLastMsg[0x1ca]]; //Get brake pressure
TickTock 28:f24ac05645d9 499 tt.background(Navy);
TickTock 28:f24ac05645d9 500 if (force) {
TickTock 28:f24ac05645d9 501 tt.cls();
TickTock 28:f24ac05645d9 502 tt.rect(0,111,170,239,White);
TickTock 28:f24ac05645d9 503 tt.line(0,207,170,207,White);
TickTock 28:f24ac05645d9 504 tt.line(0,175,170,175,White);
TickTock 28:f24ac05645d9 505 tt.line(0,143,170,143,White);
TickTock 28:f24ac05645d9 506 lastPressure[0] = 200;
TickTock 28:f24ac05645d9 507 lastPressure[1] = 200;
TickTock 28:f24ac05645d9 508 lastPressure[2] = 200;
TickTock 28:f24ac05645d9 509 lastPressure[3] = 200;
TickTock 28:f24ac05645d9 510 }
TickTock 48:d1ce92104a1f 511
TickTock 48:d1ce92104a1f 512 // display the steering position small square
TickTock 37:fea2c1d52c5f 513 if (s!=ls){
TickTock 48:d1ce92104a1f 514 // steering position has moved
TickTock 48:d1ce92104a1f 515 //tt.fillrect(ls,5,ls+9,14, Navy); // blank old position
TickTock 48:d1ce92104a1f 516
TickTock 48:d1ce92104a1f 517 //---- gg - steering red
TickTock 48:d1ce92104a1f 518 // box is blanked by top of Braking bar, so move up 5
TickTock 48:d1ce92104a1f 519 tt.fillrect(ls,0,ls+9,9, Navy); // blank old position
TickTock 48:d1ce92104a1f 520 if( steerOutBounds != 0 ) // draw out-of-bounds as a red box
TickTock 48:d1ce92104a1f 521 tt.fillrect(s,0,s+9,9, Red); // draw out-of-bounds position
TickTock 48:d1ce92104a1f 522 else
TickTock 48:d1ce92104a1f 523 tt.fillrect(s,0,s+9,9, White); // draw new in-bounds position
TickTock 48:d1ce92104a1f 524
TickTock 48:d1ce92104a1f 525 //----
TickTock 37:fea2c1d52c5f 526 //tt.foreground(Yellow);
TickTock 37:fea2c1d52c5f 527 //tt.set_font((unsigned char*) Arial28x28);
TickTock 37:fea2c1d52c5f 528 //tt.locate(10,40);
TickTock 37:fea2c1d52c5f 529 //printf("%d %d \n",s,ls);
TickTock 37:fea2c1d52c5f 530 ls=s;
TickTock 37:fea2c1d52c5f 531 }
TickTock 48:d1ce92104a1f 532
TickTock 37:fea2c1d52c5f 533 if (throttle!=lthrottle){
TickTock 37:fea2c1d52c5f 534 if (throttle>239) throttle=239;
TickTock 37:fea2c1d52c5f 535 if(throttle<lthrottle){
TickTock 37:fea2c1d52c5f 536 tt.fillrect(280,239-lthrottle,310,239-throttle,Navy);
TickTock 37:fea2c1d52c5f 537 }else{
TickTock 37:fea2c1d52c5f 538 tt.fillrect(280,239-throttle,310,239,Yellow);
TickTock 37:fea2c1d52c5f 539 }
TickTock 37:fea2c1d52c5f 540 lthrottle=throttle;
TickTock 37:fea2c1d52c5f 541 }
TickTock 37:fea2c1d52c5f 542
TickTock 28:f24ac05645d9 543 // plot bar graph for each wheel pressure
TickTock 28:f24ac05645d9 544 for (i=0; i<4; i++){
TickTock 28:f24ac05645d9 545 if (msg.data[i]<239) {
TickTock 28:f24ac05645d9 546 if (msg.data[i]>lastPressure[i]){
TickTock 28:f24ac05645d9 547 tt.fillrect(10+40*i,239-msg.data[i],40+40*i,239,Red);
TickTock 28:f24ac05645d9 548 } else if (msg.data[i]<lastPressure[i]) {
TickTock 28:f24ac05645d9 549 tt.fillrect(10+40*i,238-lastPressure[i],40+40*i,238-msg.data[i],Navy);
TickTock 28:f24ac05645d9 550 }
TickTock 28:f24ac05645d9 551 lastPressure[i]=msg.data[i];
TickTock 28:f24ac05645d9 552 }
TickTock 28:f24ac05645d9 553 }
TickTock 28:f24ac05645d9 554
TickTock 156:4e5d30535cf9 555 msg = lastMsg[indexLastMsg[0x1cb]];
TickTock 156:4e5d30535cf9 556 targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); //Get target total braking force
TickTock 156:4e5d30535cf9 557 //regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); //Get target regen portion
TickTock 156:4e5d30535cf9 558 msg = lastMsg[indexLastMsg[0x1d5]]; //Get regen portion - seems to be actual regen versus target regen
TickTock 73:62ee8eae3a84 559 regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
TickTock 73:62ee8eae3a84 560
TickTock 73:62ee8eae3a84 561 if (targetBraking<2045){
TickTock 73:62ee8eae3a84 562 if ((targetBraking>50)&&(regenBraking>50)){
TickTock 73:62ee8eae3a84 563 temp = targetBraking;
TickTock 73:62ee8eae3a84 564 temp *= 1000;
TickTock 73:62ee8eae3a84 565 temp /= regenBraking;
TickTock 73:62ee8eae3a84 566 if (temp<tardivreg_x1000) tardivreg_x1000=temp;
TickTock 73:62ee8eae3a84 567 }
TickTock 73:62ee8eae3a84 568 if (targetBraking>maxTarget) maxTarget=targetBraking;
TickTock 73:62ee8eae3a84 569 if (regenBraking>maxRegen) maxRegen=regenBraking;
TickTock 73:62ee8eae3a84 570 temp = targetBraking;
TickTock 73:62ee8eae3a84 571 temp *=200;
TickTock 73:62ee8eae3a84 572 temp /= maxTarget;
TickTock 73:62ee8eae3a84 573 t = (char) temp;
TickTock 73:62ee8eae3a84 574 if (t>200) t=200;
TickTock 73:62ee8eae3a84 575 temp = regenBraking;
TickTock 73:62ee8eae3a84 576 temp *= tardivreg_x1000;
TickTock 73:62ee8eae3a84 577 temp /= maxTarget;
TickTock 73:62ee8eae3a84 578 temp /= 5; // 1000/200=5
TickTock 73:62ee8eae3a84 579 r = (char) temp;
TickTock 73:62ee8eae3a84 580 if (r>200) r=200;
TickTock 73:62ee8eae3a84 581 if(lr!=r&&prdata){
TickTock 73:62ee8eae3a84 582 tt.foreground(Yellow);
TickTock 73:62ee8eae3a84 583 tt.set_font((unsigned char*) Arial28x28);
TickTock 73:62ee8eae3a84 584 tt.locate(100,40);
TickTock 73:62ee8eae3a84 585 printf("%d %d \n",regenBraking,maxRegen);
TickTock 73:62ee8eae3a84 586 tt.locate(100,70);
TickTock 73:62ee8eae3a84 587 printf("%3.1f (%3.1f%s) \n",(float)tardivreg_x1000/10,(float)regenBraking*tardivreg_x1000/targetBraking/10,"%");
TickTock 73:62ee8eae3a84 588 }
TickTock 73:62ee8eae3a84 589 if(lt!=t&&prdata){
TickTock 73:62ee8eae3a84 590 tt.foreground(Yellow);
TickTock 73:62ee8eae3a84 591 tt.set_font((unsigned char*) Arial28x28);
TickTock 73:62ee8eae3a84 592 tt.locate(100,10);
TickTock 73:62ee8eae3a84 593 printf("%d %d \n",targetBraking,maxTarget);
TickTock 73:62ee8eae3a84 594 }
TickTock 73:62ee8eae3a84 595 if (r>t) t=r; //Should never happen
TickTock 73:62ee8eae3a84 596 if((lr!=r||lt!=t)&&!prdata){
TickTock 73:62ee8eae3a84 597 tt.fillrect(190,10,260,239-t,Navy);
TickTock 73:62ee8eae3a84 598 tt.fillrect(190,239-t,260,239-r,Red);
TickTock 73:62ee8eae3a84 599 tt.fillrect(190,239-r,260,239,Green);
TickTock 73:62ee8eae3a84 600 }
TickTock 73:62ee8eae3a84 601 lt=t;
TickTock 73:62ee8eae3a84 602 lr=r;
TickTock 28:f24ac05645d9 603 }
TickTock 28:f24ac05645d9 604 }
TickTock 28:f24ac05645d9 605
TickTock 42:4533b13b297d 606 void cpData(bool force, bool showButtons){
TickTock 36:dbd39c315258 607 short unsigned max, min, jv, i, bd;
TickTock 36:dbd39c315258 608 unsigned avg;
TickTock 97:a25940fd7b5b 609 static char step=0; // counter to allow incremental update
TickTock 36:dbd39c315258 610 if(force){
TickTock 36:dbd39c315258 611 tt.foreground(White);
TickTock 36:dbd39c315258 612 tt.background(Navy);
TickTock 36:dbd39c315258 613 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 36:dbd39c315258 614 max=0;
TickTock 36:dbd39c315258 615 min=9999;
TickTock 36:dbd39c315258 616 avg=0;
TickTock 36:dbd39c315258 617 for(i=0; i<96; i++){
TickTock 124:0d622967b764 618 bd=(battData[BatDataBaseG2*7+i*2+3]<<8)+battData[BatDataBaseG2*7+i*2+4];
TickTock 36:dbd39c315258 619 avg+=bd;
TickTock 36:dbd39c315258 620 if(bd>max) max=bd;
TickTock 36:dbd39c315258 621 if(bd<min) min=bd;
TickTock 36:dbd39c315258 622 }
TickTock 36:dbd39c315258 623 avg /= 96;
TickTock 36:dbd39c315258 624 if(min<3713) {
TickTock 36:dbd39c315258 625 jv=avg-(max-avg)*1.5;
TickTock 36:dbd39c315258 626 } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
TickTock 36:dbd39c315258 627 jv=0;
TickTock 36:dbd39c315258 628 }
TickTock 99:c05abf8e1cdc 629
TickTock 107:e9be732c1ad4 630 char* sTemperatureUnit = temperatureUnit();
TickTock 97:a25940fd7b5b 631 switch(step){
TickTock 97:a25940fd7b5b 632 case 0:
TickTock 97:a25940fd7b5b 633 tt.cls();
TickTock 97:a25940fd7b5b 634 showCP=true;
TickTock 97:a25940fd7b5b 635 break;
TickTock 97:a25940fd7b5b 636 case 1:
TickTock 97:a25940fd7b5b 637 tt.locate(0,6);
TickTock 99:c05abf8e1cdc 638 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",
TickTock 148:6e3b9135fad2 639 max,min,avg,jv, convertC(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+8]),sTemperatureUnit,
TickTock 148:6e3b9135fad2 640 convertC(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+14]),sTemperatureUnit);
TickTock 97:a25940fd7b5b 641 tt.rect(8+0*41,16,40+0*41,28,Green);
TickTock 97:a25940fd7b5b 642 tt.rect(8+1*41,16,40+1*41,28,Yellow);
TickTock 97:a25940fd7b5b 643 //tt.rect(8+2*41,16,40+2*41,28,White);
TickTock 97:a25940fd7b5b 644 tt.rect(8+3*41,16,40+3*41,28,Red);
TickTock 97:a25940fd7b5b 645 break;
TickTock 97:a25940fd7b5b 646 default:
TickTock 97:a25940fd7b5b 647 tt.locate(0,36+(step-2)*48);
TickTock 97:a25940fd7b5b 648 for(i=(step-2)*4; i<(step-1)*4; i++){
TickTock 97:a25940fd7b5b 649 printf("%02d-%02d : %04d %04d %04d %04d %04d %04d\n",
TickTock 97:a25940fd7b5b 650 i*6+1,i*6+6,
TickTock 124:0d622967b764 651 (battData[BatDataBaseG2*7+i*12+3]<<8)+battData[BatDataBaseG2*7+i*12+4],(battData[BatDataBaseG2*7+i*12+5]<<8)+battData[BatDataBaseG2*7+i*12+6],
TickTock 124:0d622967b764 652 (battData[BatDataBaseG2*7+i*12+7]<<8)+battData[BatDataBaseG2*7+i*12+8],(battData[BatDataBaseG2*7+i*12+9]<<8)+battData[BatDataBaseG2*7+i*12+10],
TickTock 124:0d622967b764 653 (battData[BatDataBaseG2*7+i*12+11]<<8)+battData[BatDataBaseG2*7+i*12+12],(battData[BatDataBaseG2*7+i*12+13]<<8)+battData[BatDataBaseG2*7+i*12+14]);
TickTock 97:a25940fd7b5b 654 }
TickTock 97:a25940fd7b5b 655 for(i=(step-2)*24; i<(step-1)*24; i++){
TickTock 124:0d622967b764 656 bd=(battData[BatDataBaseG2*7+i*2+3]<<8)+battData[BatDataBaseG2*7+i*2+4];
TickTock 97:a25940fd7b5b 657 if(bd>0){
TickTock 97:a25940fd7b5b 658 if(bd==max) tt.rect(58+(i%6)*41,34+(int)(i/6)*12,90+(i%6)*41,46+(int)(i/6)*12,Green);
TickTock 97:a25940fd7b5b 659 //if(bd==avg) tt.rect(58+(i%6)*41,34+(int)(i/6)*12,90+(i%6)*41,46+(int)(i/6)*12,White);
TickTock 97:a25940fd7b5b 660 if(bd==min) tt.rect(58+(i%6)*41,34+(int)(i/6)*12,90+(i%6)*41,46+(int)(i/6)*12,Yellow);
TickTock 97:a25940fd7b5b 661 if(bd<jv) tt.rect(58+(i%6)*41,34+(int)(i/6)*12,90+(i%6)*41,46+(int)(i/6)*12,Red);
TickTock 97:a25940fd7b5b 662 }
TickTock 97:a25940fd7b5b 663 }
TickTock 36:dbd39c315258 664 }
TickTock 97:a25940fd7b5b 665 step=step<5?step+1:0;
TickTock 97:a25940fd7b5b 666 if(step==0){
TickTock 97:a25940fd7b5b 667 showCP=false;
TickTock 36:dbd39c315258 668 }
TickTock 36:dbd39c315258 669 }
TickTock 122:138a40892a4c 670 if(showButtons){
garygid 54:6ce808d0995e 671 showButton(1,0,"Request","CP Data",4,4);
TickTock 44:6262a9fd1e56 672 }
TickTock 44:6262a9fd1e56 673 }
TickTock 44:6262a9fd1e56 674
TickTock 44:6262a9fd1e56 675 //----------------
garygid 67:2022fce701d0 676 // gg - index
garygid 67:2022fce701d0 677 void showIndex(bool force, bool showButtons){
garygid 67:2022fce701d0 678
garygid 67:2022fce701d0 679 if(force){
garygid 67:2022fce701d0 680 tt.foreground(White);
garygid 67:2022fce701d0 681 tt.background(Navy);
garygid 67:2022fce701d0 682 //tt.set_font((unsigned char*) Arial12x12_prop); // select the font
garygid 67:2022fce701d0 683
garygid 67:2022fce701d0 684 tt.cls();
garygid 67:2022fce701d0 685
garygid 67:2022fce701d0 686 // add the buttons to GoTo to other screens
garygid 67:2022fce701d0 687
TickTock 151:3047ebb3c9a8 688 // top row
garygid 67:2022fce701d0 689 showButton(0,0," GoTo"," Main",4,4);
garygid 67:2022fce701d0 690 showButton(1,0," GoTo"," Brake",4,4);
garygid 67:2022fce701d0 691 showButton(2,0," GoTo"," EFF",4,4);
TickTock 122:138a40892a4c 692 showButton(3,0," GoTo","Health",4,4);
garygid 67:2022fce701d0 693 // middle row
garygid 67:2022fce701d0 694 showButton(0,1," GoTo","CP Data",4,4);
garygid 67:2022fce701d0 695 showButton(1,1," GoTo","CP Hist",4,4);
garygid 67:2022fce701d0 696 showButton(2,1," GoTo","CP Bars",4,4);
leafman 98:9f8bab96edff 697 showButton(3,1," GoTo"," Config",4,4);
leafman 98:9f8bab96edff 698 // bottom (not Nav) row
TickTock 157:1a100a5ed06f 699 showButton(0,2," GoTo","Playback",4,4);
TickTock 131:0d926c080a65 700 //showButton(1,2," GoTo","Set Time",4,4);
leafman 98:9f8bab96edff 701 showButton(2,2," GoTo"," Log",4,4);
TickTock 108:29b5a760adc2 702 showButton(3,2," GoTo"," Trip",4,4);
garygid 67:2022fce701d0 703
garygid 67:2022fce701d0 704 showCP=false;
garygid 67:2022fce701d0 705 }
garygid 67:2022fce701d0 706
garygid 67:2022fce701d0 707 if(sMode==1&&showButtons){
garygid 67:2022fce701d0 708 tt.foreground(Yellow);
garygid 67:2022fce701d0 709 tt.background(DarkCyan);
garygid 67:2022fce701d0 710 tt.set_font((unsigned char*) Arial12x12);
garygid 67:2022fce701d0 711
garygid 67:2022fce701d0 712 // do nothing here?
garygid 67:2022fce701d0 713 }
garygid 67:2022fce701d0 714 }
garygid 67:2022fce701d0 715
garygid 67:2022fce701d0 716 //----------------
TickTock 48:d1ce92104a1f 717 // gg - cpbars
TickTock 48:d1ce92104a1f 718 void cpBarPlot(bool force, bool showButtons){
TickTock 48:d1ce92104a1f 719 short unsigned max, min, jv, i, bd;
TickTock 48:d1ce92104a1f 720 unsigned avg;
TickTock 48:d1ce92104a1f 721 short unsigned nBar[96] ; // bar height over min
TickTock 48:d1ce92104a1f 722
TickTock 48:d1ce92104a1f 723 if(force){
TickTock 48:d1ce92104a1f 724 tt.foreground(White);
TickTock 48:d1ce92104a1f 725 tt.background(Navy);
TickTock 48:d1ce92104a1f 726 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 48:d1ce92104a1f 727 max=0;
TickTock 48:d1ce92104a1f 728 min=9999;
TickTock 48:d1ce92104a1f 729 avg=0;
TickTock 48:d1ce92104a1f 730
TickTock 48:d1ce92104a1f 731 // calc each cell-pair voltage, find max and min
TickTock 48:d1ce92104a1f 732 for(i=0; i<96; i++){
TickTock 124:0d622967b764 733 bd=(battData[BatDataBaseG2*7+i*2+3]<<8)+battData[BatDataBaseG2*7+i*2+4];
TickTock 48:d1ce92104a1f 734 nBar[i] = bd; // init to bar height
TickTock 48:d1ce92104a1f 735 avg+=bd;
TickTock 48:d1ce92104a1f 736 if(bd>max) max=bd;
TickTock 48:d1ce92104a1f 737 if(bd<min) min=bd;
TickTock 48:d1ce92104a1f 738 }
TickTock 48:d1ce92104a1f 739 avg /= 96;
TickTock 48:d1ce92104a1f 740
TickTock 48:d1ce92104a1f 741 if(min<3713) {
TickTock 48:d1ce92104a1f 742 jv=avg-(max-avg)*1.5;
TickTock 48:d1ce92104a1f 743 } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
TickTock 48:d1ce92104a1f 744 jv=0;
TickTock 48:d1ce92104a1f 745 }
TickTock 48:d1ce92104a1f 746
TickTock 48:d1ce92104a1f 747 //------------------
TickTock 48:d1ce92104a1f 748 tt.cls();
TickTock 48:d1ce92104a1f 749
TickTock 48:d1ce92104a1f 750 // show as vertical bar plot
TickTock 48:d1ce92104a1f 751 int xWinMin = 26;
TickTock 48:d1ce92104a1f 752 int xWinMax = 316;
TickTock 48:d1ce92104a1f 753 int yWinMin = 50;
TickTock 48:d1ce92104a1f 754 int yWinMax = 150;
TickTock 48:d1ce92104a1f 755 // draw the Bar Graph Frame, 2 pixels wide
TickTock 48:d1ce92104a1f 756 tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red);
TickTock 48:d1ce92104a1f 757 tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green);
TickTock 48:d1ce92104a1f 758
TickTock 48:d1ce92104a1f 759 // bar heights
TickTock 48:d1ce92104a1f 760 int height = yWinMax - yWinMin ;
TickTock 48:d1ce92104a1f 761 int iBarValMax = max - min ; // zero to N
TickTock 48:d1ce92104a1f 762
TickTock 48:d1ce92104a1f 763 //----------------
TickTock 48:d1ce92104a1f 764 if( iBarValMax == 0 ) {
TickTock 48:d1ce92104a1f 765 // for testing
TickTock 48:d1ce92104a1f 766 min = 3501 ;
TickTock 48:d1ce92104a1f 767 //max = min + 95*2 ; // for tall values
TickTock 48:d1ce92104a1f 768 max = min + 95/4 ; // for small values
TickTock 48:d1ce92104a1f 769 avg = ( max + min ) / 2;
TickTock 48:d1ce92104a1f 770 iBarValMax = max - min ; // zero to N
TickTock 48:d1ce92104a1f 771 for(int i=0; i<96; i++) {
TickTock 48:d1ce92104a1f 772 //nBar[i] = i*2 + min ; // test tall values
TickTock 48:d1ce92104a1f 773 nBar[i] = i/4 + min ; // test small values
TickTock 48:d1ce92104a1f 774 }
TickTock 48:d1ce92104a1f 775 }
TickTock 48:d1ce92104a1f 776 //---------------
TickTock 48:d1ce92104a1f 777 float nBarScale = float(height) / iBarValMax ;
TickTock 48:d1ce92104a1f 778 if( nBarScale < 0.1 ) nBarScale = 0.1 ;
TickTock 48:d1ce92104a1f 779
TickTock 48:d1ce92104a1f 780 // do the Bar-height scaling
TickTock 48:d1ce92104a1f 781 for(int i=0; i<96; i++){
TickTock 48:d1ce92104a1f 782 nBar[i] -= min ; // now, 0 to N = iBinValMax
TickTock 48:d1ce92104a1f 783 nBar[i] *= nBarScale ; // scale, as needed
TickTock 48:d1ce92104a1f 784 }
TickTock 48:d1ce92104a1f 785
TickTock 161:71ac85d11f03 786 // label the Y axis
TickTock 138:a2f5af85ed0d 787 tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.\n", max , max - min );
TickTock 138:a2f5af85ed0d 788 tt.locate( 2, yWinMax+5); printf("%04d\n", min );
TickTock 161:71ac85d11f03 789
TickTock 124:0d622967b764 790 // BatDataBaseG4 * 7 = 280
TickTock 48:d1ce92104a1f 791 tt.locate( 0, yWinMax+40 );
TickTock 108:29b5a760adc2 792 char* sTemperatureUnit = temperatureUnit();
TickTock 138:a2f5af85ed0d 793 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",
TickTock 148:6e3b9135fad2 794 max,min,avg,jv, convertC(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+8]),sTemperatureUnit,
TickTock 148:6e3b9135fad2 795 convertC(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+14]),sTemperatureUnit);
TickTock 108:29b5a760adc2 796 //printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",
TickTock 124:0d622967b764 797 // max,min,avg,jv, battData[BatDataBaseG4*7+5],battData[BatDataBaseG4*7+8], battData[BatDataBaseG4*7+11],battData[BatDataBaseG4*7+14]);
TickTock 48:d1ce92104a1f 798
TickTock 48:d1ce92104a1f 799
TickTock 48:d1ce92104a1f 800 //---------------
TickTock 48:d1ce92104a1f 801 // show the bars
TickTock 48:d1ce92104a1f 802 int nBarWidth = 2 ;
TickTock 48:d1ce92104a1f 803 int nBarSpace = 1 ; // 1 for testing
TickTock 48:d1ce92104a1f 804
TickTock 48:d1ce92104a1f 805 int xPos = xWinMin + 2 ; // start one from the left
TickTock 48:d1ce92104a1f 806
TickTock 48:d1ce92104a1f 807 for( int i=0; i<96; i++) {
TickTock 48:d1ce92104a1f 808 height = nBar[i] ;
TickTock 48:d1ce92104a1f 809 if( height > 100 ) height = 100 ; // clip tops
TickTock 48:d1ce92104a1f 810
TickTock 48:d1ce92104a1f 811 // draw the bar, is always inside x-window
TickTock 121:553faf139a20 812 if (shunt[i]){
TickTock 121:553faf139a20 813 tt.fillrect( xPos,yWinMax-height, xPos+nBarWidth-1,yWinMax, Red);
TickTock 121:553faf139a20 814 } else {
TickTock 121:553faf139a20 815 tt.fillrect( xPos,yWinMax-height, xPos+nBarWidth-1,yWinMax, Green);
TickTock 121:553faf139a20 816 }
TickTock 48:d1ce92104a1f 817 // tic mark the y axis each 5
TickTock 48:d1ce92104a1f 818 if(i%5 == 4){
TickTock 48:d1ce92104a1f 819 tt.line( xPos,yWinMax+2, xPos,yWinMax+5, White); // a white tick mark
TickTock 48:d1ce92104a1f 820 tt.line( xPos+1,yWinMax+2, xPos+1,yWinMax+5, White); // a white tick mark, to widen
TickTock 48:d1ce92104a1f 821 //tt.rect( xPos,yWinMax+2, xPos+1,yWinMax+5, White); // a white 2-wide tick mark is SLOW
TickTock 48:d1ce92104a1f 822 }
TickTock 48:d1ce92104a1f 823 // label the y axis each 10
TickTock 48:d1ce92104a1f 824 if(i%10 == 9){
TickTock 48:d1ce92104a1f 825 tt.locate( xPos-6, yWinMax+8 );
TickTock 48:d1ce92104a1f 826 printf("%02d\n", i+1 );
TickTock 48:d1ce92104a1f 827 }
TickTock 48:d1ce92104a1f 828
TickTock 48:d1ce92104a1f 829 // step to the next bar position
TickTock 48:d1ce92104a1f 830 xPos += nBarWidth + nBarSpace ;
TickTock 48:d1ce92104a1f 831 }
TickTock 48:d1ce92104a1f 832
TickTock 48:d1ce92104a1f 833 showCP=false;
TickTock 48:d1ce92104a1f 834 }
TickTock 48:d1ce92104a1f 835
TickTock 48:d1ce92104a1f 836 // handle the button
TickTock 48:d1ce92104a1f 837 if(sMode==1&&showButtons){
garygid 54:6ce808d0995e 838 showButton(1,0,"Request","CP Data",4,4);
TickTock 48:d1ce92104a1f 839 }
TickTock 48:d1ce92104a1f 840 }
TickTock 48:d1ce92104a1f 841
TickTock 48:d1ce92104a1f 842 //----------------
TickTock 44:6262a9fd1e56 843 // gg - hist
TickTock 47:9cc7d876dd6d 844 void cpHistogram(bool force, bool showButtons){
TickTock 44:6262a9fd1e56 845 short unsigned max, min, jv, i, bd;
TickTock 44:6262a9fd1e56 846 unsigned avg;
TickTock 44:6262a9fd1e56 847 if(force){
TickTock 44:6262a9fd1e56 848 tt.foreground(White);
TickTock 44:6262a9fd1e56 849 tt.background(Navy);
TickTock 44:6262a9fd1e56 850 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 44:6262a9fd1e56 851 max=0;
TickTock 44:6262a9fd1e56 852 min=9999;
TickTock 44:6262a9fd1e56 853 avg=0;
TickTock 44:6262a9fd1e56 854 for(i=0; i<96; i++){
TickTock 124:0d622967b764 855 bd=(battData[BatDataBaseG2*7+i*2+3]<<8)+battData[BatDataBaseG2*7+i*2+4];
TickTock 44:6262a9fd1e56 856 avg+=bd;
TickTock 44:6262a9fd1e56 857 if(bd>max) max=bd;
TickTock 44:6262a9fd1e56 858 if(bd<min) min=bd;
TickTock 44:6262a9fd1e56 859 }
TickTock 44:6262a9fd1e56 860 avg /= 96;
TickTock 44:6262a9fd1e56 861 if(min<3713) {
TickTock 44:6262a9fd1e56 862 jv=avg-(max-avg)*1.5;
TickTock 44:6262a9fd1e56 863 } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
TickTock 44:6262a9fd1e56 864 jv=0;
TickTock 44:6262a9fd1e56 865 }
TickTock 44:6262a9fd1e56 866 //------------------
TickTock 44:6262a9fd1e56 867 tt.cls();
TickTock 44:6262a9fd1e56 868
TickTock 44:6262a9fd1e56 869 // show as histogram
TickTock 44:6262a9fd1e56 870 int xWinMin = 20;
TickTock 44:6262a9fd1e56 871 int xWinMax = 300;
TickTock 44:6262a9fd1e56 872 int yWinMin = 50;
TickTock 44:6262a9fd1e56 873 int yWinMax = 150;
TickTock 161:71ac85d11f03 874
TickTock 44:6262a9fd1e56 875 // binning
TickTock 44:6262a9fd1e56 876 short nBin[301] ; // bins to count Min values in nBin[0], etc.
TickTock 161:71ac85d11f03 877 int height;
TickTock 44:6262a9fd1e56 878 int iBinIndxMax = 300 ;
TickTock 44:6262a9fd1e56 879 int iBinValMax = max - min ; // zero to N
TickTock 44:6262a9fd1e56 880 if( iBinValMax > iBinIndxMax ) iBinValMax = iBinIndxMax ;
TickTock 44:6262a9fd1e56 881
TickTock 44:6262a9fd1e56 882 // clean the bins
TickTock 44:6262a9fd1e56 883 for(int i=0; i<=iBinIndxMax; i++) {
TickTock 44:6262a9fd1e56 884 nBin[i] = 0;
TickTock 44:6262a9fd1e56 885 }
TickTock 44:6262a9fd1e56 886
TickTock 44:6262a9fd1e56 887 // do the bin counting
TickTock 44:6262a9fd1e56 888 for(int i=0; i<96; i++){
TickTock 124:0d622967b764 889 bd=(battData[BatDataBaseG2*7+i*2+3]<<8)+battData[BatDataBaseG2*7+i*2+4] - min ;
TickTock 44:6262a9fd1e56 890 if( bd > iBinValMax ) bd = iBinValMax ;
TickTock 161:71ac85d11f03 891 nBin[bd]++ ;
TickTock 44:6262a9fd1e56 892 }
TickTock 162:c6545fc0164a 893
TickTock 162:c6545fc0164a 894 //----------------
TickTock 162:c6545fc0164a 895 if( iBinValMax == 0 ) { // dummy data if no real data
TickTock 162:c6545fc0164a 896 min = 10 ;
TickTock 162:c6545fc0164a 897 max = 50 ;
TickTock 162:c6545fc0164a 898 avg = ( max + min ) / 2;
TickTock 162:c6545fc0164a 899 iBinValMax = max - min ;
TickTock 162:c6545fc0164a 900 for(int i=0; i<=(iBinValMax/2); i++) {
TickTock 162:c6545fc0164a 901 nBin[i] = i ;
TickTock 162:c6545fc0164a 902 nBin[iBinValMax-i] = i ;
TickTock 162:c6545fc0164a 903 }
TickTock 162:c6545fc0164a 904 }
TickTock 161:71ac85d11f03 905
TickTock 161:71ac85d11f03 906 // label the Y axis
TickTock 161:71ac85d11f03 907 tt.locate( 0, yWinMin ); printf("25\n");
TickTock 161:71ac85d11f03 908 tt.locate( 0, yWinMax-6 ); printf("0\n");
TickTock 161:71ac85d11f03 909 tt.locate( xWinMin-12, yWinMax+6 ); printf("%04d\n", min);
TickTock 161:71ac85d11f03 910 tt.locate( xWinMax-18, yWinMax+6 ); printf("%04d\n", max);
TickTock 161:71ac85d11f03 911 // draw the Histogram Frame, 2 pixels wide
TickTock 161:71ac85d11f03 912 tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red);
TickTock 161:71ac85d11f03 913 tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green);
TickTock 48:d1ce92104a1f 914 tt.locate( 0, yWinMax+40 );
TickTock 108:29b5a760adc2 915 char* sTemperatureUnit = temperatureUnit();
TickTock 108:29b5a760adc2 916 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",
TickTock 148:6e3b9135fad2 917 max,min,avg,jv, convertC(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+8]),sTemperatureUnit,
TickTock 148:6e3b9135fad2 918 convertC(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertC(battData[BatDataBaseG4*7+14]),sTemperatureUnit);
TickTock 161:71ac85d11f03 919
TickTock 44:6262a9fd1e56 920 //---------------
TickTock 44:6262a9fd1e56 921 // show the bars
TickTock 161:71ac85d11f03 922 int nBarWidth = (xWinMax-xWinMin-2)/iBinValMax-1; //3
TickTock 161:71ac85d11f03 923 int nBarSpace = 1 ;
TickTock 44:6262a9fd1e56 924
TickTock 44:6262a9fd1e56 925 int xPos = (xWinMin + xWinMax) / 2 ;
TickTock 44:6262a9fd1e56 926 xPos -= (avg-min) * (nBarWidth + nBarSpace) ;
TickTock 161:71ac85d11f03 927
TickTock 44:6262a9fd1e56 928 for( int i=0; i<=iBinValMax; i++) {
TickTock 44:6262a9fd1e56 929 height = 4 * nBin[i] ;
TickTock 44:6262a9fd1e56 930 if( height > 100 ) height = 100 ; // clip tops
TickTock 44:6262a9fd1e56 931
TickTock 44:6262a9fd1e56 932 // if inside the window, draw the bar
TickTock 44:6262a9fd1e56 933 if( ( xPos + nBarWidth < xWinMax ) && ( xPos > xWinMin ) )
TickTock 44:6262a9fd1e56 934 tt.fillrect( xPos,yWinMax-height, xPos+nBarWidth-1,yWinMax, Green);
TickTock 44:6262a9fd1e56 935
TickTock 44:6262a9fd1e56 936 // step to the next bar position
TickTock 44:6262a9fd1e56 937 xPos += nBarWidth + nBarSpace ;
TickTock 44:6262a9fd1e56 938 }
TickTock 44:6262a9fd1e56 939
TickTock 44:6262a9fd1e56 940 showCP=false;
TickTock 44:6262a9fd1e56 941 }
TickTock 44:6262a9fd1e56 942
TickTock 44:6262a9fd1e56 943 // handle the button
TickTock 47:9cc7d876dd6d 944 if(sMode==1&&showButtons){
garygid 54:6ce808d0995e 945 showButton(1,0,"Request","CP Data",4,4);
TickTock 162:c6545fc0164a 946 }
TickTock 36:dbd39c315258 947 }
TickTock 36:dbd39c315258 948
TickTock 48:d1ce92104a1f 949 //---------------
leafman 98:9f8bab96edff 950 void config(bool force, bool showButtons){
TickTock 36:dbd39c315258 951 if (force) {
TickTock 36:dbd39c315258 952 tt.background(Black);
TickTock 36:dbd39c315258 953 tt.cls();
TickTock 36:dbd39c315258 954 }
garygid 65:821fc79cd7fe 955 //-------- top row --------
TickTock 161:71ac85d11f03 956 showButton(1,0," Reset","CANary",4,4);
TickTock 131:0d926c080a65 957 showButton(2,0," Save"," Config",4,4);
TickTock 158:059abeb44ba1 958
TickTock 48:d1ce92104a1f 959 //------- second row -----
TickTock 108:29b5a760adc2 960 if (logEn&&usbEn) {
garygid 54:6ce808d0995e 961 sprintf(sTemp1,"Disable");
TickTock 36:dbd39c315258 962 } else {
garygid 54:6ce808d0995e 963 sprintf(sTemp1,"Enable");
TickTock 36:dbd39c315258 964 }
garygid 54:6ce808d0995e 965 showButton(0,1,sTemp1,"Logging",4,4);
TickTock 48:d1ce92104a1f 966
TickTock 36:dbd39c315258 967 if (repeatPoll) {
garygid 54:6ce808d0995e 968 sprintf(sTemp1,"Disable");
TickTock 36:dbd39c315258 969 } else {
garygid 54:6ce808d0995e 970 sprintf(sTemp1,"Enable");
TickTock 36:dbd39c315258 971 }
garygid 54:6ce808d0995e 972 showButton(1,1,sTemp1,"Auto CP",4,4);
TickTock 48:d1ce92104a1f 973
TickTock 48:d1ce92104a1f 974 // add Enable/Disable Batt Log gg - yesBattLog
TickTock 48:d1ce92104a1f 975 if (yesBattLog) {
garygid 54:6ce808d0995e 976 sprintf(sTemp1,"Disable");
TickTock 48:d1ce92104a1f 977 } else {
garygid 54:6ce808d0995e 978 sprintf(sTemp1,"Enable");
TickTock 48:d1ce92104a1f 979 }
garygid 54:6ce808d0995e 980 showButton(2,1,sTemp1,"Batt Log",4,4);
TickTock 157:1a100a5ed06f 981
TickTock 158:059abeb44ba1 982 //------- third row -----
TickTock 157:1a100a5ed06f 983 if(brakeMon)
TickTock 157:1a100a5ed06f 984 showButton(0,2,"Disable","BrkMon",4,4);
TickTock 157:1a100a5ed06f 985 else
TickTock 157:1a100a5ed06f 986 showButton(0,2," Enable"," BrkMon",4,4);
TickTock 157:1a100a5ed06f 987
TickTock 157:1a100a5ed06f 988 if(regenMon)
TickTock 157:1a100a5ed06f 989 showButton(1,2,"Disable","RegMon",4,4);
TickTock 157:1a100a5ed06f 990 else
TickTock 157:1a100a5ed06f 991 showButton(1,2," Enable"," RegMon",4,4);
TickTock 159:577e9d015693 992
TickTock 159:577e9d015693 993 if(heaterMon)
TickTock 159:577e9d015693 994 showButton(2,2,"Disable","HeatMon",4,4);
TickTock 159:577e9d015693 995 else
TickTock 159:577e9d015693 996 showButton(2,2," Enable","HeatMon",4,4);
TickTock 159:577e9d015693 997
TickTock 157:1a100a5ed06f 998 }
TickTock 157:1a100a5ed06f 999
TickTock 157:1a100a5ed06f 1000 void config2(bool force, bool showButtons){
TickTock 157:1a100a5ed06f 1001 if (force) {
TickTock 157:1a100a5ed06f 1002 tt.background(Black);
TickTock 157:1a100a5ed06f 1003 tt.cls();
TickTock 157:1a100a5ed06f 1004 }
TickTock 157:1a100a5ed06f 1005 //-------- top row --------
TickTock 157:1a100a5ed06f 1006 showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4
TickTock 161:71ac85d11f03 1007 showButton(1,0," Reset","Max/Min",4,4);
TickTock 169:84d790ac18a2 1008 if (showHealth) {
TickTock 169:84d790ac18a2 1009 sprintf(sTemp1," Hide");
TickTock 169:84d790ac18a2 1010 } else {
TickTock 169:84d790ac18a2 1011 sprintf(sTemp1," Show");
TickTock 169:84d790ac18a2 1012 }
TickTock 169:84d790ac18a2 1013 showButton(2,0,sTemp1," Health",4,4);
TickTock 169:84d790ac18a2 1014
TickTock 157:1a100a5ed06f 1015 // a button to step to the next skin
TickTock 157:1a100a5ed06f 1016 unsigned int nextSkin = skin + 1 ;
TickTock 157:1a100a5ed06f 1017 if( nextSkin > maxSkin ) nextSkin = 0 ;
TickTock 157:1a100a5ed06f 1018
TickTock 157:1a100a5ed06f 1019 if( nextSkin == ttSkin ) sprintf(sTemp1,"Skin TT");
TickTock 157:1a100a5ed06f 1020 else if( nextSkin == ggSkin ) sprintf(sTemp1,"Skin GG");
TickTock 157:1a100a5ed06f 1021 else sprintf(sTemp1,"Skin %d",nextSkin);
TickTock 157:1a100a5ed06f 1022
TickTock 157:1a100a5ed06f 1023 showButton(3,0," Use",sTemp1,4,4);
TickTock 157:1a100a5ed06f 1024
TickTock 157:1a100a5ed06f 1025 //------- second row -----
TickTock 157:1a100a5ed06f 1026 // add Enable/Disable Debug - debugMode
garygid 87:46ac3f2519d6 1027 if (debugMode) {
TickTock 131:0d926c080a65 1028 sprintf(sTemp1," Disable");
garygid 87:46ac3f2519d6 1029 } else {
TickTock 131:0d926c080a65 1030 sprintf(sTemp1," Enable");
garygid 87:46ac3f2519d6 1031 }
garygid 87:46ac3f2519d6 1032 showButton(3,1,sTemp1," Debug",4,4);
TickTock 157:1a100a5ed06f 1033
TickTock 158:059abeb44ba1 1034 //------- third row -----
TickTock 158:059abeb44ba1 1035 if (autoSync) {
TickTock 158:059abeb44ba1 1036 sprintf(sTemp1," Disable");
TickTock 158:059abeb44ba1 1037 } else {
TickTock 158:059abeb44ba1 1038 sprintf(sTemp1," Enable");
TickTock 158:059abeb44ba1 1039 }
TickTock 158:059abeb44ba1 1040 showButton(0,2,sTemp1," tSync",4,4);
TickTock 131:0d926c080a65 1041 showButton(1,2," Set"," Time",4,4);
TickTock 169:84d790ac18a2 1042 showButton(2,2," Update"," Config",4,4);
TickTock 169:84d790ac18a2 1043 showButton(3,2," Update","Firmware",4,4);
TickTock 36:dbd39c315258 1044 }
TickTock 36:dbd39c315258 1045
TickTock 42:4533b13b297d 1046 void pbScreen(bool force, bool showButtons){
TickTock 36:dbd39c315258 1047 if (force) {
TickTock 36:dbd39c315258 1048 tt.background(Black);
TickTock 36:dbd39c315258 1049 tt.cls();
TickTock 36:dbd39c315258 1050 }
TickTock 36:dbd39c315258 1051 if(playbackOpen){
garygid 54:6ce808d0995e 1052 showButton(0,0,"Slower"," <--",4,4);
garygid 54:6ce808d0995e 1053
TickTock 36:dbd39c315258 1054 if(playbackEn){
garygid 54:6ce808d0995e 1055 sprintf(sTemp1,"Pause");
TickTock 36:dbd39c315258 1056 }else{
garygid 54:6ce808d0995e 1057 sprintf(sTemp1," Run");
TickTock 36:dbd39c315258 1058 }
garygid 54:6ce808d0995e 1059 sprintf(sTemp2,"%4.3f ",playbackInt);
garygid 54:6ce808d0995e 1060 showButton(1,0,sTemp1,sTemp2,4,4);
garygid 54:6ce808d0995e 1061
garygid 54:6ce808d0995e 1062 showButton(2,0,"Faster"," -->",4,4);
TickTock 36:dbd39c315258 1063 }
TickTock 36:dbd39c315258 1064 if(playbackOpen){
TickTock 36:dbd39c315258 1065 sprintf(sTemp1," Stop");
TickTock 36:dbd39c315258 1066 }else{
garygid 54:6ce808d0995e 1067 sprintf(sTemp1,"Start");
TickTock 36:dbd39c315258 1068 }
garygid 54:6ce808d0995e 1069 showButton(1,1,sTemp1,"Playback",4,4);
TickTock 36:dbd39c315258 1070 }
TickTock 36:dbd39c315258 1071
TickTock 42:4533b13b297d 1072 void showDateTime(bool force, bool showButtons){
TickTock 152:a4d66901785d 1073 CANMessage msg;
TickTock 36:dbd39c315258 1074 struct tm t; // pointer to a static tm structure
TickTock 36:dbd39c315258 1075 time_t seconds ;
TickTock 36:dbd39c315258 1076 tt.foreground(Yellow);
TickTock 44:6262a9fd1e56 1077 tt.background(Black);
TickTock 152:a4d66901785d 1078 if (force||tock) {
TickTock 36:dbd39c315258 1079 tt.cls();
TickTock 36:dbd39c315258 1080 tt.locate(10,10);
TickTock 43:e7f6f80590e3 1081 tt.set_font((unsigned char*) Arial12x12);
TickTock 152:a4d66901785d 1082 if(accOn){
TickTock 152:a4d66901785d 1083 seconds = time(NULL);
TickTock 153:e94cfe3c339c 1084 t = *localtime(&seconds);
TickTock 153:e94cfe3c339c 1085
TickTock 153:e94cfe3c339c 1086 if(modelYear<2013){
TickTock 153:e94cfe3c339c 1087 msg = lastMsg[indexLastMsg[0x5fa]];
TickTock 153:e94cfe3c339c 1088 t.tm_mon = (msg.data[5]>>4)-1;
TickTock 153:e94cfe3c339c 1089 t.tm_mday = msg.data[2]>>3;
TickTock 153:e94cfe3c339c 1090 // Have not figured out where the year is on MY2011
TickTock 153:e94cfe3c339c 1091 msg = lastMsg[indexLastMsg[0x5fc]];
TickTock 153:e94cfe3c339c 1092 t.tm_hour = msg.data[0]>>3;
TickTock 153:e94cfe3c339c 1093 t.tm_min = (msg.data[1]<<4&0x30)+(msg.data[2]>>4);
TickTock 153:e94cfe3c339c 1094 t.tm_sec = msg.data[1]>>2;
TickTock 153:e94cfe3c339c 1095 }else{
TickTock 153:e94cfe3c339c 1096 // Have not figured out where Year, Month, or Day is for MY2013
TickTock 153:e94cfe3c339c 1097 msg = lastMsg[indexLastMsg[0x5f9]];
TickTock 153:e94cfe3c339c 1098 t.tm_hour = msg.data[5]>>3;
TickTock 153:e94cfe3c339c 1099 t.tm_min = msg.data[4];
TickTock 153:e94cfe3c339c 1100 msg = lastMsg[indexLastMsg[0x509]];
TickTock 153:e94cfe3c339c 1101 t.tm_sec = msg.data[2]>>2;
TickTock 153:e94cfe3c339c 1102 }
TickTock 153:e94cfe3c339c 1103
TickTock 152:a4d66901785d 1104 strftime(sTemp1, 32, "%a %m/%d/%Y %X \n", &t);
TickTock 152:a4d66901785d 1105 printf("Leaf: %s",sTemp1);
TickTock 152:a4d66901785d 1106 }
TickTock 152:a4d66901785d 1107 seconds = time(NULL);
TickTock 152:a4d66901785d 1108 t = *localtime(&seconds);
TickTock 36:dbd39c315258 1109 strftime(sTemp1, 32, "%a %m/%d/%Y %X \n", &t);
TickTock 152:a4d66901785d 1110 tt.locate(10,24);
TickTock 152:a4d66901785d 1111 printf("CANary: %s",sTemp1);
TickTock 122:138a40892a4c 1112 if(showButtons){
TickTock 36:dbd39c315258 1113 switch(dtMode){
TickTock 36:dbd39c315258 1114 case 0:
TickTock 36:dbd39c315258 1115 sprintf(sTemp1,"Year");
TickTock 36:dbd39c315258 1116 break;
TickTock 36:dbd39c315258 1117 case 1:
TickTock 36:dbd39c315258 1118 sprintf(sTemp1,"Month");
TickTock 36:dbd39c315258 1119 break;
TickTock 36:dbd39c315258 1120 case 2:
TickTock 36:dbd39c315258 1121 sprintf(sTemp1,"Day");
TickTock 36:dbd39c315258 1122 break;
TickTock 36:dbd39c315258 1123 case 3:
TickTock 36:dbd39c315258 1124 sprintf(sTemp1,"Hour");
TickTock 36:dbd39c315258 1125 break;
TickTock 36:dbd39c315258 1126 case 4:
TickTock 36:dbd39c315258 1127 sprintf(sTemp1,"Minute");
TickTock 36:dbd39c315258 1128 break;
TickTock 36:dbd39c315258 1129 case 5:
TickTock 36:dbd39c315258 1130 sprintf(sTemp1,"Second");
TickTock 36:dbd39c315258 1131 break;
TickTock 36:dbd39c315258 1132 default:
TickTock 36:dbd39c315258 1133 break;
TickTock 36:dbd39c315258 1134 }
TickTock 66:b7476ce7a59e 1135 showButton(0,1,sTemp1,"",4,4);
TickTock 152:a4d66901785d 1136 showButton(1,1," Up","",4,4);
TickTock 152:a4d66901785d 1137 showButton(2,1," Down","",4,4);
TickTock 152:a4d66901785d 1138 if(accOn){
TickTock 152:a4d66901785d 1139 showButton(3,1," Sync","w/ car",4,4);
TickTock 152:a4d66901785d 1140 }
TickTock 152:a4d66901785d 1141 if(autoSync){
TickTock 152:a4d66901785d 1142 showButton(3,2,"disable"," auto",4,4);
TickTock 152:a4d66901785d 1143 }else{
TickTock 152:a4d66901785d 1144 showButton(3,2,"enable"," auto",4,4);
TickTock 152:a4d66901785d 1145 }
TickTock 36:dbd39c315258 1146 }
TickTock 36:dbd39c315258 1147 }
TickTock 36:dbd39c315258 1148 }
TickTock 36:dbd39c315258 1149
TickTock 50:83d5864c64a0 1150 void dteDisplay(bool force, bool showButtons, bool showMiles){
TickTock 66:b7476ce7a59e 1151 unsigned short i,x,y,lx,ly,gids,radius,color,r,t;
TickTock 170:7ee98e3611bc 1152 unsigned char toVal,availableRegen=0;
TickTock 50:83d5864c64a0 1153 static unsigned short lgids=0;
TickTock 50:83d5864c64a0 1154 static unsigned char leff[39]={0};
TickTock 50:83d5864c64a0 1155 CANMessage msg;
TickTock 66:b7476ce7a59e 1156 unsigned long targetBraking, regenBraking, temp;
TickTock 156:4e5d30535cf9 1157 static unsigned long maxTarget = 1000, tardivreg_x1000 = 1400;
TickTock 170:7ee98e3611bc 1158 static unsigned char lr=0, lt=0, lar=0;
TickTock 50:83d5864c64a0 1159
TickTock 50:83d5864c64a0 1160 msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
TickTock 50:83d5864c64a0 1161 gids = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 50:83d5864c64a0 1162 if(gids==0){
TickTock 83:52b1f330a62d 1163 gids=281; // Display new, fully charged capacity until real data obtained
TickTock 50:83d5864c64a0 1164 }
TickTock 50:83d5864c64a0 1165
TickTock 37:fea2c1d52c5f 1166 tt.background(Navy);
TickTock 49:a3d2c5bb3cfa 1167 tt.foreground(Yellow);
TickTock 52:d5385fbf4ea1 1168 if(force){
TickTock 97:a25940fd7b5b 1169 tt.set_font((unsigned char*) Arial12x12);
TickTock 52:d5385fbf4ea1 1170 tt.cls();
TickTock 49:a3d2c5bb3cfa 1171 x=50+0*6;
TickTock 52:d5385fbf4ea1 1172 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 1173 printf("sec\n");
TickTock 50:83d5864c64a0 1174 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 1175 x=50+9*6;
TickTock 52:d5385fbf4ea1 1176 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 1177 printf("min\n");
TickTock 50:83d5864c64a0 1178 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 1179 x=50+18*6;
TickTock 52:d5385fbf4ea1 1180 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 1181 printf("hour\n");
TickTock 83:52b1f330a62d 1182 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 1183 x=50+25*6;
TickTock 52:d5385fbf4ea1 1184 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 1185 printf("day\n");
TickTock 50:83d5864c64a0 1186 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 1187 x=50+32*6;
TickTock 52:d5385fbf4ea1 1188 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 1189 printf("mon\n");
TickTock 50:83d5864c64a0 1190 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 1191 x=50+38*6;
TickTock 170:7ee98e3611bc 1192 lar=0;
TickTock 162:c6545fc0164a 1193 }
TickTock 162:c6545fc0164a 1194 toVal=33;
TickTock 83:52b1f330a62d 1195 if(force||lgids!=gids){ // update Y axis when kWh changes
TickTock 97:a25940fd7b5b 1196 tt.set_font((unsigned char*) Arial24x23);
TickTock 131:0d926c080a65 1197 for(i=2;i<7;i++){
TickTock 131:0d926c080a65 1198 y=200-(i-2)*40;
TickTock 97:a25940fd7b5b 1199 tt.locate(0,y-8);
TickTock 83:52b1f330a62d 1200 if (showMiles){
leafman 98:9f8bab96edff 1201 printf("%3.0f\n",convertDistance(i*((float)(gids-5)*.075))); // LM - Added metric support
TickTock 83:52b1f330a62d 1202 }else{
TickTock 83:52b1f330a62d 1203 printf("%d.0\n",i);
TickTock 50:83d5864c64a0 1204 }
TickTock 97:a25940fd7b5b 1205 tt.line(48,y,toVal*6+56,y,DarkGrey);
TickTock 83:52b1f330a62d 1206 }
TickTock 50:83d5864c64a0 1207 lgids=gids;
TickTock 50:83d5864c64a0 1208 }
TickTock 121:553faf139a20 1209 if(tock||force){
TickTock 131:0d926c080a65 1210 for(i=2;i<7;i++){
TickTock 131:0d926c080a65 1211 y=200-(i-2)*40;
TickTock 83:52b1f330a62d 1212 tt.line(40,y,158,y,DarkGrey);
TickTock 50:83d5864c64a0 1213 }
TickTock 50:83d5864c64a0 1214
TickTock 50:83d5864c64a0 1215 x=50+0*6;
TickTock 50:83d5864c64a0 1216 tt.line(x,10,x,220,DarkGrey);
TickTock 50:83d5864c64a0 1217 x=50+9*6;
TickTock 50:83d5864c64a0 1218 tt.line(x,10,x,220,DarkGrey);
TickTock 50:83d5864c64a0 1219 x=50+18*6;
TickTock 50:83d5864c64a0 1220 tt.line(x,10,x,220,DarkGrey);
TickTock 83:52b1f330a62d 1221 //x=50+25*6;
TickTock 83:52b1f330a62d 1222 //tt.line(x,60,x,220,DarkGrey);
TickTock 83:52b1f330a62d 1223 //x=50+32*6;
TickTock 83:52b1f330a62d 1224 //tt.line(x,60,x,220,DarkGrey);
TickTock 66:b7476ce7a59e 1225 //x=50+38*6;
TickTock 66:b7476ce7a59e 1226 //tt.line(x,60,x,220,DarkGrey);
TickTock 50:83d5864c64a0 1227 tt.set_font((unsigned char*) SCProSB31x55);
TickTock 164:46ed06263b0e 1228 tt.foreground(Yellow);
TickTock 50:83d5864c64a0 1229 if (showMiles){
TickTock 93:c2402e8cd0e2 1230 float miles = mpkWh[dtePeriod]*((float)(gids-5)*.075);
leafman 98:9f8bab96edff 1231 miles = convertDistance(miles); // LM - Metric support
TickTock 93:c2402e8cd0e2 1232 // Right justify
TickTock 94:c3a14b3975d6 1233 if (miles>99.9){ //space=18; num=31; . = 23
TickTock 163:3b6fab958773 1234 tt.locate(161,1);
TickTock 94:c3a14b3975d6 1235 printf("%4.1f\n",miles);
TickTock 93:c2402e8cd0e2 1236 } else if (miles>9.9){
TickTock 163:3b6fab958773 1237 tt.locate(156,1);
TickTock 94:c3a14b3975d6 1238 printf(" %3.1f\n",miles);
TickTock 93:c2402e8cd0e2 1239 } else {
TickTock 163:3b6fab958773 1240 tt.locate(151,1);
TickTock 94:c3a14b3975d6 1241 printf(" %2.1f\n",miles);
TickTock 93:c2402e8cd0e2 1242 }
TickTock 164:46ed06263b0e 1243 if(CCon) {
TickTock 169:84d790ac18a2 1244 tt.foreground(GreenYellow);
TickTock 164:46ed06263b0e 1245 tt.set_font((unsigned char*) Arial24x23);
TickTock 165:4daa921730dd 1246 miles = (mpkWh_noCC-mpkWh[dtePeriod])*((float)(gids-5)*.075);
TickTock 164:46ed06263b0e 1247 miles = convertDistance(miles); // LM - Metric support
TickTock 164:46ed06263b0e 1248 // Right justify
TickTock 165:4daa921730dd 1249 if (miles>9.9){
TickTock 165:4daa921730dd 1250 tt.locate(190,52);
TickTock 165:4daa921730dd 1251 printf(" +%3.1f \n",miles);
TickTock 165:4daa921730dd 1252 } else {
TickTock 164:46ed06263b0e 1253 tt.locate(182,52);
TickTock 165:4daa921730dd 1254 printf(" +%2.1f \n",miles);
TickTock 164:46ed06263b0e 1255 }
TickTock 162:c6545fc0164a 1256 }
TickTock 50:83d5864c64a0 1257 } else {
TickTock 163:3b6fab958773 1258 tt.locate(200,1);
TickTock 66:b7476ce7a59e 1259 printf("%3.1f \n",mpkWh[dtePeriod]);
TickTock 164:46ed06263b0e 1260 if(CCon) {
TickTock 169:84d790ac18a2 1261 tt.foreground(GreenYellow);
TickTock 164:46ed06263b0e 1262 tt.set_font((unsigned char*) Arial24x23);
TickTock 165:4daa921730dd 1263 tt.locate(190,52);
TickTock 165:4daa921730dd 1264 printf(" +%2.1f \n",(mpkWh_noCC-mpkWh[dtePeriod]));
TickTock 164:46ed06263b0e 1265 }
TickTock 50:83d5864c64a0 1266 }
TickTock 49:a3d2c5bb3cfa 1267 lx=50;
TickTock 97:a25940fd7b5b 1268 ly=mpkWh[0]*40;
TickTock 50:83d5864c64a0 1269 if(dtePeriod==0){
TickTock 52:d5385fbf4ea1 1270 radius=6;
TickTock 79:68f0dd8d1f19 1271 color=Yellow;
TickTock 50:83d5864c64a0 1272 }else{
TickTock 50:83d5864c64a0 1273 radius=2;
TickTock 50:83d5864c64a0 1274 color=Green;
TickTock 50:83d5864c64a0 1275 }
TickTock 131:0d926c080a65 1276 if(ly<60){
TickTock 97:a25940fd7b5b 1277 ly=220;
TickTock 97:a25940fd7b5b 1278 color=Red;
TickTock 131:0d926c080a65 1279 }else if(ly<280) {
TickTock 131:0d926c080a65 1280 ly=280-ly;
TickTock 97:a25940fd7b5b 1281 }else{
TickTock 97:a25940fd7b5b 1282 ly=0;
TickTock 97:a25940fd7b5b 1283 }
TickTock 50:83d5864c64a0 1284 tt.fillcircle(lx,leff[0],radius,Navy);
TickTock 50:83d5864c64a0 1285 tt.fillcircle(lx,ly,radius,color);
TickTock 49:a3d2c5bb3cfa 1286
TickTock 79:68f0dd8d1f19 1287 for(i=1;i<toVal;i++){
TickTock 49:a3d2c5bb3cfa 1288 x=50+i*6;
TickTock 97:a25940fd7b5b 1289 y=mpkWh[i]*40;
TickTock 50:83d5864c64a0 1290 if(i==dtePeriod){
TickTock 79:68f0dd8d1f19 1291 radius=6;
TickTock 79:68f0dd8d1f19 1292 color=Yellow;
TickTock 50:83d5864c64a0 1293 }else{
TickTock 50:83d5864c64a0 1294 radius=2;
TickTock 50:83d5864c64a0 1295 color=Green;
TickTock 50:83d5864c64a0 1296 }
TickTock 131:0d926c080a65 1297 if(y<60){
TickTock 97:a25940fd7b5b 1298 y=220;
TickTock 97:a25940fd7b5b 1299 color=Red;
TickTock 131:0d926c080a65 1300 }else if(y<280) {
TickTock 131:0d926c080a65 1301 y=280-y;
TickTock 97:a25940fd7b5b 1302 }else{
TickTock 97:a25940fd7b5b 1303 y=0;
TickTock 97:a25940fd7b5b 1304 }
TickTock 50:83d5864c64a0 1305 tt.fillcircle(x,leff[i],radius,Navy);
TickTock 50:83d5864c64a0 1306 tt.line(x-6,leff[i-1],x,leff[i],Navy);
TickTock 50:83d5864c64a0 1307 leff[i-1]=ly;
TickTock 52:d5385fbf4ea1 1308 if(y>0){
TickTock 52:d5385fbf4ea1 1309 tt.fillcircle(x,y,radius,color);
TickTock 52:d5385fbf4ea1 1310 }
TickTock 49:a3d2c5bb3cfa 1311 tt.line(lx,ly,x,y,White);
TickTock 49:a3d2c5bb3cfa 1312 lx=x;
TickTock 49:a3d2c5bb3cfa 1313 ly=y;
TickTock 49:a3d2c5bb3cfa 1314 }
TickTock 50:83d5864c64a0 1315 leff[i-1]=y;
TickTock 37:fea2c1d52c5f 1316 }
TickTock 66:b7476ce7a59e 1317
TickTock 170:7ee98e3611bc 1318 msg = lastMsg[indexLastMsg[0x260]]; //Get available regen
TickTock 170:7ee98e3611bc 1319 availableRegen = msg.data[1]*2;
TickTock 170:7ee98e3611bc 1320
TickTock 170:7ee98e3611bc 1321 if(availableRegen>lar){
TickTock 170:7ee98e3611bc 1322 tt.fillrect(264,240-availableRegen,266,239-lar,White);
TickTock 170:7ee98e3611bc 1323 tt.fillrect(308,240-availableRegen,310,239-lar,White);
TickTock 170:7ee98e3611bc 1324 lar=availableRegen;
TickTock 170:7ee98e3611bc 1325 }else if(availableRegen<lar){
TickTock 170:7ee98e3611bc 1326 tt.fillrect(264,240-lar,266,239-availableRegen,Navy);
TickTock 170:7ee98e3611bc 1327 tt.fillrect(308,240-lar,310,239-availableRegen,Navy);
TickTock 170:7ee98e3611bc 1328 lar=availableRegen;
TickTock 170:7ee98e3611bc 1329 }
TickTock 170:7ee98e3611bc 1330
TickTock 156:4e5d30535cf9 1331 msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target total braking
TickTock 66:b7476ce7a59e 1332 targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
TickTock 156:4e5d30535cf9 1333
TickTock 156:4e5d30535cf9 1334 msg = lastMsg[indexLastMsg[0x1d4]]; //Get Motor Amps - simlar to 1d5/1.4 but includes coast regen
TickTock 156:4e5d30535cf9 1335 temp = (msg.data[2]<<4)+(msg.data[3]>>4);
TickTock 156:4e5d30535cf9 1336 if(temp>0x7ff){ // invert and chop positive current
TickTock 156:4e5d30535cf9 1337 regenBraking=0x1000-temp;
TickTock 156:4e5d30535cf9 1338 }else{
TickTock 156:4e5d30535cf9 1339 regenBraking=0;
TickTock 108:29b5a760adc2 1340 }
TickTock 73:62ee8eae3a84 1341
TickTock 73:62ee8eae3a84 1342 if (targetBraking<2045){
TickTock 73:62ee8eae3a84 1343 if (targetBraking>maxTarget) maxTarget=targetBraking;
TickTock 66:b7476ce7a59e 1344 temp = targetBraking;
TickTock 163:3b6fab958773 1345 temp *=167;
TickTock 73:62ee8eae3a84 1346 temp /= maxTarget;
TickTock 73:62ee8eae3a84 1347 t = (char) temp;
TickTock 163:3b6fab958773 1348 if (t>160) t=160;
TickTock 73:62ee8eae3a84 1349 temp = regenBraking;
TickTock 73:62ee8eae3a84 1350 temp *= tardivreg_x1000;
TickTock 73:62ee8eae3a84 1351 temp /= maxTarget;
TickTock 163:3b6fab958773 1352 temp /= 6; // 1000/167=6
TickTock 73:62ee8eae3a84 1353 r = (char) temp;
TickTock 163:3b6fab958773 1354 if (r>160) r=160;
TickTock 73:62ee8eae3a84 1355 if (r>t) t=r; //Should never happen
TickTock 73:62ee8eae3a84 1356 if(lr!=r||lt!=t){
TickTock 170:7ee98e3611bc 1357 if (t<160) tt.fillrect(268,239-160,306,238-t,Navy);
TickTock 170:7ee98e3611bc 1358 if (r<t) tt.fillrect(268,239-t,306,238-r,Red);
TickTock 170:7ee98e3611bc 1359 if (0<r) tt.fillrect(268,239-r,306,238,Green);
TickTock 73:62ee8eae3a84 1360 }
TickTock 73:62ee8eae3a84 1361 lt=t;
TickTock 73:62ee8eae3a84 1362 lr=r;
TickTock 66:b7476ce7a59e 1363 }
TickTock 37:fea2c1d52c5f 1364 }
TickTock 37:fea2c1d52c5f 1365
TickTock 150:ef46ce63345c 1366 void testDisplay (bool force, bool showButtons){
TickTock 158:059abeb44ba1 1367 static unsigned short maxPS=0, oldData[8]={0};
TickTock 158:059abeb44ba1 1368 unsigned char i, uData[8];//, year, month, day, hour, minute, second;
TickTock 148:6e3b9135fad2 1369 CANMessage msg;
TickTock 148:6e3b9135fad2 1370
TickTock 148:6e3b9135fad2 1371 tt.set_font((unsigned char*) Arial24x23);
TickTock 148:6e3b9135fad2 1372 tt.foreground(Yellow);
TickTock 148:6e3b9135fad2 1373 tt.background(Navy);
TickTock 148:6e3b9135fad2 1374 if(force){
TickTock 148:6e3b9135fad2 1375 tt.cls();
TickTock 148:6e3b9135fad2 1376 }
TickTock 158:059abeb44ba1 1377 if(logEn){
TickTock 158:059abeb44ba1 1378 if(pointerSep>maxPS){maxPS=pointerSep;}
TickTock 158:059abeb44ba1 1379 tt.locate(10,10);
TickTock 170:7ee98e3611bc 1380 printf("%3d sep %3d max\n",pointerSep,maxPS);
TickTock 170:7ee98e3611bc 1381 }else{
TickTock 170:7ee98e3611bc 1382 tt.locate(10,10);
TickTock 170:7ee98e3611bc 1383 printf("%d maxT\n",maxTarget);
TickTock 158:059abeb44ba1 1384 }
TickTock 158:059abeb44ba1 1385 /*msg = lastMsg[indexLastMsg[0x5fa]];
TickTock 152:a4d66901785d 1386 month = msg.data[5]>>4;
TickTock 152:a4d66901785d 1387 day = msg.data[2]>>3;
TickTock 152:a4d66901785d 1388 msg = lastMsg[indexLastMsg[0x5fb]];
TickTock 152:a4d66901785d 1389 year = msg.data[1];
TickTock 152:a4d66901785d 1390 msg = lastMsg[indexLastMsg[0x5fc]];
TickTock 152:a4d66901785d 1391 hour = msg.data[0]>>3;
TickTock 152:a4d66901785d 1392 minute = (msg.data[1]<<4&0x30)+(msg.data[2]>>4);
TickTock 152:a4d66901785d 1393 second = msg.data[1]>>2;
TickTock 152:a4d66901785d 1394 tt.locate(0,40);
TickTock 158:059abeb44ba1 1395 printf("%02d%02d%02d %02d%02d%03d\n",hour,minute,second,month,day,year);*/
TickTock 152:a4d66901785d 1396 //printf("%4.2fV %4.2fV \n",accV,accV2);
TickTock 158:059abeb44ba1 1397
TickTock 152:a4d66901785d 1398 for (i=0; i<8; i++){
TickTock 152:a4d66901785d 1399 msg = lastMsg[indexLastMsg[(uMsgId[i]>>4)]];
TickTock 152:a4d66901785d 1400 uData[i] = msg.data[(uMsgId[i]&0x000f)];
TickTock 158:059abeb44ba1 1401 if(i%2==0){
TickTock 158:059abeb44ba1 1402 tt.locate(10,90+(i/2)*30);
TickTock 158:059abeb44ba1 1403 }else{
TickTock 158:059abeb44ba1 1404 tt.locate(170,90+(i/2)*30);
TickTock 158:059abeb44ba1 1405 }
TickTock 158:059abeb44ba1 1406 if(clearTest){
TickTock 169:84d790ac18a2 1407 maxPS=0;
TickTock 158:059abeb44ba1 1408 oldData[i]=uData[i];
TickTock 158:059abeb44ba1 1409 tt.foreground(Yellow);
TickTock 158:059abeb44ba1 1410 tt.background(Navy);
TickTock 158:059abeb44ba1 1411 printf("%4x:%2x\n",uMsgId[i],uData[i]);
TickTock 158:059abeb44ba1 1412 }else if(uData[i]!=oldData[i]){
TickTock 158:059abeb44ba1 1413 tt.foreground(Navy);
TickTock 158:059abeb44ba1 1414 tt.background(Yellow);
TickTock 158:059abeb44ba1 1415 printf("%4x:%2x\n",uMsgId[i],uData[i]);
TickTock 159:577e9d015693 1416 oldData[i]=uData[i];
TickTock 158:059abeb44ba1 1417 }else if(force){
TickTock 158:059abeb44ba1 1418 tt.foreground(Yellow);
TickTock 158:059abeb44ba1 1419 tt.background(Navy);
TickTock 158:059abeb44ba1 1420 printf("%4x:%2x\n",uMsgId[i],uData[i]);
TickTock 158:059abeb44ba1 1421 }
TickTock 152:a4d66901785d 1422 }
TickTock 158:059abeb44ba1 1423 clearTest=false;
TickTock 158:059abeb44ba1 1424 showButton(3,0,"Reset","flags",4,4);
TickTock 148:6e3b9135fad2 1425 }
TickTock 148:6e3b9135fad2 1426
TickTock 36:dbd39c315258 1427 void updateDisplay(char display){
TickTock 122:138a40892a4c 1428 bool changed,showButtons;
TickTock 164:46ed06263b0e 1429 changed = (dMode[display]!=lastDMode[display]);
TickTock 122:138a40892a4c 1430 showButtons = (display==whichTouched)&&(sMode==1);
TickTock 36:dbd39c315258 1431 tt.set_display(display);
TickTock 36:dbd39c315258 1432 switch (dMode[display]) {
TickTock 36:dbd39c315258 1433 case logScreen:
TickTock 122:138a40892a4c 1434 printLog(changed,showButtons);
TickTock 36:dbd39c315258 1435 break;
TickTock 41:8d4609ea7259 1436 case mainScreen:
TickTock 122:138a40892a4c 1437 mainDisplay(changed,showButtons);
TickTock 36:dbd39c315258 1438 break;
TickTock 36:dbd39c315258 1439 case brakeScreen:
TickTock 122:138a40892a4c 1440 braking(changed,showButtons);
TickTock 36:dbd39c315258 1441 break;
TickTock 41:8d4609ea7259 1442 case dteScreen:
TickTock 122:138a40892a4c 1443 dteDisplay(changed,showButtons,true);
TickTock 37:fea2c1d52c5f 1444 break;
TickTock 50:83d5864c64a0 1445 case effScreen:
TickTock 122:138a40892a4c 1446 dteDisplay(changed,showButtons,false);
TickTock 50:83d5864c64a0 1447 break;
TickTock 50:83d5864c64a0 1448 case monitorScreen:
TickTock 122:138a40892a4c 1449 printLast(changed,showButtons);
TickTock 36:dbd39c315258 1450 break;
TickTock 36:dbd39c315258 1451 case changedScreen:
TickTock 122:138a40892a4c 1452 printChanged(changed,showButtons);
TickTock 36:dbd39c315258 1453 break;
TickTock 36:dbd39c315258 1454 case cpScreen:
TickTock 122:138a40892a4c 1455 cpData(changed||showCP,showButtons);
TickTock 36:dbd39c315258 1456 break;
leafman 98:9f8bab96edff 1457 case configScreen:
TickTock 122:138a40892a4c 1458 config(changed,showButtons);
TickTock 36:dbd39c315258 1459 break;
TickTock 157:1a100a5ed06f 1460 case config2Screen:
TickTock 157:1a100a5ed06f 1461 config2(changed,showButtons);
TickTock 157:1a100a5ed06f 1462 break;
TickTock 38:155ec32c5e91 1463 case playbackScreen:
TickTock 122:138a40892a4c 1464 pbScreen(changed,showButtons);
TickTock 36:dbd39c315258 1465 break;
TickTock 36:dbd39c315258 1466 case dateScreen:
TickTock 122:138a40892a4c 1467 showDateTime(changed,showButtons);
TickTock 36:dbd39c315258 1468 break;
TickTock 44:6262a9fd1e56 1469 case cpHistScreen: // gg - hist
TickTock 122:138a40892a4c 1470 cpHistogram(changed||showCP,showButtons);
TickTock 44:6262a9fd1e56 1471 break;
TickTock 48:d1ce92104a1f 1472 case cpBarScreen: // gg - cpbars
TickTock 122:138a40892a4c 1473 cpBarPlot(changed||showCP,showButtons);
TickTock 48:d1ce92104a1f 1474 break;
garygid 67:2022fce701d0 1475 case indexScreen:
TickTock 122:138a40892a4c 1476 showIndex(changed,showButtons);
garygid 67:2022fce701d0 1477 break;
TickTock 107:e9be732c1ad4 1478 case tripScreen:
TickTock 168:9227024c4e3a 1479 tripDisplay(changed,showButtons,false);
TickTock 168:9227024c4e3a 1480 break;
TickTock 168:9227024c4e3a 1481 case ccTripScreen:
TickTock 168:9227024c4e3a 1482 tripDisplay(changed,showButtons,true);
TickTock 107:e9be732c1ad4 1483 break;
TickTock 118:02010b18efdc 1484 case healthScreen:
TickTock 122:138a40892a4c 1485 healthDisplay(changed,showButtons);
garygid 67:2022fce701d0 1486 break;
TickTock 150:ef46ce63345c 1487 case testScreen:
TickTock 150:ef46ce63345c 1488 testDisplay(changed,showButtons);
TickTock 148:6e3b9135fad2 1489 break;
TickTock 36:dbd39c315258 1490 default:
TickTock 43:e7f6f80590e3 1491 if (changed){
TickTock 43:e7f6f80590e3 1492 tt.background(Black);
TickTock 43:e7f6f80590e3 1493 tt.cls();
TickTock 43:e7f6f80590e3 1494 }
TickTock 36:dbd39c315258 1495 break;
TickTock 36:dbd39c315258 1496 }
TickTock 36:dbd39c315258 1497 lastDMode[display]=dMode[display];
TickTock 36:dbd39c315258 1498
TickTock 42:4533b13b297d 1499 if(display==whichTouched){
TickTock 42:4533b13b297d 1500 switch (sMode) {
TickTock 42:4533b13b297d 1501 case 1: // Select screens
garygid 54:6ce808d0995e 1502 showButton(0,tNavRow," <-Prev","",4,4); // gg - 4x4
garygid 67:2022fce701d0 1503 // col 1 see below
garygid 67:2022fce701d0 1504 showButton(2,tNavRow," Go To"," Index",4,4); // gg - index
garygid 54:6ce808d0995e 1505 showButton(3,tNavRow," Next->","",4,4); // gg - move next
TickTock 154:90ea16ca7475 1506 if (enableSound) {
TickTock 154:90ea16ca7475 1507 sprintf(sTemp1," Mute");
TickTock 154:90ea16ca7475 1508 } else {
TickTock 154:90ea16ca7475 1509 sprintf(sTemp1,"Un-Mute");
TickTock 154:90ea16ca7475 1510 }
garygid 67:2022fce701d0 1511 // col 1 in Nav row
TickTock 42:4533b13b297d 1512 switch (dMode[display]) {
TickTock 44:6262a9fd1e56 1513 case offScreen:
TickTock 154:90ea16ca7475 1514 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1515 sprintf(sTemp2," Off");
TickTock 42:4533b13b297d 1516 break;
TickTock 44:6262a9fd1e56 1517 case logScreen:
TickTock 154:90ea16ca7475 1518 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1519 sprintf(sTemp2," Log");
TickTock 42:4533b13b297d 1520 break;
TickTock 44:6262a9fd1e56 1521 case mainScreen:
TickTock 154:90ea16ca7475 1522 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1523 sprintf(sTemp2," Main");
TickTock 42:4533b13b297d 1524 break;
TickTock 44:6262a9fd1e56 1525 case brakeScreen:
TickTock 154:90ea16ca7475 1526 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1527 sprintf(sTemp2,"Braking");
TickTock 42:4533b13b297d 1528 break;
TickTock 44:6262a9fd1e56 1529 case dteScreen:
TickTock 154:90ea16ca7475 1530 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1531 sprintf(sTemp2," DTE");
TickTock 42:4533b13b297d 1532 break;
TickTock 50:83d5864c64a0 1533 case effScreen:
TickTock 154:90ea16ca7475 1534 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1535 sprintf(sTemp2," Eff");
TickTock 50:83d5864c64a0 1536 break;
TickTock 44:6262a9fd1e56 1537 case monitorScreen:
TickTock 154:90ea16ca7475 1538 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1539 sprintf(sTemp2," Monitor");
TickTock 42:4533b13b297d 1540 break;
TickTock 44:6262a9fd1e56 1541 case changedScreen:
TickTock 154:90ea16ca7475 1542 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1543 sprintf(sTemp2,"DeltaMon");
TickTock 42:4533b13b297d 1544 break;
TickTock 44:6262a9fd1e56 1545 case cpScreen:
TickTock 154:90ea16ca7475 1546 showButton(3,0,sTemp1,"",4,4);
garygid 67:2022fce701d0 1547 sprintf(sTemp2,"CP Data");
TickTock 42:4533b13b297d 1548 break;
leafman 98:9f8bab96edff 1549 case configScreen:
garygid 54:6ce808d0995e 1550 sprintf(sTemp2," Config");
leafman 98:9f8bab96edff 1551 break;
TickTock 157:1a100a5ed06f 1552 case config2Screen:
TickTock 157:1a100a5ed06f 1553 sprintf(sTemp2,"Config2");
TickTock 157:1a100a5ed06f 1554 break;
TickTock 44:6262a9fd1e56 1555 case playbackScreen:
TickTock 154:90ea16ca7475 1556 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1557 sprintf(sTemp2,"Playback");
TickTock 42:4533b13b297d 1558 break;
TickTock 44:6262a9fd1e56 1559 case dateScreen:
TickTock 154:90ea16ca7475 1560 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1561 sprintf(sTemp2,"Set Time");
TickTock 42:4533b13b297d 1562 break;
TickTock 44:6262a9fd1e56 1563 case cpHistScreen: // gg - hist
TickTock 154:90ea16ca7475 1564 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1565 sprintf(sTemp2,"CP Hist");
TickTock 44:6262a9fd1e56 1566 break;
TickTock 48:d1ce92104a1f 1567 case cpBarScreen: // gg - cpbars
TickTock 154:90ea16ca7475 1568 showButton(3,0,sTemp1,"",4,4);
garygid 54:6ce808d0995e 1569 sprintf(sTemp2,"CP Bars");
TickTock 48:d1ce92104a1f 1570 break;
TickTock 107:e9be732c1ad4 1571 case tripScreen:
TickTock 154:90ea16ca7475 1572 showButton(3,0,sTemp1,"",4,4);
TickTock 107:e9be732c1ad4 1573 sprintf(sTemp2," Trip");
TickTock 107:e9be732c1ad4 1574 break;
TickTock 118:02010b18efdc 1575 case healthScreen:
TickTock 154:90ea16ca7475 1576 showButton(3,0,sTemp1,"",4,4);
TickTock 118:02010b18efdc 1577 sprintf(sTemp2,"Health");
TickTock 118:02010b18efdc 1578 break;
TickTock 150:ef46ce63345c 1579 case testScreen:
TickTock 150:ef46ce63345c 1580 sprintf(sTemp2," Test");
TickTock 150:ef46ce63345c 1581 break;
garygid 67:2022fce701d0 1582 case indexScreen: // gg - index
garygid 67:2022fce701d0 1583 sprintf(sTemp2," Index");
garygid 67:2022fce701d0 1584 break;
TickTock 42:4533b13b297d 1585 }
garygid 54:6ce808d0995e 1586 showButton(1,tNavRow," Select",sTemp2,4,4);
garygid 54:6ce808d0995e 1587
TickTock 42:4533b13b297d 1588 wait_ms(100); // pause a moment to reduce flicker
TickTock 42:4533b13b297d 1589 break;
garygid 54:6ce808d0995e 1590
TickTock 42:4533b13b297d 1591 case 2: // numpad
TickTock 151:3047ebb3c9a8 1592 showButton(0,0," 1","",4,4);
TickTock 151:3047ebb3c9a8 1593 showButton(1,0," 2","",4,4);
TickTock 151:3047ebb3c9a8 1594 showButton(2,0," 3","",4,4);
TickTock 151:3047ebb3c9a8 1595 showButton(0,1," 4","",4,4);
TickTock 151:3047ebb3c9a8 1596 showButton(1,1," 5","",4,4);
TickTock 151:3047ebb3c9a8 1597 showButton(2,1," 6","",4,4);
TickTock 151:3047ebb3c9a8 1598 showButton(0,2," 7","",4,4);
TickTock 151:3047ebb3c9a8 1599 showButton(1,2," 8","",4,4);
TickTock 151:3047ebb3c9a8 1600 showButton(2,2," 9","",4,4);
TickTock 151:3047ebb3c9a8 1601 showButton(1,3," 0","",4,4);
garygid 54:6ce808d0995e 1602
TickTock 151:3047ebb3c9a8 1603 showButton(0,3,"<--","",4,4);
TickTock 151:3047ebb3c9a8 1604 showButton(2,3,"-->","",4,4);
TickTock 151:3047ebb3c9a8 1605 showButton(3,3,"return","",4,4);
TickTock 42:4533b13b297d 1606 case 3:
TickTock 42:4533b13b297d 1607 break;
TickTock 42:4533b13b297d 1608 default:
TickTock 42:4533b13b297d 1609 break;
TickTock 42:4533b13b297d 1610 }
TickTock 36:dbd39c315258 1611 }
TickTock 121:553faf139a20 1612 tock=false;
TickTock 121:553faf139a20 1613 } // updateDisplay
TickTock 36:dbd39c315258 1614
garygid 58:4d06288d75a2 1615 //---------------------
garygid 58:4d06288d75a2 1616 // gg - highlight
TickTock 62:ffd15edb5431 1617 void highlightButton(unsigned char column, unsigned char row, unsigned char tScn, unsigned char columns, unsigned char rows){
TickTock 62:ffd15edb5431 1618
garygid 58:4d06288d75a2 1619 unsigned short x1,x2,y1,y2;
garygid 58:4d06288d75a2 1620
garygid 58:4d06288d75a2 1621 x1=column*(320/columns)+btnGap/2;
garygid 58:4d06288d75a2 1622 x2=(column+1)*(320/columns)-btnGap/2;
garygid 58:4d06288d75a2 1623 y1=row*(240/rows)+btnGap/2;
garygid 58:4d06288d75a2 1624 y2=(row+1)*(240/rows)-btnGap/2;
garygid 65:821fc79cd7fe 1625
garygid 65:821fc79cd7fe 1626 tt.set_display(tScn);
garygid 65:821fc79cd7fe 1627
garygid 65:821fc79cd7fe 1628 if( skin == ggSkin ){
garygid 65:821fc79cd7fe 1629 // paint the whole button box, for a better visual effect
garygid 65:821fc79cd7fe 1630 // especially on a screen with a yellow background
garygid 65:821fc79cd7fe 1631 if( tScn == 0 )
garygid 65:821fc79cd7fe 1632 tt.fillrect(x1,y1,x2,y2,White); // DarkCyan);
garygid 65:821fc79cd7fe 1633 else
garygid 65:821fc79cd7fe 1634 tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
TickTock 66:b7476ce7a59e 1635 } else {
TickTock 66:b7476ce7a59e 1636 tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
garygid 65:821fc79cd7fe 1637 }
garygid 58:4d06288d75a2 1638
garygid 58:4d06288d75a2 1639 // paint the outer pixel as a yellow frame
garygid 58:4d06288d75a2 1640 tt.rect(x1,y1,x2,y2,Yellow) ; // DarkCyan);
garygid 58:4d06288d75a2 1641 }
garygid 58:4d06288d75a2 1642
garygid 58:4d06288d75a2 1643 //---------------------
TickTock 36:dbd39c315258 1644 void showButton(unsigned char column, unsigned char row, char * text1, char * text2, unsigned char columns, unsigned char rows){
TickTock 36:dbd39c315258 1645 unsigned short x1,x2,y1,y2;
garygid 54:6ce808d0995e 1646
TickTock 36:dbd39c315258 1647 x1=column*(320/columns)+btnGap/2;
TickTock 36:dbd39c315258 1648 x2=(column+1)*(320/columns)-btnGap/2;
TickTock 36:dbd39c315258 1649 y1=row*(240/rows)+btnGap/2;
TickTock 36:dbd39c315258 1650 y2=(row+1)*(240/rows)-btnGap/2;
TickTock 36:dbd39c315258 1651 tt.fillrect(x1,y1,x2,y2,DarkCyan);
TickTock 151:3047ebb3c9a8 1652
TickTock 151:3047ebb3c9a8 1653 tt.foreground(Yellow);
TickTock 151:3047ebb3c9a8 1654 tt.background(DarkCyan);
TickTock 151:3047ebb3c9a8 1655 tt.set_font((unsigned char*) Arial12x12);
garygid 54:6ce808d0995e 1656
garygid 54:6ce808d0995e 1657 // adapt formatting of text to the smaller 4x4 box
garygid 54:6ce808d0995e 1658 tt.locate(x1+btnGap/2,y1+btnGap); // gg - 4x4
TickTock 36:dbd39c315258 1659 printf("%s\n",text1);
garygid 54:6ce808d0995e 1660
garygid 54:6ce808d0995e 1661 tt.locate(x1+btnGap/2,y1+btnGap+20);
TickTock 36:dbd39c315258 1662 printf("%s\n",text2);
TickTock 36:dbd39c315258 1663 }
garygid 54:6ce808d0995e 1664
TickTock 13:62e0f7f39ff5 1665
leafman 98:9f8bab96edff 1666 //The temps are stored as metric, distances as imperial... I'm assuming the input based on that - LM
TickTock 148:6e3b9135fad2 1667 float convertC(float input)
leafman 98:9f8bab96edff 1668 {
leafman 98:9f8bab96edff 1669 if (!metric) {
TickTock 150:ef46ce63345c 1670 //convert!
leafman 98:9f8bab96edff 1671 float output = input *1.8f;
leafman 98:9f8bab96edff 1672 output += 32.0f;
leafman 98:9f8bab96edff 1673 return output;
TickTock 23:cd03f9c3395e 1674 }
leafman 98:9f8bab96edff 1675 return input;
leafman 98:9f8bab96edff 1676 }
TickTock 148:6e3b9135fad2 1677
TickTock 148:6e3b9135fad2 1678 float convertF(float input)
TickTock 148:6e3b9135fad2 1679 {
TickTock 148:6e3b9135fad2 1680 if (metric) {
TickTock 150:ef46ce63345c 1681 //convert!
TickTock 148:6e3b9135fad2 1682 float output = input -32.0f;
TickTock 148:6e3b9135fad2 1683 output /= 1.8f;
TickTock 148:6e3b9135fad2 1684 return output;
TickTock 148:6e3b9135fad2 1685 }
TickTock 148:6e3b9135fad2 1686 return input;
TickTock 148:6e3b9135fad2 1687 }
leafman 98:9f8bab96edff 1688 float convertDistance(float input)
leafman 98:9f8bab96edff 1689 {
leafman 98:9f8bab96edff 1690 if (metric) {
leafman 98:9f8bab96edff 1691 return input / 0.62137f;
TickTock 13:62e0f7f39ff5 1692 }
leafman 98:9f8bab96edff 1693 return input;
leafman 98:9f8bab96edff 1694 }
leafman 98:9f8bab96edff 1695 char* distanceUnit()
leafman 98:9f8bab96edff 1696 {
leafman 98:9f8bab96edff 1697 if(metric)
leafman 98:9f8bab96edff 1698 return "km";
leafman 98:9f8bab96edff 1699 return "mi";
leafman 98:9f8bab96edff 1700 }
leafman 98:9f8bab96edff 1701 char* temperatureUnit()
leafman 98:9f8bab96edff 1702 {
leafman 98:9f8bab96edff 1703 if(metric)
leafman 98:9f8bab96edff 1704 return "C";
leafman 98:9f8bab96edff 1705 return "F";
leafman 98:9f8bab96edff 1706 }