Dual CANbus monitor and instrumentation cluster

Eagle Schematic and Board design

/media/uploads/TickTock/canaryr5.zip

/media/uploads/TickTock/sch_r4.jpg /media/uploads/TickTock/lcdsch.jpg /media/uploads/TickTock/brd_r4.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
1R1R392M12063.9K resistor
4R2,R4-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
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

Assembly

1) LCD Displays

I found ribbon cable is a nice way to organize the wires to the displays. You'll need 12 conductors and I connected them in the following order:

1LED+
2LED-
3RSTB
4MOSI
5SCLK
6CSB
7X+
8X-
9Y+
10Y-
11VDD
12GND

First I connected all the GND connections (IM0, IM1, IM3, & 2 GND). 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. Take a break and repeat for the second display. /media/uploads/TickTock/lcdtop.jpg /media/uploads/TickTock/lcdbot.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.

/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

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. 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.

5) Final Assembly

Committer:
TickTock
Date:
Sun Apr 14 22:00:51 2013 +0000
Revision:
72:f9a6faa28873
Parent:
68:10f7d7dbae19
Child:
73:62ee8eae3a84
Added log screen to index screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TickTock 13:62e0f7f39ff5 1 //displayModes.cpp
TickTock 37:fea2c1d52c5f 2 #include "displayModes.h"
TickTock 13:62e0f7f39ff5 3
TickTock 25:ddf0ec209f03 4 char sTemp1[40];
TickTock 24:6cf76ed8c432 5 char sTemp2[16];
TickTock 13:62e0f7f39ff5 6
TickTock 42:4533b13b297d 7 void printLast (bool force, bool showButtons){
TickTock 13:62e0f7f39ff5 8 CANMessage msg;
TickTock 13:62e0f7f39ff5 9 tt.locate(0,6);
TickTock 13:62e0f7f39ff5 10 tt.foreground(Red);
TickTock 13:62e0f7f39ff5 11 tt.background(Yellow);
TickTock 13:62e0f7f39ff5 12 if(force) tt.cls(); // Just clear screen if forced - always update display
TickTock 13:62e0f7f39ff5 13 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 13:62e0f7f39ff5 14 for(int i=0; i<19; i++){
TickTock 13:62e0f7f39ff5 15 msg = lastMsg[i+indexOffset];
TickTock 13:62e0f7f39ff5 16 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 17 }
TickTock 42:4533b13b297d 18 if((sMode==1)&&showButtons){
TickTock 25:ddf0ec209f03 19 tt.foreground(Yellow);
TickTock 25:ddf0ec209f03 20 tt.background(DarkCyan);
TickTock 25:ddf0ec209f03 21 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 22
garygid 53:6ce808d0995e 23 showButton(0,0," <up>","",4,4);
garygid 53:6ce808d0995e 24 showButton(2,0,"<down>","",4,4);
TickTock 25:ddf0ec209f03 25 }
TickTock 13:62e0f7f39ff5 26 }
TickTock 13:62e0f7f39ff5 27
TickTock 42:4533b13b297d 28 void printChanged (bool force, bool showButtons){
TickTock 13:62e0f7f39ff5 29 CANMessage msg;
TickTock 13:62e0f7f39ff5 30 unsigned char i,j;
TickTock 13:62e0f7f39ff5 31 tt.locate(0,6);
TickTock 13:62e0f7f39ff5 32 tt.foreground(Red);
TickTock 13:62e0f7f39ff5 33 tt.background(Yellow);
TickTock 13:62e0f7f39ff5 34 if(force) tt.cls(); // Just clear screen if forced - always update display
TickTock 13:62e0f7f39ff5 35 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 13:62e0f7f39ff5 36 i=0;
TickTock 13:62e0f7f39ff5 37 j=indexOffset;
TickTock 13:62e0f7f39ff5 38 do{
TickTock 13:62e0f7f39ff5 39 j=j<99?j+1:j;
TickTock 13:62e0f7f39ff5 40 if(msgChanged[j]>0){
TickTock 13:62e0f7f39ff5 41 msg = lastMsg[j];
TickTock 13:62e0f7f39ff5 42 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 43 i++;
TickTock 13:62e0f7f39ff5 44 }// if changed
TickTock 13:62e0f7f39ff5 45 }while(i<19&&j<99);
TickTock 42:4533b13b297d 46 if((sMode==1)&&showButtons){
TickTock 40:0e6e71a7323f 47 tt.foreground(Yellow);
TickTock 40:0e6e71a7323f 48 tt.background(DarkCyan);
TickTock 40:0e6e71a7323f 49 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 50
garygid 53:6ce808d0995e 51 showButton(0,0," <up>","",4,4);
garygid 53:6ce808d0995e 52 showButton(2,0," <down>","",4,4);
garygid 53:6ce808d0995e 53 showButton(1,0," Reset","Baseline",4,4);
TickTock 40:0e6e71a7323f 54 }
TickTock 13:62e0f7f39ff5 55 }
TickTock 13:62e0f7f39ff5 56
TickTock 42:4533b13b297d 57 void printLog (bool force, bool showButtons){
TickTock 13:62e0f7f39ff5 58 static unsigned char lastDisplayLoc = 0;
TickTock 13:62e0f7f39ff5 59 if(force||displayLoc!=lastDisplayLoc){ //only update if changed
TickTock 13:62e0f7f39ff5 60 tt.foreground(Amber);
TickTock 13:62e0f7f39ff5 61 tt.background(Black);
TickTock 13:62e0f7f39ff5 62 tt.cls();
TickTock 13:62e0f7f39ff5 63 tt.locate(0,6);
TickTock 13:62e0f7f39ff5 64 tt.set_font((unsigned char*) Arial12x12);
TickTock 13:62e0f7f39ff5 65 for(int i=0; i<19; i++){
TickTock 13:62e0f7f39ff5 66 printf("%s",displayLog[displayLoc]);
TickTock 13:62e0f7f39ff5 67 displayLoc=displayLoc>17?0:displayLoc+1;
TickTock 13:62e0f7f39ff5 68 }
TickTock 13:62e0f7f39ff5 69 }
TickTock 13:62e0f7f39ff5 70 lastDisplayLoc=displayLoc;
TickTock 13:62e0f7f39ff5 71 }
TickTock 13:62e0f7f39ff5 72
TickTock 42:4533b13b297d 73 void mainDisplay (bool force, bool showButtons){
TickTock 13:62e0f7f39ff5 74 unsigned short gids, SOC, packV;
TickTock 13:62e0f7f39ff5 75 static unsigned short lgids=0, lSOC=0, lpackV=0;
TickTock 49:a3d2c5bb3cfa 76 static float lkW=0, laccV=0, lmpkWh=0;
TickTock 13:62e0f7f39ff5 77 CANMessage msg;
TickTock 13:62e0f7f39ff5 78
TickTock 13:62e0f7f39ff5 79 msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
TickTock 13:62e0f7f39ff5 80 gids = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 13:62e0f7f39ff5 81 msg = lastMsg[indexLastMsg[0x55b]]; //Get SOC
TickTock 13:62e0f7f39ff5 82 SOC = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 13:62e0f7f39ff5 83 msg = lastMsg[indexLastMsg[0x1db]]; //Get pack volts
TickTock 13:62e0f7f39ff5 84 packV = (msg.data[2]<<2)+(msg.data[3]>>6);
TickTock 13:62e0f7f39ff5 85
TickTock 13:62e0f7f39ff5 86 tt.background(Navy);
TickTock 38:155ec32c5e91 87 tt.foreground(Yellow);
TickTock 38:155ec32c5e91 88 tt.set_font((unsigned char*) Arial28x28);
TickTock 13:62e0f7f39ff5 89 if(force) tt.cls();
TickTock 48:d1ce92104a1f 90 if(skin==ttSkin){
TickTock 50:83d5864c64a0 91 if(force||gids!=lgids||mpkWh[dtePeriod]!=lmpkWh){
TickTock 48:d1ce92104a1f 92 tt.locate(10,10);
TickTock 48:d1ce92104a1f 93 printf("%4d gids \n",gids);
TickTock 49:a3d2c5bb3cfa 94 tt.locate(10,40);
TickTock 49:a3d2c5bb3cfa 95 printf("%4.1f kWh \n",(float)(gids-5)*0.075);
TickTock 48:d1ce92104a1f 96 tt.set_font((unsigned char*) SCProSB31x55);
TickTock 48:d1ce92104a1f 97 tt.foreground(Green);
TickTock 48:d1ce92104a1f 98 tt.locate(60,96);
TickTock 50:83d5864c64a0 99 printf("%4.1f mi \n",mpkWh[dtePeriod]*((float)(gids-5)*.075));
TickTock 48:d1ce92104a1f 100 lgids=gids;
TickTock 50:83d5864c64a0 101 lmpkWh=mpkWh[dtePeriod];
TickTock 48:d1ce92104a1f 102 tt.foreground(Yellow);
TickTock 48:d1ce92104a1f 103 tt.set_font((unsigned char*) Arial28x28);
TickTock 48:d1ce92104a1f 104 }
TickTock 48:d1ce92104a1f 105 if(force||SOC!=lSOC){
TickTock 48:d1ce92104a1f 106 tt.locate(200,10);
TickTock 48:d1ce92104a1f 107 printf("%4.1f%s\n",(float)SOC/10,"% ");
TickTock 48:d1ce92104a1f 108 lSOC=SOC;
TickTock 48:d1ce92104a1f 109 }
TickTock 48:d1ce92104a1f 110 if(force||packV!=lpackV){
TickTock 48:d1ce92104a1f 111 tt.locate(200,200);
TickTock 48:d1ce92104a1f 112 printf("%4.1fV \n",(float)packV/2);
TickTock 48:d1ce92104a1f 113 lpackV=packV;
TickTock 48:d1ce92104a1f 114 }
TickTock 48:d1ce92104a1f 115 if(force||accV!=laccV){
TickTock 48:d1ce92104a1f 116 tt.locate(20,200);
TickTock 48:d1ce92104a1f 117 printf("%3.1fV \n",accV);
TickTock 48:d1ce92104a1f 118 laccV=accV;
TickTock 48:d1ce92104a1f 119 }
TickTock 49:a3d2c5bb3cfa 120 if(force||kW[0]!=lkW){
TickTock 48:d1ce92104a1f 121 tt.locate(180,40);
TickTock 49:a3d2c5bb3cfa 122 printf("%3.2fkW \n",kW[0]);
TickTock 49:a3d2c5bb3cfa 123 //printf("%3.1f mpkWh \n",mpkWh[0]);
TickTock 49:a3d2c5bb3cfa 124 lkW=kW[0];
TickTock 48:d1ce92104a1f 125 }
TickTock 48:d1ce92104a1f 126 }else {//if(skin==ggSkin){
TickTock 48:d1ce92104a1f 127 if(force||gids!=lgids){
TickTock 48:d1ce92104a1f 128 tt.locate(10,10);
TickTock 48:d1ce92104a1f 129 printf("%4d GIDs \n",gids);
TickTock 48:d1ce92104a1f 130
TickTock 48:d1ce92104a1f 131 tt.locate(40,40); // gg - add GIDs Percent of 281
TickTock 48:d1ce92104a1f 132 printf("%4.1f%s \n", (float)gids*0.355872, "% ") ;
TickTock 48:d1ce92104a1f 133 tt.locate(20,70);
TickTock 48:d1ce92104a1f 134 //printf("%4.1f kWh \n",(float)gids*0.08); // is input, not usable
TickTock 48:d1ce92104a1f 135 printf("%4.1f kwh \n",(float)gids*0.075); // gg - closer to usable
TickTock 48:d1ce92104a1f 136
TickTock 48:d1ce92104a1f 137 tt.set_font((unsigned char*) SCProSB31x55);
TickTock 48:d1ce92104a1f 138 tt.foreground(Green);
TickTock 48:d1ce92104a1f 139 //tt.locate(60,96);
TickTock 48:d1ce92104a1f 140 tt.locate(60,116); // gg - move down a little
TickTock 48:d1ce92104a1f 141 printf("%4.1f mi \n",(float)(gids-5)*0.31); // Approx for now
TickTock 48:d1ce92104a1f 142 lgids=gids;
TickTock 48:d1ce92104a1f 143 tt.foreground(Yellow);
TickTock 48:d1ce92104a1f 144 tt.set_font((unsigned char*) Arial28x28);
TickTock 48:d1ce92104a1f 145 }
TickTock 48:d1ce92104a1f 146
TickTock 48:d1ce92104a1f 147 if(force||SOC!=lSOC){
TickTock 48:d1ce92104a1f 148 tt.locate(200,10);
TickTock 48:d1ce92104a1f 149 printf("%4.1f%s\n",(float)SOC/10,"% ");
TickTock 48:d1ce92104a1f 150 lSOC=SOC;
TickTock 48:d1ce92104a1f 151 }
TickTock 48:d1ce92104a1f 152 if(force||packV!=lpackV){
TickTock 48:d1ce92104a1f 153 tt.locate(200,200);
TickTock 48:d1ce92104a1f 154 printf("%4.1fV \n",(float)packV/2);
TickTock 48:d1ce92104a1f 155 lpackV=packV;
TickTock 48:d1ce92104a1f 156 }
TickTock 48:d1ce92104a1f 157 if(force||accV!=laccV){
TickTock 48:d1ce92104a1f 158 tt.locate(20,200);
TickTock 48:d1ce92104a1f 159 printf("%3.1fV \n",accV);
TickTock 48:d1ce92104a1f 160 laccV=accV;
TickTock 48:d1ce92104a1f 161 }
TickTock 49:a3d2c5bb3cfa 162 if(force||kW[0]!=lkW){
TickTock 48:d1ce92104a1f 163 tt.locate(160,40); // gg - move left to keep from wrap
TickTock 49:a3d2c5bb3cfa 164 printf("%3.2fkw \n",kW[0]); // use small w to save space
TickTock 49:a3d2c5bb3cfa 165 lkW=kW[0];
TickTock 48:d1ce92104a1f 166 }
TickTock 35:5acbd8a64a89 167 }
TickTock 13:62e0f7f39ff5 168 }
TickTock 13:62e0f7f39ff5 169
TickTock 42:4533b13b297d 170 void braking (bool force, bool showButtons, bool prdata=false){
TickTock 28:f24ac05645d9 171 unsigned long targetBraking, regenBraking;
TickTock 28:f24ac05645d9 172 static unsigned long maxTarget = 1000, maxRegen = 1000, tarDivReg = 1000;
TickTock 28:f24ac05645d9 173 unsigned long temp;
TickTock 28:f24ac05645d9 174 static unsigned char lastPressure[4] = {200,200,200,200};
TickTock 28:f24ac05645d9 175 unsigned char i,r,t;
TickTock 37:fea2c1d52c5f 176 static unsigned char lr=0, lt=0;
TickTock 37:fea2c1d52c5f 177 signed short steering;
TickTock 37:fea2c1d52c5f 178 unsigned short s;
TickTock 37:fea2c1d52c5f 179 static unsigned short ls;
TickTock 37:fea2c1d52c5f 180 unsigned char throttle;
TickTock 37:fea2c1d52c5f 181 static unsigned char lthrottle;
TickTock 48:d1ce92104a1f 182 short steerOutBounds = 0 ;
TickTock 28:f24ac05645d9 183 CANMessage msg;
TickTock 28:f24ac05645d9 184
TickTock 48:d1ce92104a1f 185 //---------------
TickTock 37:fea2c1d52c5f 186 msg = lastMsg[indexLastMsg[0x180]]; //Get Throttle position
TickTock 37:fea2c1d52c5f 187 throttle = msg.data[5];
TickTock 48:d1ce92104a1f 188
TickTock 48:d1ce92104a1f 189 // ---- steering ----
TickTock 37:fea2c1d52c5f 190 msg = lastMsg[indexLastMsg[0x002]]; //Get Steering angle
TickTock 37:fea2c1d52c5f 191 steering = (msg.data[1]<<8)+msg.data[0];
TickTock 48:d1ce92104a1f 192
TickTock 48:d1ce92104a1f 193 if(skin==ttSkin){
TickTock 67:b7476ce7a59e 194 s= (unsigned short) ((steering/10)+155)%310; // this modulo wraps display
TickTock 48:d1ce92104a1f 195 }else{// if(skin==ggSkin){
TickTock 48:d1ce92104a1f 196 // do not go off screen left or right. gg - steering
TickTock 48:d1ce92104a1f 197 short ss = (short) ((steering/15)+160); // less gain 10 -> 15
TickTock 48:d1ce92104a1f 198 if(ss<0) { ss=0; steerOutBounds = 1; }
TickTock 48:d1ce92104a1f 199 if(ss>310) { ss=310; steerOutBounds = 1; }
TickTock 48:d1ce92104a1f 200 s = (unsigned short) ss;
TickTock 48:d1ce92104a1f 201 }
TickTock 48:d1ce92104a1f 202
TickTock 48:d1ce92104a1f 203 //--------------
TickTock 28:f24ac05645d9 204 msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
TickTock 28:f24ac05645d9 205 regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
TickTock 28:f24ac05645d9 206 targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
TickTock 28:f24ac05645d9 207 if ((targetBraking>50)&&(regenBraking>50)){
TickTock 28:f24ac05645d9 208 temp = targetBraking;
TickTock 28:f24ac05645d9 209 temp *= 1000;
TickTock 28:f24ac05645d9 210 temp /= regenBraking;
TickTock 28:f24ac05645d9 211 if (temp<tarDivReg) tarDivReg=temp;
TickTock 28:f24ac05645d9 212 }
TickTock 28:f24ac05645d9 213 if (targetBraking>maxTarget) maxTarget=targetBraking;
TickTock 28:f24ac05645d9 214 if (regenBraking>maxRegen) maxRegen=regenBraking;
TickTock 28:f24ac05645d9 215
TickTock 28:f24ac05645d9 216 msg = lastMsg[indexLastMsg[0x1ca]]; //Get brake pressure
TickTock 28:f24ac05645d9 217 tt.background(Navy);
TickTock 28:f24ac05645d9 218 if (force) {
TickTock 28:f24ac05645d9 219 tt.cls();
TickTock 28:f24ac05645d9 220 tt.rect(0,111,170,239,White);
TickTock 28:f24ac05645d9 221 tt.line(0,207,170,207,White);
TickTock 28:f24ac05645d9 222 tt.line(0,175,170,175,White);
TickTock 28:f24ac05645d9 223 tt.line(0,143,170,143,White);
TickTock 28:f24ac05645d9 224 lastPressure[0] = 200;
TickTock 28:f24ac05645d9 225 lastPressure[1] = 200;
TickTock 28:f24ac05645d9 226 lastPressure[2] = 200;
TickTock 28:f24ac05645d9 227 lastPressure[3] = 200;
TickTock 28:f24ac05645d9 228 }
TickTock 48:d1ce92104a1f 229
TickTock 48:d1ce92104a1f 230 // display the steering position small square
TickTock 37:fea2c1d52c5f 231 if (s!=ls){
TickTock 48:d1ce92104a1f 232 // steering position has moved
TickTock 48:d1ce92104a1f 233 //tt.fillrect(ls,5,ls+9,14, Navy); // blank old position
TickTock 48:d1ce92104a1f 234
TickTock 48:d1ce92104a1f 235 //---- gg - steering red
TickTock 48:d1ce92104a1f 236 // box is blanked by top of Braking bar, so move up 5
TickTock 48:d1ce92104a1f 237 tt.fillrect(ls,0,ls+9,9, Navy); // blank old position
TickTock 48:d1ce92104a1f 238 if( steerOutBounds != 0 ) // draw out-of-bounds as a red box
TickTock 48:d1ce92104a1f 239 tt.fillrect(s,0,s+9,9, Red); // draw out-of-bounds position
TickTock 48:d1ce92104a1f 240 else
TickTock 48:d1ce92104a1f 241 tt.fillrect(s,0,s+9,9, White); // draw new in-bounds position
TickTock 48:d1ce92104a1f 242
TickTock 48:d1ce92104a1f 243 //----
TickTock 37:fea2c1d52c5f 244 //tt.foreground(Yellow);
TickTock 37:fea2c1d52c5f 245 //tt.set_font((unsigned char*) Arial28x28);
TickTock 37:fea2c1d52c5f 246 //tt.locate(10,40);
TickTock 37:fea2c1d52c5f 247 //printf("%d %d \n",s,ls);
TickTock 37:fea2c1d52c5f 248 ls=s;
TickTock 37:fea2c1d52c5f 249 }
TickTock 48:d1ce92104a1f 250
TickTock 37:fea2c1d52c5f 251 if (throttle!=lthrottle){
TickTock 37:fea2c1d52c5f 252 if (throttle>239) throttle=239;
TickTock 37:fea2c1d52c5f 253 if(throttle<lthrottle){
TickTock 37:fea2c1d52c5f 254 tt.fillrect(280,239-lthrottle,310,239-throttle,Navy);
TickTock 37:fea2c1d52c5f 255 }else{
TickTock 37:fea2c1d52c5f 256 tt.fillrect(280,239-throttle,310,239,Yellow);
TickTock 37:fea2c1d52c5f 257 }
TickTock 37:fea2c1d52c5f 258 lthrottle=throttle;
TickTock 37:fea2c1d52c5f 259 }
TickTock 37:fea2c1d52c5f 260
TickTock 28:f24ac05645d9 261 // plot bar graph for each wheel pressure
TickTock 28:f24ac05645d9 262 for (i=0; i<4; i++){
TickTock 28:f24ac05645d9 263 if (msg.data[i]<239) {
TickTock 28:f24ac05645d9 264 if (msg.data[i]>lastPressure[i]){
TickTock 28:f24ac05645d9 265 tt.fillrect(10+40*i,239-msg.data[i],40+40*i,239,Red);
TickTock 28:f24ac05645d9 266 } else if (msg.data[i]<lastPressure[i]) {
TickTock 28:f24ac05645d9 267 tt.fillrect(10+40*i,238-lastPressure[i],40+40*i,238-msg.data[i],Navy);
TickTock 28:f24ac05645d9 268 }
TickTock 28:f24ac05645d9 269 lastPressure[i]=msg.data[i];
TickTock 28:f24ac05645d9 270 }
TickTock 28:f24ac05645d9 271 }
TickTock 28:f24ac05645d9 272
TickTock 28:f24ac05645d9 273 temp = targetBraking;
TickTock 28:f24ac05645d9 274 temp *=200;
TickTock 28:f24ac05645d9 275 temp /= maxTarget;
TickTock 28:f24ac05645d9 276 t = (char) temp;
TickTock 28:f24ac05645d9 277 if (t>200) t=200;
TickTock 28:f24ac05645d9 278 temp = regenBraking;
TickTock 28:f24ac05645d9 279 temp *= tarDivReg;
TickTock 28:f24ac05645d9 280 temp /= maxTarget;
TickTock 28:f24ac05645d9 281 temp /= 5;
TickTock 28:f24ac05645d9 282 r = (char) temp;
TickTock 28:f24ac05645d9 283 if (r>200) r=200;
TickTock 28:f24ac05645d9 284 if(lr!=r&&prdata){
TickTock 28:f24ac05645d9 285 tt.foreground(Yellow);
TickTock 28:f24ac05645d9 286 tt.set_font((unsigned char*) Arial28x28);
TickTock 28:f24ac05645d9 287 tt.locate(100,40);
TickTock 28:f24ac05645d9 288 printf("%d %d \n",regenBraking,maxRegen);
TickTock 28:f24ac05645d9 289 tt.locate(100,70);
TickTock 28:f24ac05645d9 290 printf("%3.1f (%3.1f%s) \n",(float)tarDivReg/10,(float)regenBraking*tarDivReg/targetBraking/10,"%");
TickTock 28:f24ac05645d9 291 }
TickTock 28:f24ac05645d9 292 if(lt!=t&&prdata){
TickTock 28:f24ac05645d9 293 tt.foreground(Yellow);
TickTock 28:f24ac05645d9 294 tt.set_font((unsigned char*) Arial28x28);
TickTock 28:f24ac05645d9 295 tt.locate(100,10);
TickTock 28:f24ac05645d9 296 printf("%d %d \n",targetBraking,maxTarget);
TickTock 28:f24ac05645d9 297 }
TickTock 28:f24ac05645d9 298 if (r>t) t=r; //Should never happen
TickTock 28:f24ac05645d9 299 if((lr!=r||lt!=t)&&!prdata){
TickTock 37:fea2c1d52c5f 300 tt.fillrect(190,10,260,239-t,Navy);
TickTock 37:fea2c1d52c5f 301 tt.fillrect(190,239-t,260,239-r,Red);
TickTock 37:fea2c1d52c5f 302 tt.fillrect(190,239-r,260,239,Green);
TickTock 28:f24ac05645d9 303 }
TickTock 28:f24ac05645d9 304 lt=t;
TickTock 28:f24ac05645d9 305 lr=r;
TickTock 28:f24ac05645d9 306 }
TickTock 28:f24ac05645d9 307
TickTock 42:4533b13b297d 308 void cpData(bool force, bool showButtons){
TickTock 36:dbd39c315258 309 short unsigned max, min, jv, i, bd;
TickTock 36:dbd39c315258 310 unsigned avg;
TickTock 36:dbd39c315258 311 if(force){
TickTock 36:dbd39c315258 312 tt.foreground(White);
TickTock 36:dbd39c315258 313 tt.background(Navy);
TickTock 36:dbd39c315258 314 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 36:dbd39c315258 315 max=0;
TickTock 36:dbd39c315258 316 min=9999;
TickTock 36:dbd39c315258 317 avg=0;
TickTock 36:dbd39c315258 318 for(i=0; i<96; i++){
TickTock 36:dbd39c315258 319 bd=(battData[i*2+3]<<8)+battData[i*2+4];
TickTock 36:dbd39c315258 320 avg+=bd;
TickTock 36:dbd39c315258 321 if(bd>max) max=bd;
TickTock 36:dbd39c315258 322 if(bd<min) min=bd;
TickTock 36:dbd39c315258 323 }
TickTock 36:dbd39c315258 324 avg /= 96;
TickTock 36:dbd39c315258 325 if(min<3713) {
TickTock 36:dbd39c315258 326 jv=avg-(max-avg)*1.5;
TickTock 36:dbd39c315258 327 } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
TickTock 36:dbd39c315258 328 jv=0;
TickTock 36:dbd39c315258 329 }
TickTock 36:dbd39c315258 330 tt.cls();
TickTock 36:dbd39c315258 331 tt.locate(0,6);
TickTock 36:dbd39c315258 332 printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",max,min,avg,jv,battData[224+5],battData[224+8],battData[224+11],battData[224+14]);
TickTock 36:dbd39c315258 333 tt.locate(0,36);
TickTock 36:dbd39c315258 334 for(i=0; i<16; i++){
TickTock 36:dbd39c315258 335 printf("%02d-%02d : %04d %04d %04d %04d %04d %04d\n",i*6+1,i*6+6,(battData[i*12+3]<<8)+battData[i*12+4],(battData[i*12+5]<<8)+battData[i*12+6],(battData[i*12+7]<<8)+battData[i*12+8],(battData[i*12+9]<<8)+battData[i*12+10],(battData[i*12+11]<<8)+battData[i*12+12],(battData[i*12+13]<<8)+battData[i*12+14]);
TickTock 36:dbd39c315258 336 }
TickTock 36:dbd39c315258 337 tt.rect(8+0*41,16,40+0*41,28,Green);
TickTock 36:dbd39c315258 338 tt.rect(8+1*41,16,40+1*41,28,Yellow);
TickTock 36:dbd39c315258 339 //tt.rect(8+2*41,16,40+2*41,28,White);
TickTock 36:dbd39c315258 340 tt.rect(8+3*41,16,40+3*41,28,Red);
TickTock 36:dbd39c315258 341 for(i=0; i<96; i++){
TickTock 36:dbd39c315258 342 bd=(battData[i*2+3]<<8)+battData[i*2+4];
TickTock 36:dbd39c315258 343 if(bd>0){
TickTock 36:dbd39c315258 344 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 36:dbd39c315258 345 //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 36:dbd39c315258 346 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 36:dbd39c315258 347 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 36:dbd39c315258 348 }
TickTock 36:dbd39c315258 349 }
TickTock 36:dbd39c315258 350 showCP=false;
TickTock 36:dbd39c315258 351 }
TickTock 42:4533b13b297d 352 if((sMode==1)&&showButtons){
TickTock 36:dbd39c315258 353 tt.foreground(Yellow);
TickTock 36:dbd39c315258 354 tt.background(DarkCyan);
TickTock 36:dbd39c315258 355 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 356
garygid 53:6ce808d0995e 357 showButton(1,0,"Request","CP Data",4,4);
TickTock 44:6262a9fd1e56 358 }
TickTock 44:6262a9fd1e56 359 }
TickTock 44:6262a9fd1e56 360
TickTock 44:6262a9fd1e56 361 //----------------
garygid 65:2022fce701d0 362 // gg - index
garygid 65:2022fce701d0 363 void showIndex(bool force, bool showButtons){
garygid 65:2022fce701d0 364
garygid 65:2022fce701d0 365 if(force){
garygid 65:2022fce701d0 366 tt.foreground(White);
garygid 65:2022fce701d0 367 tt.background(Navy);
garygid 65:2022fce701d0 368 //tt.set_font((unsigned char*) Arial12x12_prop); // select the font
garygid 65:2022fce701d0 369
garygid 65:2022fce701d0 370 tt.cls();
garygid 65:2022fce701d0 371
garygid 65:2022fce701d0 372 // add the buttons to GoTo to other screens
garygid 65:2022fce701d0 373
garygid 65:2022fce701d0 374 tt.foreground(Yellow);
garygid 65:2022fce701d0 375 tt.background(DarkCyan);
garygid 65:2022fce701d0 376 tt.set_font((unsigned char*) Arial12x12);
garygid 65:2022fce701d0 377
garygid 65:2022fce701d0 378 // top row
garygid 65:2022fce701d0 379 showButton(0,0," GoTo"," Main",4,4);
garygid 65:2022fce701d0 380 showButton(1,0," GoTo"," Brake",4,4);
garygid 65:2022fce701d0 381 showButton(2,0," GoTo"," EFF",4,4);
garygid 65:2022fce701d0 382 showButton(3,0," GoTo"," DTE",4,4);
garygid 65:2022fce701d0 383 // middle row
garygid 65:2022fce701d0 384 showButton(0,1," GoTo","CP Data",4,4);
garygid 65:2022fce701d0 385 showButton(1,1," GoTo","CP Hist",4,4);
garygid 65:2022fce701d0 386 showButton(2,1," GoTo","CP Bars",4,4);
garygid 65:2022fce701d0 387 // bottom (not Nav) row
garygid 65:2022fce701d0 388 showButton(0,2," GoTo"," Config",4,4);
garygid 65:2022fce701d0 389 showButton(1,2," GoTo","Playback",4,4);
garygid 65:2022fce701d0 390 showButton(2,2," GoTo","Set Time",4,4);
TickTock 72:f9a6faa28873 391 showButton(3,2," GoTo"," Log",4,4);
garygid 65:2022fce701d0 392
garygid 65:2022fce701d0 393 showCP=false;
garygid 65:2022fce701d0 394 }
garygid 65:2022fce701d0 395
garygid 65:2022fce701d0 396 if(sMode==1&&showButtons){
garygid 65:2022fce701d0 397 tt.foreground(Yellow);
garygid 65:2022fce701d0 398 tt.background(DarkCyan);
garygid 65:2022fce701d0 399 tt.set_font((unsigned char*) Arial12x12);
garygid 65:2022fce701d0 400
garygid 65:2022fce701d0 401 // do nothing here?
garygid 65:2022fce701d0 402 }
garygid 65:2022fce701d0 403 }
garygid 65:2022fce701d0 404
garygid 65:2022fce701d0 405 //----------------
TickTock 48:d1ce92104a1f 406 // gg - cpbars
TickTock 48:d1ce92104a1f 407 void cpBarPlot(bool force, bool showButtons){
TickTock 48:d1ce92104a1f 408 short unsigned max, min, jv, i, bd;
TickTock 48:d1ce92104a1f 409 unsigned avg;
TickTock 48:d1ce92104a1f 410 short unsigned nBar[96] ; // bar height over min
TickTock 48:d1ce92104a1f 411
TickTock 48:d1ce92104a1f 412 if(force){
TickTock 48:d1ce92104a1f 413 tt.foreground(White);
TickTock 48:d1ce92104a1f 414 tt.background(Navy);
TickTock 48:d1ce92104a1f 415 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 48:d1ce92104a1f 416 max=0;
TickTock 48:d1ce92104a1f 417 min=9999;
TickTock 48:d1ce92104a1f 418 avg=0;
TickTock 48:d1ce92104a1f 419
TickTock 48:d1ce92104a1f 420 // calc each cell-pair voltage, find max and min
TickTock 48:d1ce92104a1f 421 for(i=0; i<96; i++){
TickTock 48:d1ce92104a1f 422 bd=(battData[i*2+3]<<8)+battData[i*2+4];
TickTock 48:d1ce92104a1f 423 nBar[i] = bd; // init to bar height
TickTock 48:d1ce92104a1f 424 avg+=bd;
TickTock 48:d1ce92104a1f 425 if(bd>max) max=bd;
TickTock 48:d1ce92104a1f 426 if(bd<min) min=bd;
TickTock 48:d1ce92104a1f 427 }
TickTock 48:d1ce92104a1f 428 avg /= 96;
TickTock 48:d1ce92104a1f 429
TickTock 48:d1ce92104a1f 430 if(min<3713) {
TickTock 48:d1ce92104a1f 431 jv=avg-(max-avg)*1.5;
TickTock 48:d1ce92104a1f 432 } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
TickTock 48:d1ce92104a1f 433 jv=0;
TickTock 48:d1ce92104a1f 434 }
TickTock 48:d1ce92104a1f 435
TickTock 48:d1ce92104a1f 436 //------------------
TickTock 48:d1ce92104a1f 437 tt.cls();
TickTock 48:d1ce92104a1f 438
TickTock 48:d1ce92104a1f 439 // show as vertical bar plot
TickTock 48:d1ce92104a1f 440 int xWinMin = 26;
TickTock 48:d1ce92104a1f 441 int xWinMax = 316;
TickTock 48:d1ce92104a1f 442 int yWinMin = 50;
TickTock 48:d1ce92104a1f 443 int yWinMax = 150;
TickTock 48:d1ce92104a1f 444 // draw the Bar Graph Frame, 2 pixels wide
TickTock 48:d1ce92104a1f 445 tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red);
TickTock 48:d1ce92104a1f 446 tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green);
TickTock 48:d1ce92104a1f 447
TickTock 48:d1ce92104a1f 448 // bar heights
TickTock 48:d1ce92104a1f 449 int height = yWinMax - yWinMin ;
TickTock 48:d1ce92104a1f 450 int iBarValMax = max - min ; // zero to N
TickTock 48:d1ce92104a1f 451
TickTock 48:d1ce92104a1f 452 //----------------
TickTock 48:d1ce92104a1f 453 if( iBarValMax == 0 ) {
TickTock 48:d1ce92104a1f 454 // for testing
TickTock 48:d1ce92104a1f 455 min = 3501 ;
TickTock 48:d1ce92104a1f 456 //max = min + 95*2 ; // for tall values
TickTock 48:d1ce92104a1f 457 max = min + 95/4 ; // for small values
TickTock 48:d1ce92104a1f 458 avg = ( max + min ) / 2;
TickTock 48:d1ce92104a1f 459 iBarValMax = max - min ; // zero to N
TickTock 48:d1ce92104a1f 460 for(int i=0; i<96; i++) {
TickTock 48:d1ce92104a1f 461 //nBar[i] = i*2 + min ; // test tall values
TickTock 48:d1ce92104a1f 462 nBar[i] = i/4 + min ; // test small values
TickTock 48:d1ce92104a1f 463 }
TickTock 48:d1ce92104a1f 464 }
TickTock 48:d1ce92104a1f 465 //---------------
TickTock 48:d1ce92104a1f 466 float nBarScale = float(height) / iBarValMax ;
TickTock 48:d1ce92104a1f 467 if( nBarScale < 0.1 ) nBarScale = 0.1 ;
TickTock 48:d1ce92104a1f 468
TickTock 48:d1ce92104a1f 469 // do the Bar-height scaling
TickTock 48:d1ce92104a1f 470 for(int i=0; i<96; i++){
TickTock 48:d1ce92104a1f 471 nBar[i] -= min ; // now, 0 to N = iBinValMax
TickTock 48:d1ce92104a1f 472 nBar[i] *= nBarScale ; // scale, as needed
TickTock 48:d1ce92104a1f 473 }
TickTock 48:d1ce92104a1f 474
TickTock 48:d1ce92104a1f 475 // values, for now
TickTock 48:d1ce92104a1f 476 tt.locate( 0, yWinMax+40 );
TickTock 48:d1ce92104a1f 477 printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",
TickTock 48:d1ce92104a1f 478 max,min,avg,jv,
TickTock 48:d1ce92104a1f 479 battData[224+5],battData[224+8],
TickTock 48:d1ce92104a1f 480 battData[224+11],battData[224+14]);
TickTock 48:d1ce92104a1f 481
TickTock 48:d1ce92104a1f 482 // label the X axis (approximate)
TickTock 48:d1ce92104a1f 483 tt.locate( 2, yWinMax+5); printf("%04d", min );
TickTock 48:d1ce92104a1f 484 //tt.locate( 2, yWinMin-14 ); printf("%04d = %04d from %1.4f", max, int( height / nBarScale ) + min, nBarScale );
TickTock 48:d1ce92104a1f 485 tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.", max , max - min );
TickTock 48:d1ce92104a1f 486
TickTock 48:d1ce92104a1f 487 //---------------
TickTock 48:d1ce92104a1f 488 // show the bars
TickTock 48:d1ce92104a1f 489 int nBarWidth = 2 ;
TickTock 48:d1ce92104a1f 490 int nBarSpace = 1 ; // 1 for testing
TickTock 48:d1ce92104a1f 491
TickTock 48:d1ce92104a1f 492 int xPos = xWinMin + 2 ; // start one from the left
TickTock 48:d1ce92104a1f 493
TickTock 48:d1ce92104a1f 494 for( int i=0; i<96; i++) {
TickTock 48:d1ce92104a1f 495 height = nBar[i] ;
TickTock 48:d1ce92104a1f 496 if( height > 100 ) height = 100 ; // clip tops
TickTock 48:d1ce92104a1f 497
TickTock 48:d1ce92104a1f 498 // draw the bar, is always inside x-window
TickTock 48:d1ce92104a1f 499 tt.fillrect( xPos,yWinMax-height, xPos+nBarWidth-1,yWinMax, Green);
TickTock 48:d1ce92104a1f 500
TickTock 48:d1ce92104a1f 501 // tic mark the y axis each 5
TickTock 48:d1ce92104a1f 502 if(i%5 == 4){
TickTock 48:d1ce92104a1f 503 tt.line( xPos,yWinMax+2, xPos,yWinMax+5, White); // a white tick mark
TickTock 48:d1ce92104a1f 504 tt.line( xPos+1,yWinMax+2, xPos+1,yWinMax+5, White); // a white tick mark, to widen
TickTock 48:d1ce92104a1f 505 //tt.rect( xPos,yWinMax+2, xPos+1,yWinMax+5, White); // a white 2-wide tick mark is SLOW
TickTock 48:d1ce92104a1f 506 }
TickTock 48:d1ce92104a1f 507 // label the y axis each 10
TickTock 48:d1ce92104a1f 508 if(i%10 == 9){
TickTock 48:d1ce92104a1f 509 tt.locate( xPos-6, yWinMax+8 );
TickTock 48:d1ce92104a1f 510 printf("%02d\n", i+1 );
TickTock 48:d1ce92104a1f 511 }
TickTock 48:d1ce92104a1f 512
TickTock 48:d1ce92104a1f 513 // step to the next bar position
TickTock 48:d1ce92104a1f 514 xPos += nBarWidth + nBarSpace ;
TickTock 48:d1ce92104a1f 515 }
TickTock 48:d1ce92104a1f 516
TickTock 48:d1ce92104a1f 517 showCP=false;
TickTock 48:d1ce92104a1f 518 }
TickTock 48:d1ce92104a1f 519
TickTock 48:d1ce92104a1f 520 // handle the button
TickTock 48:d1ce92104a1f 521 if(sMode==1&&showButtons){
TickTock 48:d1ce92104a1f 522 tt.foreground(Yellow);
TickTock 48:d1ce92104a1f 523 tt.background(DarkCyan);
TickTock 48:d1ce92104a1f 524 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 525
garygid 53:6ce808d0995e 526 showButton(1,0,"Request","CP Data",4,4);
TickTock 48:d1ce92104a1f 527 }
TickTock 48:d1ce92104a1f 528 }
TickTock 48:d1ce92104a1f 529
TickTock 48:d1ce92104a1f 530 //----------------
TickTock 44:6262a9fd1e56 531 // gg - hist
TickTock 47:9cc7d876dd6d 532 void cpHistogram(bool force, bool showButtons){
TickTock 44:6262a9fd1e56 533 short unsigned max, min, jv, i, bd;
TickTock 44:6262a9fd1e56 534 unsigned avg;
TickTock 44:6262a9fd1e56 535 if(force){
TickTock 44:6262a9fd1e56 536 tt.foreground(White);
TickTock 44:6262a9fd1e56 537 tt.background(Navy);
TickTock 44:6262a9fd1e56 538 tt.set_font((unsigned char*) Arial12x12_prop); // select the font
TickTock 44:6262a9fd1e56 539 max=0;
TickTock 44:6262a9fd1e56 540 min=9999;
TickTock 44:6262a9fd1e56 541 avg=0;
TickTock 44:6262a9fd1e56 542 for(i=0; i<96; i++){
TickTock 44:6262a9fd1e56 543 bd=(battData[i*2+3]<<8)+battData[i*2+4];
TickTock 44:6262a9fd1e56 544 avg+=bd;
TickTock 44:6262a9fd1e56 545 if(bd>max) max=bd;
TickTock 44:6262a9fd1e56 546 if(bd<min) min=bd;
TickTock 44:6262a9fd1e56 547 }
TickTock 44:6262a9fd1e56 548 avg /= 96;
TickTock 44:6262a9fd1e56 549 if(min<3713) {
TickTock 44:6262a9fd1e56 550 jv=avg-(max-avg)*1.5;
TickTock 44:6262a9fd1e56 551 } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
TickTock 44:6262a9fd1e56 552 jv=0;
TickTock 44:6262a9fd1e56 553 }
TickTock 44:6262a9fd1e56 554
TickTock 44:6262a9fd1e56 555 //------------------
TickTock 44:6262a9fd1e56 556 tt.cls();
TickTock 44:6262a9fd1e56 557
TickTock 44:6262a9fd1e56 558 // show as histogram
TickTock 44:6262a9fd1e56 559 int xWinMin = 20;
TickTock 44:6262a9fd1e56 560 int xWinMax = 300;
TickTock 44:6262a9fd1e56 561 int yWinMin = 50;
TickTock 44:6262a9fd1e56 562 int yWinMax = 150;
TickTock 44:6262a9fd1e56 563 // draw the Histogram Frame, 2 pixels wide
TickTock 44:6262a9fd1e56 564 tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red);
TickTock 44:6262a9fd1e56 565 tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green);
TickTock 44:6262a9fd1e56 566
TickTock 44:6262a9fd1e56 567 // binning
TickTock 44:6262a9fd1e56 568 short nBin[301] ; // bins to count Min values in nBin[0], etc.
TickTock 44:6262a9fd1e56 569 int height ;
TickTock 44:6262a9fd1e56 570 int iBinIndxMax = 300 ;
TickTock 44:6262a9fd1e56 571 int iBinValMax = max - min ; // zero to N
TickTock 44:6262a9fd1e56 572 if( iBinValMax > iBinIndxMax ) iBinValMax = iBinIndxMax ;
TickTock 44:6262a9fd1e56 573
TickTock 44:6262a9fd1e56 574 // clean the bins
TickTock 44:6262a9fd1e56 575 for(int i=0; i<=iBinIndxMax; i++) {
TickTock 44:6262a9fd1e56 576 nBin[i] = 0;
TickTock 44:6262a9fd1e56 577 }
TickTock 44:6262a9fd1e56 578
TickTock 44:6262a9fd1e56 579 // do the bin counting
TickTock 44:6262a9fd1e56 580 for(int i=0; i<96; i++){
TickTock 44:6262a9fd1e56 581 bd=(battData[i*2+3]<<8)+battData[i*2+4] - min ;
TickTock 44:6262a9fd1e56 582 if( bd > iBinValMax ) bd = iBinValMax ;
TickTock 44:6262a9fd1e56 583 nBin[bd] ++ ;
TickTock 44:6262a9fd1e56 584 }
TickTock 44:6262a9fd1e56 585
TickTock 44:6262a9fd1e56 586 //----------------
TickTock 44:6262a9fd1e56 587 if( iBinValMax == 0 ) {
TickTock 44:6262a9fd1e56 588 // for testing
TickTock 44:6262a9fd1e56 589 min = 10 ;
TickTock 44:6262a9fd1e56 590 max = 50 ;
TickTock 44:6262a9fd1e56 591 avg = ( max + min ) / 2;
TickTock 44:6262a9fd1e56 592 iBinValMax = max - min ;
TickTock 44:6262a9fd1e56 593 for(int i=0; i<=(iBinValMax/2); i++) {
TickTock 44:6262a9fd1e56 594 nBin[i] = i ;
TickTock 44:6262a9fd1e56 595 nBin[iBinValMax-i] = i ;
TickTock 44:6262a9fd1e56 596 }
TickTock 44:6262a9fd1e56 597 }
TickTock 44:6262a9fd1e56 598
TickTock 48:d1ce92104a1f 599 // the values, for now
TickTock 48:d1ce92104a1f 600 tt.locate( 0, yWinMax+40 );
TickTock 48:d1ce92104a1f 601 printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",max,min,avg,jv,battData[224+5],battData[224+8],battData[224+11],battData[224+14]);
TickTock 48:d1ce92104a1f 602
TickTock 44:6262a9fd1e56 603 //---------------
TickTock 44:6262a9fd1e56 604 // show the bars
TickTock 44:6262a9fd1e56 605 int nBarWidth = 3 ;
TickTock 44:6262a9fd1e56 606 int nBarSpace = 1 ; // 1 for testing
TickTock 44:6262a9fd1e56 607
TickTock 44:6262a9fd1e56 608 int xPos = (xWinMin + xWinMax) / 2 ;
TickTock 44:6262a9fd1e56 609 xPos -= (avg-min) * (nBarWidth + nBarSpace) ;
TickTock 44:6262a9fd1e56 610
TickTock 44:6262a9fd1e56 611 for( int i=0; i<=iBinValMax; i++) {
TickTock 44:6262a9fd1e56 612 height = 4 * nBin[i] ;
TickTock 44:6262a9fd1e56 613 if( height > 100 ) height = 100 ; // clip tops
TickTock 44:6262a9fd1e56 614
TickTock 44:6262a9fd1e56 615 // if inside the window, draw the bar
TickTock 44:6262a9fd1e56 616 if( ( xPos + nBarWidth < xWinMax ) && ( xPos > xWinMin ) )
TickTock 44:6262a9fd1e56 617 tt.fillrect( xPos,yWinMax-height, xPos+nBarWidth-1,yWinMax, Green);
TickTock 44:6262a9fd1e56 618
TickTock 44:6262a9fd1e56 619 // step to the next bar position
TickTock 44:6262a9fd1e56 620 xPos += nBarWidth + nBarSpace ;
TickTock 44:6262a9fd1e56 621 }
TickTock 44:6262a9fd1e56 622
TickTock 44:6262a9fd1e56 623 showCP=false;
TickTock 44:6262a9fd1e56 624 }
TickTock 44:6262a9fd1e56 625
TickTock 44:6262a9fd1e56 626 // handle the button
TickTock 47:9cc7d876dd6d 627 if(sMode==1&&showButtons){
TickTock 44:6262a9fd1e56 628 tt.foreground(Yellow);
TickTock 44:6262a9fd1e56 629 tt.background(DarkCyan);
TickTock 44:6262a9fd1e56 630 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 631
garygid 53:6ce808d0995e 632 showButton(1,0,"Request","CP Data",4,4);
garygid 53:6ce808d0995e 633 }
TickTock 36:dbd39c315258 634 }
TickTock 36:dbd39c315258 635
TickTock 48:d1ce92104a1f 636 //---------------
TickTock 42:4533b13b297d 637 void config1(bool force, bool showButtons){
TickTock 36:dbd39c315258 638 if (force) {
TickTock 36:dbd39c315258 639 tt.background(Black);
TickTock 36:dbd39c315258 640 tt.cls();
TickTock 36:dbd39c315258 641 }
TickTock 36:dbd39c315258 642 tt.foreground(Yellow);
TickTock 36:dbd39c315258 643 tt.background(DarkCyan);
TickTock 36:dbd39c315258 644 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 645
garygid 64:821fc79cd7fe 646 //-------- top row --------
garygid 53:6ce808d0995e 647 showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4
garygid 53:6ce808d0995e 648 showButton(1,0," Reset","",4,4);
garygid 64:821fc79cd7fe 649 showButton(2,0," Save"," Config",4,4);
garygid 64:821fc79cd7fe 650
garygid 64:821fc79cd7fe 651 // a button to step to the next skin
garygid 64:821fc79cd7fe 652 unsigned int nextSkin = skin + 1 ;
garygid 64:821fc79cd7fe 653 if( nextSkin > maxSkin ) nextSkin = 0 ;
garygid 53:6ce808d0995e 654
garygid 64:821fc79cd7fe 655 if( nextSkin == ttSkin ) sprintf(sTemp1,"Skin TT");
garygid 64:821fc79cd7fe 656 else if( nextSkin == ggSkin ) sprintf(sTemp1,"Skin GG");
garygid 64:821fc79cd7fe 657 else sprintf(sTemp1,"Skin %d",nextSkin);
garygid 64:821fc79cd7fe 658
garygid 64:821fc79cd7fe 659 showButton(3,0," Use",sTemp1,4,4);
TickTock 48:d1ce92104a1f 660
TickTock 48:d1ce92104a1f 661 //------- second row -----
TickTock 36:dbd39c315258 662 if (logEn) {
garygid 53:6ce808d0995e 663 sprintf(sTemp1,"Disable");
TickTock 36:dbd39c315258 664 } else {
garygid 53:6ce808d0995e 665 sprintf(sTemp1,"Enable");
TickTock 36:dbd39c315258 666 }
garygid 53:6ce808d0995e 667 showButton(0,1,sTemp1,"Logging",4,4);
TickTock 48:d1ce92104a1f 668
TickTock 36:dbd39c315258 669 if (repeatPoll) {
garygid 53:6ce808d0995e 670 sprintf(sTemp1,"Disable");
TickTock 36:dbd39c315258 671 } else {
garygid 53:6ce808d0995e 672 sprintf(sTemp1,"Enable");
TickTock 36:dbd39c315258 673 }
garygid 53:6ce808d0995e 674 showButton(1,1,sTemp1,"Auto CP",4,4);
TickTock 48:d1ce92104a1f 675
TickTock 48:d1ce92104a1f 676 // add Enable/Disable Batt Log gg - yesBattLog
TickTock 48:d1ce92104a1f 677 if (yesBattLog) {
garygid 53:6ce808d0995e 678 sprintf(sTemp1,"Disable");
TickTock 48:d1ce92104a1f 679 } else {
garygid 53:6ce808d0995e 680 sprintf(sTemp1,"Enable");
TickTock 48:d1ce92104a1f 681 }
garygid 53:6ce808d0995e 682 showButton(2,1,sTemp1,"Batt Log",4,4);
TickTock 36:dbd39c315258 683 }
TickTock 36:dbd39c315258 684
TickTock 42:4533b13b297d 685 void pbScreen(bool force, bool showButtons){
TickTock 36:dbd39c315258 686 if (force) {
TickTock 36:dbd39c315258 687 tt.background(Black);
TickTock 36:dbd39c315258 688 tt.cls();
TickTock 36:dbd39c315258 689 }
TickTock 36:dbd39c315258 690 tt.foreground(Yellow);
TickTock 36:dbd39c315258 691 tt.background(DarkCyan);
TickTock 36:dbd39c315258 692 tt.set_font((unsigned char*) Arial12x12);
TickTock 36:dbd39c315258 693 if(playbackOpen){
garygid 53:6ce808d0995e 694 showButton(0,0,"Slower"," <--",4,4);
garygid 53:6ce808d0995e 695
TickTock 36:dbd39c315258 696 if(playbackEn){
garygid 53:6ce808d0995e 697 sprintf(sTemp1,"Pause");
TickTock 36:dbd39c315258 698 }else{
garygid 53:6ce808d0995e 699 sprintf(sTemp1," Run");
TickTock 36:dbd39c315258 700 }
garygid 53:6ce808d0995e 701 sprintf(sTemp2,"%4.3f ",playbackInt);
garygid 53:6ce808d0995e 702 showButton(1,0,sTemp1,sTemp2,4,4);
garygid 53:6ce808d0995e 703
garygid 53:6ce808d0995e 704 showButton(2,0,"Faster"," -->",4,4);
TickTock 36:dbd39c315258 705 }
TickTock 36:dbd39c315258 706 if(playbackOpen){
TickTock 36:dbd39c315258 707 sprintf(sTemp1," Stop");
TickTock 36:dbd39c315258 708 }else{
garygid 53:6ce808d0995e 709 sprintf(sTemp1,"Start");
TickTock 36:dbd39c315258 710 }
garygid 53:6ce808d0995e 711 showButton(1,1,sTemp1,"Playback",4,4);
TickTock 36:dbd39c315258 712 }
TickTock 36:dbd39c315258 713
TickTock 42:4533b13b297d 714 void showDateTime(bool force, bool showButtons){
TickTock 36:dbd39c315258 715 struct tm t; // pointer to a static tm structure
TickTock 36:dbd39c315258 716 time_t seconds ;
TickTock 36:dbd39c315258 717 tt.foreground(Yellow);
TickTock 44:6262a9fd1e56 718 tt.background(Black);
TickTock 36:dbd39c315258 719 if (force) {
TickTock 36:dbd39c315258 720 tt.cls();
TickTock 36:dbd39c315258 721 seconds = time(NULL);
TickTock 36:dbd39c315258 722 t = *localtime(&seconds) ;
TickTock 36:dbd39c315258 723
TickTock 36:dbd39c315258 724 tt.locate(10,10);
TickTock 43:e7f6f80590e3 725 tt.set_font((unsigned char*) Arial12x12);
TickTock 36:dbd39c315258 726 strftime(sTemp1, 32, "%a %m/%d/%Y %X \n", &t);
TickTock 36:dbd39c315258 727 printf("%s",sTemp1);
TickTock 42:4533b13b297d 728 if((sMode==1)&&showButtons){
TickTock 36:dbd39c315258 729 switch(dtMode){
TickTock 36:dbd39c315258 730 case 0:
TickTock 36:dbd39c315258 731 sprintf(sTemp1,"Year");
TickTock 36:dbd39c315258 732 break;
TickTock 36:dbd39c315258 733 case 1:
TickTock 36:dbd39c315258 734 sprintf(sTemp1,"Month");
TickTock 36:dbd39c315258 735 break;
TickTock 36:dbd39c315258 736 case 2:
TickTock 36:dbd39c315258 737 sprintf(sTemp1,"Day");
TickTock 36:dbd39c315258 738 break;
TickTock 36:dbd39c315258 739 case 3:
TickTock 36:dbd39c315258 740 sprintf(sTemp1,"Hour");
TickTock 36:dbd39c315258 741 break;
TickTock 36:dbd39c315258 742 case 4:
TickTock 36:dbd39c315258 743 sprintf(sTemp1,"Minute");
TickTock 36:dbd39c315258 744 break;
TickTock 36:dbd39c315258 745 case 5:
TickTock 36:dbd39c315258 746 sprintf(sTemp1,"Second");
TickTock 36:dbd39c315258 747 break;
TickTock 36:dbd39c315258 748 case 6:
TickTock 36:dbd39c315258 749 sprintf(sTemp1,"Select");
TickTock 36:dbd39c315258 750 break;
TickTock 36:dbd39c315258 751 default:
TickTock 36:dbd39c315258 752 break;
TickTock 36:dbd39c315258 753 }
TickTock 44:6262a9fd1e56 754 tt.background(DarkCyan);
TickTock 67:b7476ce7a59e 755 showButton(0,1,sTemp1,"",4,4);
garygid 53:6ce808d0995e 756 showButton(1,1," UP","",4,4);
garygid 53:6ce808d0995e 757 showButton(2,1," DOWN","",4,4);
TickTock 36:dbd39c315258 758 }
TickTock 36:dbd39c315258 759 }
TickTock 36:dbd39c315258 760 }
TickTock 36:dbd39c315258 761
TickTock 50:83d5864c64a0 762 void dteDisplay(bool force, bool showButtons, bool showMiles){
TickTock 67:b7476ce7a59e 763 unsigned short i,x,y,lx,ly,gids,radius,color,r,t;
TickTock 50:83d5864c64a0 764 static unsigned short lgids=0;
TickTock 50:83d5864c64a0 765 static unsigned char leff[39]={0};
TickTock 50:83d5864c64a0 766 CANMessage msg;
TickTock 67:b7476ce7a59e 767 unsigned long targetBraking, regenBraking, temp;
TickTock 67:b7476ce7a59e 768 static unsigned long maxTarget = 1000, maxRegen = 1000, tarDivReg = 1000;
TickTock 67:b7476ce7a59e 769 static unsigned char lr=0, lt=0;
TickTock 50:83d5864c64a0 770
TickTock 50:83d5864c64a0 771 msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
TickTock 50:83d5864c64a0 772 gids = (msg.data[0]<<2)+(msg.data[1]>>6);
TickTock 50:83d5864c64a0 773 if(gids==0){
TickTock 50:83d5864c64a0 774 gids=281;
TickTock 50:83d5864c64a0 775 }
TickTock 50:83d5864c64a0 776
TickTock 37:fea2c1d52c5f 777 tt.background(Navy);
TickTock 49:a3d2c5bb3cfa 778 tt.foreground(Yellow);
TickTock 52:d5385fbf4ea1 779 if(force){
TickTock 52:d5385fbf4ea1 780 tt.cls();
TickTock 52:d5385fbf4ea1 781 }
TickTock 50:83d5864c64a0 782 if(force||lgids!=gids){
TickTock 49:a3d2c5bb3cfa 783 tt.set_font((unsigned char*) Arial12x12);
TickTock 49:a3d2c5bb3cfa 784 for(i=0;i<10;i++){
TickTock 49:a3d2c5bb3cfa 785 y=200-i*20;
TickTock 49:a3d2c5bb3cfa 786 tt.locate(10,y-8);
TickTock 50:83d5864c64a0 787 if (showMiles){
TickTock 50:83d5864c64a0 788 printf("%3.0f\n",i*((float)(gids-5)*.075));
TickTock 50:83d5864c64a0 789 }else{
TickTock 50:83d5864c64a0 790 printf("%d.0\n",i);
TickTock 50:83d5864c64a0 791 }
TickTock 67:b7476ce7a59e 792 tt.line(40,y,254,y,DarkGrey);
TickTock 49:a3d2c5bb3cfa 793 }
TickTock 49:a3d2c5bb3cfa 794
TickTock 49:a3d2c5bb3cfa 795 x=50+0*6;
TickTock 52:d5385fbf4ea1 796 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 797 printf("sec\n");
TickTock 50:83d5864c64a0 798 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 799 x=50+9*6;
TickTock 52:d5385fbf4ea1 800 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 801 printf("min\n");
TickTock 50:83d5864c64a0 802 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 803 x=50+18*6;
TickTock 52:d5385fbf4ea1 804 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 805 printf("hour\n");
TickTock 50:83d5864c64a0 806 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 807 x=50+25*6;
TickTock 52:d5385fbf4ea1 808 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 809 printf("day\n");
TickTock 50:83d5864c64a0 810 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 811 x=50+32*6;
TickTock 52:d5385fbf4ea1 812 tt.locate(x-10,226);
TickTock 49:a3d2c5bb3cfa 813 printf("mon\n");
TickTock 50:83d5864c64a0 814 tt.line(x,10,x,220,DarkGrey);
TickTock 49:a3d2c5bb3cfa 815 x=50+38*6;
TickTock 67:b7476ce7a59e 816 //tt.locate(x-10,226);
TickTock 67:b7476ce7a59e 817 //printf("year\n");
TickTock 67:b7476ce7a59e 818 //tt.line(x,10,x,220,DarkGrey);
TickTock 50:83d5864c64a0 819 lgids=gids;
TickTock 50:83d5864c64a0 820 }
TickTock 50:83d5864c64a0 821 if(force||updateDTE){
TickTock 50:83d5864c64a0 822 for(i=0;i<10;i++){
TickTock 50:83d5864c64a0 823 y=200-i*20;
TickTock 50:83d5864c64a0 824 if (y>60){
TickTock 67:b7476ce7a59e 825 tt.line(40,y,250,y,DarkGrey);
TickTock 50:83d5864c64a0 826 } else {
TickTock 50:83d5864c64a0 827 tt.line(40,y,150,y,DarkGrey);
TickTock 50:83d5864c64a0 828 }
TickTock 50:83d5864c64a0 829 }
TickTock 50:83d5864c64a0 830
TickTock 50:83d5864c64a0 831 x=50+0*6;
TickTock 50:83d5864c64a0 832 tt.line(x,10,x,220,DarkGrey);
TickTock 50:83d5864c64a0 833 x=50+9*6;
TickTock 50:83d5864c64a0 834 tt.line(x,10,x,220,DarkGrey);
TickTock 50:83d5864c64a0 835 x=50+18*6;
TickTock 50:83d5864c64a0 836 tt.line(x,10,x,220,DarkGrey);
TickTock 50:83d5864c64a0 837 x=50+25*6;
TickTock 67:b7476ce7a59e 838 tt.line(x,60,x,220,DarkGrey);
TickTock 50:83d5864c64a0 839 x=50+32*6;
TickTock 67:b7476ce7a59e 840 tt.line(x,60,x,220,DarkGrey);
TickTock 67:b7476ce7a59e 841 //x=50+38*6;
TickTock 67:b7476ce7a59e 842 //tt.line(x,60,x,220,DarkGrey);
TickTock 50:83d5864c64a0 843 tt.set_font((unsigned char*) SCProSB31x55);
TickTock 50:83d5864c64a0 844 tt.foreground(Green);
TickTock 50:83d5864c64a0 845 if (showMiles){
TickTock 67:b7476ce7a59e 846 tt.locate(160,8);
TickTock 52:d5385fbf4ea1 847 printf("%4.1f \n",mpkWh[dtePeriod]*((float)(gids-5)*.075));
TickTock 50:83d5864c64a0 848 } else {
TickTock 52:d5385fbf4ea1 849 tt.locate(180,10);
TickTock 67:b7476ce7a59e 850 printf("%3.1f \n",mpkWh[dtePeriod]);
TickTock 50:83d5864c64a0 851 }
TickTock 49:a3d2c5bb3cfa 852 lx=50;
TickTock 49:a3d2c5bb3cfa 853 ly=mpkWh[0]*20;
TickTock 49:a3d2c5bb3cfa 854 if(ly<200) {
TickTock 49:a3d2c5bb3cfa 855 ly=200-ly;
TickTock 49:a3d2c5bb3cfa 856 }else{
TickTock 49:a3d2c5bb3cfa 857 ly=0;
TickTock 49:a3d2c5bb3cfa 858 }
TickTock 50:83d5864c64a0 859 if(dtePeriod==0){
TickTock 52:d5385fbf4ea1 860 radius=6;
TickTock 50:83d5864c64a0 861 color=Magenta;
TickTock 50:83d5864c64a0 862 }else{
TickTock 50:83d5864c64a0 863 radius=2;
TickTock 50:83d5864c64a0 864 color=Green;
TickTock 50:83d5864c64a0 865 }
TickTock 50:83d5864c64a0 866 tt.fillcircle(lx,leff[0],radius,Navy);
TickTock 50:83d5864c64a0 867 tt.fillcircle(lx,ly,radius,color);
TickTock 49:a3d2c5bb3cfa 868
TickTock 67:b7476ce7a59e 869 for(i=1;i<33;i++){
TickTock 49:a3d2c5bb3cfa 870 x=50+i*6;
TickTock 49:a3d2c5bb3cfa 871 y=mpkWh[i]*20;
TickTock 49:a3d2c5bb3cfa 872 if(y<200) {
TickTock 49:a3d2c5bb3cfa 873 y=200-y;
TickTock 49:a3d2c5bb3cfa 874 }else{
TickTock 49:a3d2c5bb3cfa 875 y=0;
TickTock 49:a3d2c5bb3cfa 876 }
TickTock 50:83d5864c64a0 877 if(i==dtePeriod){
TickTock 50:83d5864c64a0 878 radius=4;
TickTock 50:83d5864c64a0 879 color=Magenta;
TickTock 50:83d5864c64a0 880 }else{
TickTock 50:83d5864c64a0 881 radius=2;
TickTock 50:83d5864c64a0 882 color=Green;
TickTock 50:83d5864c64a0 883 }
TickTock 50:83d5864c64a0 884 tt.fillcircle(x,leff[i],radius,Navy);
TickTock 50:83d5864c64a0 885 tt.line(x-6,leff[i-1],x,leff[i],Navy);
TickTock 50:83d5864c64a0 886 leff[i-1]=ly;
TickTock 52:d5385fbf4ea1 887 if(y>0){
TickTock 52:d5385fbf4ea1 888 tt.fillcircle(x,y,radius,color);
TickTock 52:d5385fbf4ea1 889 }
TickTock 49:a3d2c5bb3cfa 890 tt.line(lx,ly,x,y,White);
TickTock 49:a3d2c5bb3cfa 891 lx=x;
TickTock 49:a3d2c5bb3cfa 892 ly=y;
TickTock 49:a3d2c5bb3cfa 893 }
TickTock 50:83d5864c64a0 894 leff[i-1]=y;
TickTock 50:83d5864c64a0 895 updateDTE=false;
TickTock 37:fea2c1d52c5f 896 }
TickTock 67:b7476ce7a59e 897
TickTock 67:b7476ce7a59e 898 msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
TickTock 67:b7476ce7a59e 899 regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
TickTock 67:b7476ce7a59e 900 targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
TickTock 67:b7476ce7a59e 901 if ((targetBraking>50)&&(regenBraking>50)){
TickTock 67:b7476ce7a59e 902 temp = targetBraking;
TickTock 67:b7476ce7a59e 903 temp *= 1000;
TickTock 67:b7476ce7a59e 904 temp /= regenBraking;
TickTock 67:b7476ce7a59e 905 if (temp<tarDivReg) tarDivReg=temp;
TickTock 67:b7476ce7a59e 906 }
TickTock 67:b7476ce7a59e 907 if (targetBraking>maxTarget) maxTarget=targetBraking;
TickTock 67:b7476ce7a59e 908 if (regenBraking>maxRegen) maxRegen=regenBraking;
TickTock 67:b7476ce7a59e 909
TickTock 67:b7476ce7a59e 910 temp = targetBraking;
TickTock 67:b7476ce7a59e 911 temp *=200;
TickTock 67:b7476ce7a59e 912 temp /= maxTarget;
TickTock 67:b7476ce7a59e 913 t = (char) temp;
TickTock 67:b7476ce7a59e 914 if (t>175) t=175;
TickTock 67:b7476ce7a59e 915 temp = regenBraking;
TickTock 67:b7476ce7a59e 916 temp *= tarDivReg;
TickTock 67:b7476ce7a59e 917 temp /= maxTarget;
TickTock 67:b7476ce7a59e 918 temp /= 5;
TickTock 67:b7476ce7a59e 919 r = (char) temp;
TickTock 67:b7476ce7a59e 920 if (r>175) r=175;
TickTock 67:b7476ce7a59e 921 if (r>t) t=r; //Should never happen
TickTock 67:b7476ce7a59e 922 if(lr!=r||lt!=t){
TickTock 67:b7476ce7a59e 923 tt.fillrect(264,64,310,239-t,Navy);
TickTock 67:b7476ce7a59e 924 tt.fillrect(264,239-t,310,239-r,Red);
TickTock 67:b7476ce7a59e 925 tt.fillrect(264,239-r,310,239,Green);
TickTock 67:b7476ce7a59e 926 }
TickTock 67:b7476ce7a59e 927 lt=t;
TickTock 67:b7476ce7a59e 928 lr=r;
TickTock 37:fea2c1d52c5f 929 }
TickTock 37:fea2c1d52c5f 930
TickTock 36:dbd39c315258 931 void updateDisplay(char display){
TickTock 36:dbd39c315258 932 bool changed;
TickTock 36:dbd39c315258 933 changed = dMode[display]!=lastDMode[display];
TickTock 36:dbd39c315258 934 tt.set_display(display);
TickTock 36:dbd39c315258 935 switch (dMode[display]) {
TickTock 36:dbd39c315258 936 case logScreen:
TickTock 42:4533b13b297d 937 printLog(changed,(display==whichTouched));
TickTock 36:dbd39c315258 938 break;
TickTock 41:8d4609ea7259 939 case mainScreen:
TickTock 42:4533b13b297d 940 mainDisplay(changed,(display==whichTouched));
TickTock 36:dbd39c315258 941 break;
TickTock 36:dbd39c315258 942 case brakeScreen:
TickTock 42:4533b13b297d 943 braking(changed,(display==whichTouched));
TickTock 36:dbd39c315258 944 break;
TickTock 41:8d4609ea7259 945 case dteScreen:
TickTock 50:83d5864c64a0 946 dteDisplay(changed,(display==whichTouched),true);
TickTock 37:fea2c1d52c5f 947 break;
TickTock 50:83d5864c64a0 948 case effScreen:
TickTock 50:83d5864c64a0 949 dteDisplay(changed,(display==whichTouched),false);
TickTock 50:83d5864c64a0 950 break;
TickTock 50:83d5864c64a0 951 case monitorScreen:
TickTock 42:4533b13b297d 952 printLast(changed,(display==whichTouched));
TickTock 36:dbd39c315258 953 break;
TickTock 36:dbd39c315258 954 case changedScreen:
TickTock 42:4533b13b297d 955 printChanged(changed,(display==whichTouched));
TickTock 36:dbd39c315258 956 break;
TickTock 36:dbd39c315258 957 case cpScreen:
TickTock 42:4533b13b297d 958 cpData(changed||showCP,(display==whichTouched));
TickTock 36:dbd39c315258 959 break;
TickTock 36:dbd39c315258 960 case config1Screen:
TickTock 42:4533b13b297d 961 config1(changed,(display==whichTouched));
TickTock 36:dbd39c315258 962 break;
TickTock 38:155ec32c5e91 963 case playbackScreen:
TickTock 42:4533b13b297d 964 pbScreen(changed,(display==whichTouched));
TickTock 36:dbd39c315258 965 break;
TickTock 36:dbd39c315258 966 case dateScreen:
TickTock 42:4533b13b297d 967 showDateTime(changed,(display==whichTouched));
TickTock 36:dbd39c315258 968 break;
TickTock 44:6262a9fd1e56 969 case cpHistScreen: // gg - hist
TickTock 47:9cc7d876dd6d 970 cpHistogram(changed||showCP,(display==whichTouched));
TickTock 44:6262a9fd1e56 971 break;
TickTock 48:d1ce92104a1f 972 case cpBarScreen: // gg - cpbars
TickTock 48:d1ce92104a1f 973 cpBarPlot(changed||showCP,(display==whichTouched));
TickTock 48:d1ce92104a1f 974 break;
garygid 65:2022fce701d0 975 case indexScreen:
garygid 65:2022fce701d0 976 showIndex(changed,(display==whichTouched));
garygid 65:2022fce701d0 977 break;
TickTock 36:dbd39c315258 978 default:
TickTock 43:e7f6f80590e3 979 if (changed){
TickTock 43:e7f6f80590e3 980 tt.background(Black);
TickTock 43:e7f6f80590e3 981 tt.cls();
TickTock 43:e7f6f80590e3 982 }
TickTock 36:dbd39c315258 983 break;
TickTock 36:dbd39c315258 984 }
TickTock 36:dbd39c315258 985 lastDMode[display]=dMode[display];
TickTock 36:dbd39c315258 986
TickTock 42:4533b13b297d 987 if(display==whichTouched){
TickTock 42:4533b13b297d 988 switch (sMode) {
TickTock 42:4533b13b297d 989 case 1: // Select screens
TickTock 42:4533b13b297d 990 tt.foreground(Yellow);
TickTock 42:4533b13b297d 991 tt.background(DarkCyan);
garygid 53:6ce808d0995e 992 tt.set_font((unsigned char*) Arial12x12);
garygid 53:6ce808d0995e 993
garygid 53:6ce808d0995e 994 showButton(0,tNavRow," <-Prev","",4,4); // gg - 4x4
garygid 65:2022fce701d0 995 // col 1 see below
garygid 65:2022fce701d0 996 showButton(2,tNavRow," Go To"," Index",4,4); // gg - index
garygid 53:6ce808d0995e 997 showButton(3,tNavRow," Next->","",4,4); // gg - move next
garygid 53:6ce808d0995e 998
garygid 65:2022fce701d0 999 // col 1 in Nav row
TickTock 42:4533b13b297d 1000 switch (dMode[display]) {
TickTock 44:6262a9fd1e56 1001 case offScreen:
garygid 53:6ce808d0995e 1002 sprintf(sTemp2," Off");
TickTock 42:4533b13b297d 1003 break;
TickTock 44:6262a9fd1e56 1004 case logScreen:
garygid 53:6ce808d0995e 1005 sprintf(sTemp2," Log");
TickTock 42:4533b13b297d 1006 break;
TickTock 44:6262a9fd1e56 1007 case mainScreen:
garygid 53:6ce808d0995e 1008 sprintf(sTemp2," Main");
TickTock 42:4533b13b297d 1009 break;
TickTock 44:6262a9fd1e56 1010 case brakeScreen:
garygid 53:6ce808d0995e 1011 sprintf(sTemp2,"Braking");
TickTock 42:4533b13b297d 1012 break;
TickTock 44:6262a9fd1e56 1013 case dteScreen:
garygid 53:6ce808d0995e 1014 sprintf(sTemp2," DTE");
TickTock 42:4533b13b297d 1015 break;
TickTock 50:83d5864c64a0 1016 case effScreen:
garygid 53:6ce808d0995e 1017 sprintf(sTemp2," Eff");
TickTock 50:83d5864c64a0 1018 break;
TickTock 44:6262a9fd1e56 1019 case monitorScreen:
garygid 53:6ce808d0995e 1020 sprintf(sTemp2," Monitor");
TickTock 42:4533b13b297d 1021 break;
TickTock 44:6262a9fd1e56 1022 case changedScreen:
garygid 53:6ce808d0995e 1023 sprintf(sTemp2,"DeltaMon");
TickTock 42:4533b13b297d 1024 break;
TickTock 44:6262a9fd1e56 1025 case cpScreen:
garygid 65:2022fce701d0 1026 sprintf(sTemp2,"CP Data");
TickTock 42:4533b13b297d 1027 break;
TickTock 44:6262a9fd1e56 1028 case config1Screen:
garygid 53:6ce808d0995e 1029 sprintf(sTemp2," Config");
TickTock 42:4533b13b297d 1030 break;
TickTock 44:6262a9fd1e56 1031 case playbackScreen:
garygid 53:6ce808d0995e 1032 sprintf(sTemp2,"Playback");
TickTock 42:4533b13b297d 1033 break;
TickTock 44:6262a9fd1e56 1034 case dateScreen:
garygid 53:6ce808d0995e 1035 sprintf(sTemp2,"Set Time");
TickTock 42:4533b13b297d 1036 break;
TickTock 44:6262a9fd1e56 1037 case cpHistScreen: // gg - hist
garygid 53:6ce808d0995e 1038 sprintf(sTemp2,"CP Hist");
TickTock 44:6262a9fd1e56 1039 break;
TickTock 48:d1ce92104a1f 1040 case cpBarScreen: // gg - cpbars
garygid 53:6ce808d0995e 1041 sprintf(sTemp2,"CP Bars");
TickTock 48:d1ce92104a1f 1042 break;
garygid 65:2022fce701d0 1043 case indexScreen: // gg - index
garygid 65:2022fce701d0 1044 sprintf(sTemp2," Index");
garygid 65:2022fce701d0 1045 break;
TickTock 42:4533b13b297d 1046 }
garygid 53:6ce808d0995e 1047 showButton(1,tNavRow," Select",sTemp2,4,4);
garygid 53:6ce808d0995e 1048
TickTock 42:4533b13b297d 1049 wait_ms(100); // pause a moment to reduce flicker
TickTock 42:4533b13b297d 1050 break;
garygid 53:6ce808d0995e 1051
TickTock 42:4533b13b297d 1052 case 2: // numpad
TickTock 42:4533b13b297d 1053 tt.foreground(Yellow);
TickTock 42:4533b13b297d 1054 tt.background(DarkCyan);
TickTock 42:4533b13b297d 1055 tt.set_font((unsigned char*) Arial24x23);
garygid 53:6ce808d0995e 1056
garygid 53:6ce808d0995e 1057 sprintf(sTemp2,"");
garygid 53:6ce808d0995e 1058 showButton(0,0," 1",sTemp2,4,4);
garygid 53:6ce808d0995e 1059 showButton(1,0," 2",sTemp2,4,4);
garygid 53:6ce808d0995e 1060 showButton(2,0," 3",sTemp2,4,4);
garygid 53:6ce808d0995e 1061 showButton(0,1," 4",sTemp2,4,4);
garygid 53:6ce808d0995e 1062 showButton(1,1," 5",sTemp2,4,4);
garygid 53:6ce808d0995e 1063 showButton(2,1," 6",sTemp2,4,4);
garygid 53:6ce808d0995e 1064 showButton(0,2," 7",sTemp2,4,4);
garygid 53:6ce808d0995e 1065 showButton(1,2," 8",sTemp2,4,4);
garygid 53:6ce808d0995e 1066 showButton(2,2," 9",sTemp2,4,4);
garygid 53:6ce808d0995e 1067 showButton(1,3," 0",sTemp2,4,4);
garygid 53:6ce808d0995e 1068
garygid 53:6ce808d0995e 1069 showButton(0,3,"<--",sTemp2,4,4);
garygid 53:6ce808d0995e 1070 showButton(2,3,"-->",sTemp2,4,4);
garygid 53:6ce808d0995e 1071 showButton(3,3,"return",sTemp2,4,4);
TickTock 42:4533b13b297d 1072 case 3:
TickTock 42:4533b13b297d 1073 break;
TickTock 42:4533b13b297d 1074 default:
TickTock 42:4533b13b297d 1075 break;
TickTock 42:4533b13b297d 1076 }
TickTock 36:dbd39c315258 1077 }
TickTock 36:dbd39c315258 1078 }
TickTock 36:dbd39c315258 1079
garygid 58:4d06288d75a2 1080 //---------------------
garygid 58:4d06288d75a2 1081 // gg - highlight
TickTock 62:ffd15edb5431 1082 void highlightButton(unsigned char column, unsigned char row, unsigned char tScn, unsigned char columns, unsigned char rows){
TickTock 62:ffd15edb5431 1083
garygid 58:4d06288d75a2 1084 unsigned short x1,x2,y1,y2;
garygid 58:4d06288d75a2 1085
garygid 58:4d06288d75a2 1086 x1=column*(320/columns)+btnGap/2;
garygid 58:4d06288d75a2 1087 x2=(column+1)*(320/columns)-btnGap/2;
garygid 58:4d06288d75a2 1088 y1=row*(240/rows)+btnGap/2;
garygid 58:4d06288d75a2 1089 y2=(row+1)*(240/rows)-btnGap/2;
garygid 64:821fc79cd7fe 1090
garygid 64:821fc79cd7fe 1091 tt.set_display(tScn);
garygid 64:821fc79cd7fe 1092
garygid 64:821fc79cd7fe 1093 if( skin == ggSkin ){
garygid 64:821fc79cd7fe 1094 // paint the whole button box, for a better visual effect
garygid 64:821fc79cd7fe 1095 // especially on a screen with a yellow background
garygid 64:821fc79cd7fe 1096 if( tScn == 0 )
garygid 64:821fc79cd7fe 1097 tt.fillrect(x1,y1,x2,y2,White); // DarkCyan);
garygid 64:821fc79cd7fe 1098 else
garygid 64:821fc79cd7fe 1099 tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
TickTock 67:b7476ce7a59e 1100 } else {
TickTock 67:b7476ce7a59e 1101 tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
garygid 64:821fc79cd7fe 1102 }
garygid 58:4d06288d75a2 1103
garygid 58:4d06288d75a2 1104 // paint the outer pixel as a yellow frame
garygid 58:4d06288d75a2 1105 tt.rect(x1,y1,x2,y2,Yellow) ; // DarkCyan);
garygid 58:4d06288d75a2 1106 }
garygid 58:4d06288d75a2 1107
garygid 58:4d06288d75a2 1108 //---------------------
TickTock 36:dbd39c315258 1109 void showButton(unsigned char column, unsigned char row, char * text1, char * text2, unsigned char columns, unsigned char rows){
TickTock 36:dbd39c315258 1110 unsigned short x1,x2,y1,y2;
garygid 53:6ce808d0995e 1111
TickTock 36:dbd39c315258 1112 x1=column*(320/columns)+btnGap/2;
TickTock 36:dbd39c315258 1113 x2=(column+1)*(320/columns)-btnGap/2;
TickTock 36:dbd39c315258 1114 y1=row*(240/rows)+btnGap/2;
TickTock 36:dbd39c315258 1115 y2=(row+1)*(240/rows)-btnGap/2;
TickTock 36:dbd39c315258 1116 tt.fillrect(x1,y1,x2,y2,DarkCyan);
garygid 53:6ce808d0995e 1117
garygid 53:6ce808d0995e 1118 // adapt formatting of text to the smaller 4x4 box
garygid 53:6ce808d0995e 1119 tt.locate(x1+btnGap/2,y1+btnGap); // gg - 4x4
TickTock 36:dbd39c315258 1120 printf("%s\n",text1);
garygid 53:6ce808d0995e 1121
garygid 53:6ce808d0995e 1122 tt.locate(x1+btnGap/2,y1+btnGap+20);
TickTock 36:dbd39c315258 1123 printf("%s\n",text2);
TickTock 36:dbd39c315258 1124 }
garygid 53:6ce808d0995e 1125
garygid 53:6ce808d0995e 1126 //-------------
TickTock 41:8d4609ea7259 1127 // below is braking screen normalized to power rather than force
TickTock 41:8d4609ea7259 1128 // changed to force since power had too large a dynamic range
TickTock 42:4533b13b297d 1129 /*void braking (bool force, bool showButtons, bool prdata=false){
TickTock 23:cd03f9c3395e 1130 unsigned long targetBraking, regenBraking, speed;
TickTock 27:6bd073c33977 1131 static unsigned long maxTarget = 20000, maxRegen = 20000, tarDivReg = 1000;
TickTock 13:62e0f7f39ff5 1132 short rpm;
TickTock 13:62e0f7f39ff5 1133 unsigned long temp;
TickTock 13:62e0f7f39ff5 1134 static unsigned char lastPressure[4] = {200,200,200,200};
TickTock 13:62e0f7f39ff5 1135 unsigned char i,r,t;
TickTock 13:62e0f7f39ff5 1136 static unsigned char lr, lt;
TickTock 13:62e0f7f39ff5 1137 CANMessage msg;
TickTock 13:62e0f7f39ff5 1138
TickTock 13:62e0f7f39ff5 1139 msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
TickTock 13:62e0f7f39ff5 1140 regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
TickTock 13:62e0f7f39ff5 1141 targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
TickTock 13:62e0f7f39ff5 1142 msg = lastMsg[indexLastMsg[0x176]]; //Get rpms - not sure what this is but scales to mph with .0725
TickTock 13:62e0f7f39ff5 1143 rpm = ((short)msg.data[0]<<8)+msg.data[1];
TickTock 13:62e0f7f39ff5 1144 speed =rpm>0?rpm>>3:-rpm>>3; //Take absolute to get speed; div8
TickTock 23:cd03f9c3395e 1145 if ((targetBraking>2039)||(speed>200)) { //Filter weird messages
TickTock 23:cd03f9c3395e 1146 targetBraking = 0;
TickTock 23:cd03f9c3395e 1147 regenBraking = 0;
TickTock 23:cd03f9c3395e 1148 } else {
TickTock 23:cd03f9c3395e 1149 if ((targetBraking>50)&&(regenBraking>50)){
TickTock 23:cd03f9c3395e 1150 temp = targetBraking;
TickTock 23:cd03f9c3395e 1151 temp *= 1000;
TickTock 23:cd03f9c3395e 1152 temp /= regenBraking;
TickTock 23:cd03f9c3395e 1153 if (temp<tarDivReg) tarDivReg=temp;
TickTock 23:cd03f9c3395e 1154 }
TickTock 23:cd03f9c3395e 1155 targetBraking *= speed;
TickTock 23:cd03f9c3395e 1156 regenBraking *= speed;
TickTock 23:cd03f9c3395e 1157 if (targetBraking>maxTarget) maxTarget=targetBraking;
TickTock 23:cd03f9c3395e 1158 if (regenBraking>maxRegen) maxRegen=regenBraking;
TickTock 23:cd03f9c3395e 1159 }
TickTock 23:cd03f9c3395e 1160
TickTock 13:62e0f7f39ff5 1161 msg = lastMsg[indexLastMsg[0x1ca]]; //Get brake pressure
TickTock 13:62e0f7f39ff5 1162 tt.background(Navy);
TickTock 13:62e0f7f39ff5 1163 if (force) {
TickTock 13:62e0f7f39ff5 1164 tt.cls();
TickTock 13:62e0f7f39ff5 1165 tt.rect(0,111,170,239,White);
TickTock 13:62e0f7f39ff5 1166 tt.line(0,207,170,207,White);
TickTock 13:62e0f7f39ff5 1167 tt.line(0,175,170,175,White);
TickTock 13:62e0f7f39ff5 1168 tt.line(0,143,170,143,White);
TickTock 13:62e0f7f39ff5 1169 lastPressure[0] = 200;
TickTock 13:62e0f7f39ff5 1170 lastPressure[1] = 200;
TickTock 13:62e0f7f39ff5 1171 lastPressure[2] = 200;
TickTock 13:62e0f7f39ff5 1172 lastPressure[3] = 200;
TickTock 13:62e0f7f39ff5 1173 }
TickTock 13:62e0f7f39ff5 1174 // plot bar graph for each wheel pressure
TickTock 13:62e0f7f39ff5 1175 for (i=0; i<4; i++){
TickTock 13:62e0f7f39ff5 1176 if (msg.data[i]<239) {
TickTock 13:62e0f7f39ff5 1177 if (msg.data[i]>lastPressure[i]){
TickTock 13:62e0f7f39ff5 1178 tt.fillrect(10+40*i,239-msg.data[i],40+40*i,239,Red);
TickTock 13:62e0f7f39ff5 1179 } else if (msg.data[i]<lastPressure[i]) {
TickTock 13:62e0f7f39ff5 1180 tt.fillrect(10+40*i,238-lastPressure[i],40+40*i,238-msg.data[i],Navy);
TickTock 13:62e0f7f39ff5 1181 }
TickTock 13:62e0f7f39ff5 1182 lastPressure[i]=msg.data[i];
TickTock 13:62e0f7f39ff5 1183 }
TickTock 13:62e0f7f39ff5 1184 }
TickTock 13:62e0f7f39ff5 1185
TickTock 27:6bd073c33977 1186 temp = targetBraking;
TickTock 27:6bd073c33977 1187 temp *=200;
TickTock 27:6bd073c33977 1188 temp /= maxTarget;
TickTock 27:6bd073c33977 1189 t = (char) temp;
TickTock 27:6bd073c33977 1190 if (t>200) t=200;
TickTock 27:6bd073c33977 1191 temp = regenBraking;
TickTock 27:6bd073c33977 1192 temp *= tarDivReg;
TickTock 27:6bd073c33977 1193 temp /= maxTarget;
TickTock 27:6bd073c33977 1194 temp /= 5;
TickTock 27:6bd073c33977 1195 r = (char) temp;
TickTock 27:6bd073c33977 1196 if (r>200) r=200;
TickTock 27:6bd073c33977 1197 if(lr!=r&&prdata){
TickTock 27:6bd073c33977 1198 tt.foreground(Yellow);
TickTock 27:6bd073c33977 1199 tt.set_font((unsigned char*) Arial28x28);
TickTock 27:6bd073c33977 1200 tt.locate(100,40);
TickTock 27:6bd073c33977 1201 printf("%d %d \n",regenBraking,maxRegen);
TickTock 27:6bd073c33977 1202 tt.locate(100,70);
TickTock 27:6bd073c33977 1203 printf("%3.1f (%3.1f%s) \n",(float)tarDivReg/10,(float)regenBraking*tarDivReg/targetBraking/10,"%");
TickTock 27:6bd073c33977 1204 }
TickTock 27:6bd073c33977 1205 if(lt!=t&&prdata){
TickTock 27:6bd073c33977 1206 tt.foreground(Yellow);
TickTock 27:6bd073c33977 1207 tt.set_font((unsigned char*) Arial28x28);
TickTock 27:6bd073c33977 1208 tt.locate(100,10);
TickTock 27:6bd073c33977 1209 printf("%d %d \n",targetBraking,maxTarget);
TickTock 13:62e0f7f39ff5 1210 }
TickTock 27:6bd073c33977 1211 if (r>t) t=r; //Should never happen
TickTock 27:6bd073c33977 1212 if((lr!=r||lt!=t)&&!prdata){
TickTock 27:6bd073c33977 1213 tt.fillrect(200,10,300,239-t,Navy);
TickTock 27:6bd073c33977 1214 tt.fillrect(200,239-t,300,239-r,Red);
TickTock 27:6bd073c33977 1215 tt.fillrect(200,239-r,300,239,Green);
TickTock 27:6bd073c33977 1216 }
TickTock 27:6bd073c33977 1217 lt=t;
TickTock 27:6bd073c33977 1218 lr=r;
TickTock 36:dbd39c315258 1219 }*/