Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Revision 138:a2f5af85ed0d, committed 2013-08-02
- Comitter:
- TickTock
- Date:
- Fri Aug 02 05:13:26 2013 +0000
- Parent:
- 137:70853cf5a30f
- Child:
- 139:ac227b203ef2
- Commit message:
- Fixed metric DTE formatting
Changed in this revision
--- a/TOUCH_TFTx2.lib Sun Jul 28 05:32:17 2013 +0000 +++ b/TOUCH_TFTx2.lib Fri Aug 02 05:13:26 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/TickTock/code/TOUCH_TFTx2/#220e3da2dd00 +http://mbed.org/users/TickTock/code/TOUCH_TFTx2/#c58c98c5020a
--- a/displayModes.cpp Sun Jul 28 05:32:17 2013 +0000
+++ b/displayModes.cpp Fri Aug 02 05:13:26 2013 +0000
@@ -7,9 +7,10 @@
void mainDisplay (bool force, bool showButtons){
unsigned short gids, SOC_x10, packV_x2, tireP;
float useable_kWh,dte;
+ //unsigned char aTemp,c1Temp,c2Temp;
static unsigned short lgids=0, lSOC=0, lpackV_x2=0, ltireP=0, maxPS=0;
- static float lmaxTemp=0;
- static float lkW=0, laccV=0, lmpkWh=0;
+ //static unsigned char laTemp=0,lc1Temp=0,lc2Temp=0;
+ static float lmaxTemp=0, lkW=0, laccV=0, lmpkWh=0;
CANMessage msg;
@@ -19,6 +20,10 @@
SOC_x10 = (msg.data[0]<<2)+(msg.data[1]>>6);
msg = lastMsg[indexLastMsg[0x1db]]; //Get pack volts
packV_x2 = (msg.data[2]<<2)+(msg.data[3]>>6);
+ //msg = lastMsg[indexLastMsg[0x79a]]; //Get ambient and cabin temperature
+ //aTemp = msg.data[5]-41; // Need to add convertsion to C if metric
+ //c1Temp = msg.data[4]-41;
+ //c2Temp = msg.data[6]-41;
msg = lastMsg[indexLastMsg[0x385]]; //Get tire pressure
tireP = msg.data[2]+msg.data[3]+msg.data[4]+msg.data[5];
@@ -46,7 +51,7 @@
// Display DTE
dte=convertDistance(minTripEff*useable_kWh);
tt.foreground(Green);
- tt.locate(30,80);
+ tt.locate(20,80);
if(dte>=10){
printf("%2.0f \n",dte); //LM - add metric conversion
}else{
@@ -61,25 +66,29 @@
}
// " "=0x10, "."=0x15, #=0x1D
if(dte>=100){
- tt.locate(75,85);
- printf(" %2.0f\n",dte); //LM - add metric conversion
+ tt.locate(80,85);
+ printf(" %3.0f\n",dte); //LM - add metric conversion
}else if(dte>=10){
- tt.locate(89,85);
+ tt.locate(94,85);
printf(" %2.0f\n",dte); //LM - add metric conversion
}else{
- tt.locate(84,85);
+ tt.locate(89,85);
printf(" %2.1f\n",dte); //LM - add metric conversion
}
tt.set_font((unsigned char*) Arial28x28);
- tt.locate(190,106);
+ tt.locate(195,106);
printf("%s\n",distanceUnit()); //LM - add metric conversion
dte=convertDistance(maxTripEff*useable_kWh);
tt.foreground(Orange);
- tt.locate(260,80);
- if(dte>=10){
+ if(dte>=100){
+ tt.locate(255,80);
+ printf("%3.0f \n",dte); //LM - add metric conversion
+ }else if(dte>=10){
+ tt.locate(270,80);
printf("%2.0f \n",dte); //LM - add metric conversion
}else{
+ tt.locate(265,80);
printf("%2.1f \n",dte); //LM - add metric conversion
}
lgids=gids;
@@ -115,13 +124,20 @@
lpackV_x2=packV_x2;
ltireP=0;//Force tire pressure redraw, too
}
+ /*if(force||aTemp!=laTemp){
+ tt.foreground(Cyan);
+ tt.locate(10,146);
+ printf("%d %d %d\n",aTemp,c1Temp,c2Temp);
+ laTemp=aTemp;
+ lc1Temp=c1Temp;
+ lc2Temp=c2Temp;
+ }*/
if(force||maxTemp!=lmaxTemp){
tt.foreground(Cyan);
+ tt.locate(210,146);
if (convertTemperature(maxTemp)<100){
- tt.locate(210,146);
printf(" %3.1f%s\n",convertTemperature(maxTemp),temperatureUnit());
}else{
- tt.locate(210,146);
printf("%4.1f%s\n",convertTemperature(maxTemp),temperatureUnit());
}
lmaxTemp=maxTemp;
@@ -723,20 +739,20 @@
nBar[i] *= nBarScale ; // scale, as needed
}
+ // label the X axis (approximate)
+ //tt.locate( 2, yWinMin-14 ); printf("%04d = %04d from %1.4f", max, int( height / nBarScale ) + min, nBarScale );
+ tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.\n", max , max - min );
+ tt.locate( 2, yWinMax+5); printf("%04d\n", min );
// values, for now
// BatDataBaseG4 * 7 = 280
tt.locate( 0, yWinMax+40 );
char* sTemperatureUnit = temperatureUnit();
- 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",
+ 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",
max,min,avg,jv, convertTemperature(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+8]),sTemperatureUnit,
convertTemperature(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+14]),sTemperatureUnit);
//printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",
// max,min,avg,jv, battData[BatDataBaseG4*7+5],battData[BatDataBaseG4*7+8], battData[BatDataBaseG4*7+11],battData[BatDataBaseG4*7+14]);
- // label the X axis (approximate)
- tt.locate( 2, yWinMax+5); printf("%04d", min );
- //tt.locate( 2, yWinMin-14 ); printf("%04d = %04d from %1.4f", max, int( height / nBarScale ) + min, nBarScale );
- tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.", max , max - min );
//---------------
// show the bars
--- a/main.cpp Sun Jul 28 05:32:17 2013 +0000
+++ b/main.cpp Fri Aug 02 05:13:26 2013 +0000
@@ -10,9 +10,10 @@
// * Subtract accessory power from efficiency history (add back in when displaying)
// * Add trip history display
-// rev137
+// rev138
// Added update if screen touched on power
// Fixed hang on immediate USB access
+// Fixed metric DTE formatting
#include "mbed.h"
#include "CAN.h"
@@ -24,7 +25,7 @@
#include "displayModes.h"
#include "TOUCH_TFTx2.h"
-char revStr[7] = "137"; // gg - revision string, max 6 characters
+char revStr[7] = "138"; // gg - revision string, max 6 characters
FATFS USBdrive;
LocalFileSystem local("local");
@@ -547,8 +548,8 @@
playback.attach(&playbackISR,playbackInt);
printMsg("Starting playback\n"); // start playback
spkr.beep(2000,0.25);
- can1.attach(NULL);// Stop recieving CAN data
- can2.attach(NULL);
+ can1.attach(NULL);// Stop recieving EVCAN data
+ can2.attach(NULL);// Stop recieving CARCAN data
}
} else {
printMsg("Must stop logging first\n");
@@ -558,8 +559,8 @@
f_close(&efile);
playbackOpen=false;
playbackEn=false;
- can1.attach(&recieve1);// Restore CAN data recieve
- can2.attach(&recieve2);
+ can1.attach(&recieve1);// Restore EVCAN data recieve
+ can2.attach(&recieve2);// Restore EVCAN data recieve
lastDMode[whichTouched]=99;
}
} else if (dMode[whichTouched]==dateScreen){
@@ -742,7 +743,6 @@
}
}
laccOn=accOn;
- //if(!accOn&&!logEn&&userIdle&&!playbackEn){ // Car off and logging disabled and no user activity
if(!accOn&&userIdle&&!playbackEn){ // Car off and no user activity - turn off screen
dled = 0;
if (saveDmode<99){
@@ -759,6 +759,7 @@
if (repeatPoll&&(wait5secs==0)) { // Poll on startup if autopoll enabled
logOnce=true;
reqMsgCnt=0;
+ //sendTempReq();
msgReq.attach(&sendReq,0.015);
}
lastDMode[0]=99;
--- a/mbed.bld Sun Jul 28 05:32:17 2013 +0000 +++ b/mbed.bld Fri Aug 02 05:13:26 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6 \ No newline at end of file
--- a/utility.cpp Sun Jul 28 05:32:17 2013 +0000
+++ b/utility.cpp Fri Aug 02 05:13:26 2013 +0000
@@ -28,7 +28,7 @@
}
void touch_ISR(){
- //LPC_GPIOINT->IO2IntClr = (LPC_GPIOINT->IO2IntStatR | LPC_GPIOINT->IO2IntStatF); // seems to work without so maybe not necessary (performed inInterruptIn handler?)
+ //LPC_GPIOINT->IO2IntClr = (LPC_GPIOINT->IO2IntStatR | LPC_GPIOINT->IO2IntStatF); // seems to work without so maybe not necessary (performed in InterruptIn handler?)
touched=true; // just set flag - touch screen algorythm is long and we don't want to block other interrupts
}
@@ -393,8 +393,8 @@
if(reqMsgCnt<99){
switch (reqMsgCnt){
case BatDataBaseG1:
- can1.monitor(false); // set to active mode
- can1SleepMode = 0; // enable TX
+ can2.monitor(false); // set to active mode
+ can2SleepMode = 0; // enable TX
data[0]=0x02; //change to request group 1
data[1]=0x21;
data[2]=0x01;
@@ -426,23 +426,30 @@
break;
case BatDataBaseG7: // group 5 has 11 frames
reqMsgCnt = 99;
- can1SleepMode = VP230Sleep; // disable TX
- can1.monitor(true); // set to snoop mode
+ can2SleepMode = VP230Sleep; // disable TX
+ can2.monitor(true); // set to snoop mode
msgReq.detach(); // stop ticker
default:
data[0]=0x30; //change to request next line message
data[1]=0x01;
data[2]=0x00;
}
- can1.write(CANMessage(0x79b, data, 8));
+ can2.write(CANMessage(0x79b, data, 8));
reqMsgCnt++;
}
}
+void sendTempReq(){
+ //Requests ambient and cabin temperature
+ char data[8] = {0x03, 0x22, 0x11, 0x5d, 0xff, 0xff, 0xff, 0xff};
+ can2.monitor(false); // set to active mode
+ can2SleepMode = 0; // enable TX
+ can2.write(CANMessage(0x797, data, 8));
+ can2SleepMode = VP230Sleep; // disable TX
+}
+
void autoPollISR(){
- //char sTemp[40]; // just for debug
- //sprintf(sTemp,"Requesting cp data\n"); // just for debug
- //printMsg(sTemp); // just for debug
+ //sendTempReq();
reqMsgCnt = 0; //reset message counter
msgReq.attach(&sendReq,0.015);
}
--- a/utility.h Sun Jul 28 05:32:17 2013 +0000
+++ b/utility.h Fri Aug 02 05:13:26 2013 +0000
@@ -81,9 +81,8 @@
unsigned short getTimeStamp();
void logCan (char mType, CANMessage canRXmsg);
void logTS ();
- void logEvent (char * errMsg); // gg - messeges
- //void sendCPreq();
- //void sendTreq();
+ void logEvent (char * errMsg); // gg - messeges
+ void sendTempReq();
void sendReq();
void autoPollISR();
void playbackISR();
