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 164:46ed06263b0e, committed 2013-11-28
- Comitter:
- TickTock
- Date:
- Thu Nov 28 03:23:30 2013 +0000
- Parent:
- 163:3b6fab958773
- Child:
- 165:4daa921730dd
- Commit message:
- // Turn off noCC DTE when CC is off
Changed in this revision
--- a/displayModes.cpp Fri Nov 22 04:21:54 2013 +0000
+++ b/displayModes.cpp Thu Nov 28 03:23:30 2013 +0000
@@ -45,7 +45,7 @@
// worse-case DTE
dte=convertDistance(minTripEff*useable_kWh); //LM - add metric conversion
tt.foreground(Green);
- tt.locate(20,80);
+ tt.locate(20,90);
if(dte>=9.5){
printf("%2.0f \n",dte);
}else{
@@ -77,34 +77,35 @@
// No Climate Control DTE
tt.set_font((unsigned char*) Arial24x23);
tt.foreground(Green);
- dte=convertDistance(mpkWh_noCC*useable_kWh); //LM - add metric conversion
- if(dte>199){
- dte=199;
+ if(CCon) {
+ dte=convertDistance(mpkWh_noCC*useable_kWh); //LM - add metric conversion
+ if(dte>199){
+ dte=199;
+ }
+ // " "=13, "."=5, #=17
+ if(dte>=99.5){
+ tt.locate(120,134);
+ printf(" %3.0f\n",dte);
+ }else if(dte>=9.5){
+ tt.locate(111,134);
+ printf(" %2.0f\n",dte);
+ }else{
+ tt.locate(111,134);
+ printf(" %2.1f\n",dte);
+ }
}
- // " "=13, "."=5, #=17
- if(dte>=99.5){
- tt.locate(120,134);
- printf(" %3.0f\n",dte);
- }else if(dte>=9.5){
- tt.locate(111,134);
- printf(" %2.0f\n",dte);
- }else{
- tt.locate(111,134);
- printf(" %2.1f\n",dte);
- }
-
// best-case DTE
tt.set_font((unsigned char*) Arial28x28);
dte=convertDistance(maxTripEff*useable_kWh); //LM - add metric conversion
tt.foreground(Orange);
if(dte>=99.5){
- tt.locate(255,80);
+ tt.locate(255,90);
printf("%3.0f \n",dte);
}else if(dte>=9.5){
- tt.locate(270,80);
+ tt.locate(270,90);
printf("%2.0f \n",dte);
}else{
- tt.locate(265,80);
+ tt.locate(265,90);
printf("%2.1f \n",dte);
}
lgids=gids;
@@ -127,6 +128,12 @@
printf(" %4.2fkW\n",total_kW);
}
lkW=total_kW;
+ if(CCon){
+ tt.set_font((unsigned char*) Arial12x12);
+ tt.locate(232,70);
+ printf(" %3.2fkW\n",CCkW);
+ tt.set_font((unsigned char*) Arial28x28);
+ }
}
if(force||SOC_x10!=lSOC){
tt.locate(215,10);
@@ -1192,7 +1199,7 @@
//x=50+38*6;
//tt.line(x,60,x,220,DarkGrey);
tt.set_font((unsigned char*) SCProSB31x55);
- tt.foreground(Green);
+ tt.foreground(Yellow);
if (showMiles){
float miles = mpkWh[dtePeriod]*((float)(gids-5)*.075);
miles = convertDistance(miles); // LM - Metric support
@@ -1207,28 +1214,32 @@
tt.locate(151,1);
printf(" %2.1f\n",miles);
}
- tt.foreground(Cyan);
- tt.set_font((unsigned char*) Arial24x23);
- miles = mpkWh_noCC*((float)(gids-5)*.075);
- miles = convertDistance(miles); // LM - Metric support
- // Right justify
- if (miles>99.9){ //space=13; num=17; . = 5
- tt.locate(191,52);
- printf("%4.1f\n",miles);
- } else if (miles>9.9){
- tt.locate(182,52);
- printf(" %3.1f\n",miles);
- } else {
- tt.locate(173,52);
- printf(" %2.1f\n",miles);
+ if(CCon) {
+ tt.foreground(Green);
+ tt.set_font((unsigned char*) Arial24x23);
+ miles = mpkWh_noCC*((float)(gids-5)*.075);
+ miles = convertDistance(miles); // LM - Metric support
+ // Right justify
+ if (miles>99.9){ //space=13; num=17; . = 5
+ tt.locate(191,52);
+ printf("%4.1f\n",miles);
+ } else if (miles>9.9){
+ tt.locate(182,52);
+ printf(" %3.1f\n",miles);
+ } else {
+ tt.locate(173,52);
+ printf(" %2.1f\n",miles);
+ }
}
} else {
tt.locate(200,1);
printf("%3.1f \n",mpkWh[dtePeriod]);
- tt.foreground(Cyan);
- tt.set_font((unsigned char*) Arial24x23);
- tt.locate(240,52);
- printf("%3.1f \n",mpkWh_noCC);
+ if(CCon) {
+ tt.foreground(Green);
+ tt.set_font((unsigned char*) Arial24x23);
+ tt.locate(240,52);
+ printf("%3.1f \n",mpkWh_noCC);
+ }
}
lx=50;
ly=mpkWh[0]*40;
@@ -1307,9 +1318,9 @@
if (r>160) r=160;
if (r>t) t=r; //Should never happen
if(lr!=r||lt!=t){
- tt.fillrect(264,239-160,310,239-t,Navy);
- tt.fillrect(264,239-t,310,239-r,Red);
- tt.fillrect(264,239-r,310,239,Green);
+ if (t<160) tt.fillrect(264,239-160,310,238-t,Navy);
+ if (r<t) tt.fillrect(264,239-t,310,238-r,Red);
+ if (0<r) tt.fillrect(264,239-r,310,238,Green);
}
lt=t;
lr=r;
@@ -1375,7 +1386,7 @@
void updateDisplay(char display){
bool changed,showButtons;
- changed = dMode[display]!=lastDMode[display];
+ changed = (dMode[display]!=lastDMode[display]);
showButtons = (display==whichTouched)&&(sMode==1);
tt.set_display(display);
switch (dMode[display]) {
--- a/displayModes.h Fri Nov 22 04:21:54 2013 +0000
+++ b/displayModes.h Thu Nov 28 03:23:30 2013 +0000
@@ -43,6 +43,7 @@
extern unsigned char skin;
extern unsigned char dtePeriod;
extern bool tock;
+extern bool refresh;
extern DigitalOut led4;
extern unsigned char tNavRow; // gg - 4x4
extern unsigned short pointerSep; // log write buffer pointer separation
@@ -72,6 +73,7 @@
extern bool autoSync;
extern bool clearTest;
extern float CCkW;
+extern bool CCon;
extern "C" {
void printLast (bool force, bool showButtons);
--- a/main.cpp Fri Nov 22 04:21:54 2013 +0000
+++ b/main.cpp Thu Nov 28 03:23:30 2013 +0000
@@ -6,10 +6,10 @@
// * Add in-device config editor
// * Change pack volt color when CVLI fails
// * Add tire pressure cal (40psi for me = FR 38, RR 38.2, FL 37.8, RL 38 - maybe 2psi error on my tire gauge?)
+// * Add on screen messages for heater on, etc, and use refresh feature above to clear in x seconds
-// rev163
-// Fixed efficiency screen discontinuity when CC power changes
-// Added DTE & efficiency w/o CC to efficiency display
+// rev164
+// Turn off noCC DTE when CC is off
#include "mbed.h"
#include "CAN.h"
@@ -19,7 +19,7 @@
#include "utility.h"
#include "displayModes.h"
#include "TOUCH_TFTx2.h"
-char revStr[7] = "163"; // gg - revision string, max 6 characters
+char revStr[7] = "164"; // gg - revision string, max 6 characters
FATFS USBdrive;
LocalFileSystem local("local");
@@ -63,6 +63,8 @@
bool syncDone = true;
bool heaterOn = false;
bool lHeaterOn = false;
+bool CCon = false;
+bool lCCon = false;
FILE *hfile; // history file
FIL efile; // external usb file
@@ -741,7 +743,17 @@
if(tick){ // Executes once a second
tick=false;
+ lCCon = CCon;
CCkW = (lastMsg[indexLastMsg[0x510]].data[3]&0x7f)*0.125;
+ if(lastMsg[indexLastMsg[0x510]].data[3]&0x80){
+ CCon=true; // On when button pushed
+ } else if(CCkW==0) {
+ CCon=false; // Off when power drops back to zero
+ }
+ if(!CCon && lCCon){
+ lastDMode[0]=99;//force refresh
+ lastDMode[1]=99;//force refresh
+ }
if (miles_trip[0]>0.25) {
curEff = miles_trip[0]/kWh_trip[0];
} else {
@@ -828,11 +840,10 @@
if (repeatPoll&&(wait5secs==0)) { // Poll on startup if autopoll enabled
logOnce=true;
reqMsgCnt=0;
- //sendTempReq();
msgReq.attach(&sendReq,0.015);
+ lastDMode[0]=99;
+ lastDMode[1]=99;
}
- lastDMode[0]=99;
- lastDMode[1]=99;
}
//remove health screen once moving
