Dual CANbus monitor and instrumentation cluster. Presently tuned for the Nissan Leaf EV.

Dependencies:   SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2_ILI9341 mbed

Fork of CANary_corrupt by Tick Tock

After adding the LPC1768 platform, import as a program and do not select the "update to latest revision" box

User Guide

Eagle Schematic and Board design

/media/uploads/TickTock/canaryr6.zip

/media/uploads/TickTock/canary_sch.jpg

/media/uploads/TickTock/canaryr6brd.jpg

For LCD Rev 1.01:

/media/uploads/TickTock/lcdsch.jpg

For VCD Rev 2.00:

/media/uploads/TickTock/lcdr2.jpg

Parts List

qtyinstancepart #packagesupplierDescription
1BAT3Vhttp://www.ebay.com/itm/10x-CR2032-SMD-Battery-Holder-for-CR2032-Battery-/180938057979?pt=LH_DefaultDomain_0&hash=item2a20bfa8fbLithium 2032 coin battery holder
4C1-C4ECST1DC106R6032Tantalium capacitor 10uF
3FC1-FC3ZF1-20-01-T-WThttp://www.samtec.com/cable-systems/idc-ffc/ffc/zero-insertion.aspx20 conductor 1mm pitch flex cable connector (optional)
1FJ-20-R-08.00-4http://www.samtec.com/cable-systems/idc-ffc/ffc/zero-insertion.aspx8\" 20 conductor 1mm pitch flex connector, end reversed (optional)
2H1-H4(DON'T populate H1-H4 headers - solder mbed directly)
1H5http://www.ebay.com/itm/221186042943?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l26491x12 .1\" pitch header (optional)
1H62x6 .1\" pitch header (optional)
2IC1,IC2VP230LMDSOP8http://www.ebay.com/itm/130488665247?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649canbus transciever
1IC3LM1117-5VSOT2235V regulator
5JP*2 pin .1\" jumper header
1mbedLPC1768http://www.ebay.com/itm/200830573509?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649mbed uC
2Q1,Q22N2222SOT23General purpose NPN transistor
1R1R393M120639K resistor
1R2R103M120610K resistor
4R4-R6R102M12061K resistor
1R3R500M120650 Ohm resistor
2TR1-TR5ZJYS81R5-2PL51TG01http://www.digikey.com/product-detail/en/ZJYS81R5-2PL51T-G01/445-2223-1-ND/765232CM Choke
1Z11N5340BGC1702-15http://www.ebay.com/itm/150878122425?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l26496V, 5W Zener Diode
1Z1DC-DC conveterhttp://www.ebay.com/itm/251142727849?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l264912V-7V, 3W DC-DC converter
1X1USBhttp://www.ebay.com/itm/New-Vertical-USB-2-0-A-pcb-connector-socket-USB-A-Type-/300553895292?pt=LH_DefaultDomain_0&hash=item45fa687d7cvertical USB connector
2LCD0,LCD1TFThttp://www.mikroe.com/add-on-boards/display/tft-proto/320x240 LCD with touch screen
1E0Enclosurehttp://www.shapeways.com/model/1077799/canary.html?li=user-profile&materialId=63d printed enclosure

Assembly

1) LCD Displays

I found ribbon cable is a nice way to organize the wires to the displays. There are two versions of the display and each must be wired differently. The original project used HW REV. 1.01. For that version, you'll need 12 conductors and I connected them in the following order:

1LED+
2LED-
3RST
4SDI
5WR/SCLK
6CS
7X+
8X-
9Y+
10Y-
11VDD
12GND

If, instead, you have HW REV 2.0, you will need 13 conductors with the following order:

1LED+
2LED-
3RST
4SDI
5RS (SCLK)
6WR (DC)
7CS
8X+
9X-
10Y+
11Y-
12VDD
13GND

First I connected all the GND connections (2 GND & IM0, IM1, IM3 for REV1.01 or 2 GND, RD, & IM0 for REV2.00). Do not connect the bottom GND until you have the ribbon cable connected. After making all the ribbon cable connections (connecting the GND of the ribbon cable to the bottom GND pad), solder the GND bar from the previous step to the back of the bottom GND connection. Finally, make a connection from the back side 3.3V pin to IM2 for REV1.01 or to IM1,IM2,&IM3 for REV2.00. Take a break and repeat for the second display.

Examples of REV1.01 boards:

/media/uploads/TickTock/lcdtop.jpg /media/uploads/TickTock/lcdbot.jpg

Examples of REV2.00:

/media/uploads/TickTock/rev2front.jpg /media/uploads/TickTock/rev2back.jpg

Once the two displays are complete combine all wires except CS0, CS1, X+, X-, Y+, and Y-. Connect X- of the left display to X+ of the right. Similarly connect Y- of the left display to Y+ of the right. Insulate any exposed wires.

2) PCB

Refer to the schematics to place all the components on the board. If you plan to install into the CANary 3D enclosure, DO NOT install the battery holder or the socket for the mbed and, instead, connect two wires to the VB and GND pads nearby. You will have to install the battery holder against the back wall to avoid interfering with the right-hand display and the mbed will have to be directly soldered. I have not found a socket with a low enough profile to fit in the space provided (depth of enclosure is limited by the space behind the center console). Also, I recommend keeping as much lead as possible on the Zener diode (bending it as shown to clear the back wall). Although it is operating well within parameters, the Zener gets quite hot during extended operation and the leads help dissipate the heat and keep it away from the PCB and other components.Update: Several Zeners have failed resulting in damage to some users boards so I recommend using a DC-DC converter instead to bring the 12V down to 7V.

/media/uploads/TickTock/pcbtop.jpg /media/uploads/TickTock/pcbbot.jpg

Once the PCB is populated, solder the LCDs to the PCB. CS0 connects to the right display and CS1 connects to the left. /media/uploads/TickTock/brddis.jpg

Update: The Zener diodes tended to fail after a few months so I am recommending removing them and replacing with a DC-DC converter. This will run cooler and waste less energy, too. To install, remove the left display panel to gain access to the Zener. From there, the Zener can be removed and it's pads used to connect to the DC-DC converter. I recommend setting the output voltage on the bench before installing since the trim pot is tricky to reach once installed. Set it to 7V. The input can be connected to the left pad previously occupied by the zener and the output can connect to the right. GND(-) can be connected to the bottom right pad on the 2x6 header below the flex cable connector. Make sure the GND wire lies flat so it doesn't interfere with the connection of the flex cable. /media/uploads/TickTock/dcdcinst2.jpg

Once soldered in place, the DC-DC converter can easily be mounted to the back wall with double sided tape above the battery holder. /media/uploads/TickTock/dcdcinst3.jpg

3) Testing

1)First step is to buzz out all connections from the LCDs to the pins in the main board
2)Next check the touch screen connections. On the main board, place an Ohm meter across X+ and X-. You should read 700 Ohms. Repeat for Y+ and Y-. Then test the resistance from X+ to Y+. With nothing touching the screens, it should read >100K Ohms and <1K when touching either screen.
3)When all connections are checked, solder in the mbed. Download and install the touch2 program http://mbed.org/users/TickTock/code/touch2/ to test the basic operation of the mbed and touch screens.
tips:
Touch screen is sensitive - excess flux on X+,X-,Y+,Y- connection on mbed can result in flakey operation
If touch is not working, double-check the LCD0_CS and LCD1_CS are not swapped. LCD0_CS must connect to the CS of the LCD that has X- & Y- connected to the mbed. LCD1_CS must connect to the CS of the LCD that has X+ & Y+ connected to the mbed.
4)Once touch2 works, it is time to connect to the OBD connector. I highly recommend double checking all connections from the OBD to the PCB with the cable in place before connecting to the Leaf. Buzz out all the pins in the OBS to make sure none are shorting to each other, Check that the 12V goes to the Zener (and nothing else) and the switched 12V to the resistor divider (and nothing else). Test the ground connection properly connects to ground and nothing else.
5)Once you are confident there are no shorts or wrong connections from the OBD connector, take a deep breath and plug it into your leaf. Touch2 program should come up and function. Unplug and install the latest CANary firmware. If you have the REV2.00 LCD boards, you will need to edit the precompile.h file in the TOUCH_TFTx2_w9341 library and set USE_ILI9341 to 1. Test all features before installing into the enclosure (gids, cellpair, menu system, logging) since installing and removing from the enclosure is a PITA.

/media/uploads/TickTock/pcbdone.jpg /media/uploads/TickTock/functioning.jpg

4) Enclosure

The 3D printer leaves a lot of powder behind - I used a strong spray of water to get it out of all the cracks. The enclosure comes with a rather rough finish. I recommend convincing yourself you like it, then simply lightly sand then paint before assembly. Sanding is very difficult - the nylon is very nicely fused and doesn't want to sand. I tried sandblasting and that didn't work either. I had some limited success with filler and then sanding, but only on the outside - it is too difficult to sand the face. /media/uploads/TickTock/enclosure.jpg

5) Final Assembly

Make sure you are well rested with lots of patience before attempting assembly. It is a puzzle figuring out how to get both displays and the PCB in place. Enclosure was too expensive for me to keep iterating to optimize for assembly. I ended up snipping the thin display posts shorter and using various tools to push the displays into place. Also, some USB connectors are taller than others. If you have one of the taller ones, you will have to deflect the back wall a bit while inserting the PCB (being careful not to bend the housing) to get it to it's opening in the back wall. Do use a screw in the provided post to secure the PCB as USB insertion will otherwise dislodge it.

I added an additional safety line which wraps around the center post to prevent the enclosure from becoming a projectile in the event of an accident. /media/uploads/TickTock/safety.jpg Installed: /media/uploads/TickTock/installed.jpg

Committer:
TickTock
Date:
Thu Nov 21 23:08:00 2013 +0000
Revision:
162:c6545fc0164a
Parent:
161:71ac85d11f03
Child:
163:3b6fab958773
// Fixed efficiency screen discontinuity when CC power changes; // Added DTE & efficiency w/o CC to efficiency display

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