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_ILI9341 TFT_fonts TOUCH_TFTx2_ILI9341 mbed
Fork of CANary_corrupt by
Revision 181:396fdcceefd2, committed 2014-03-25
- Comitter:
- TickTock
- Date:
- Tue Mar 25 19:57:08 2014 +0000
- Parent:
- 180:5fdeeb86f3a3
- Child:
- 182:10017d74de67
- Commit message:
- // Added grid to whpg displays
Changed in this revision
| displayModes.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/displayModes.cpp Mon Mar 24 01:18:05 2014 +0000
+++ b/displayModes.cpp Tue Mar 25 19:57:08 2014 +0000
@@ -37,11 +37,14 @@
if (useable_kWh<0){
useable_kWh=0;
}
- tt.locate(181,4);
+ //tt.locate(181,4);
+ tt.locate(170,4); //LAJ temp
if (useable_kWh<9.95){
- printf("%3.2fkWh\n",useable_kWh);
+ //printf("%3.2fkWh\n",useable_kWh);
+ printf("%3.2f %3.2f\n",useable_kWh,(wh[gids]-400)/1000); //LAJ temp
} else {
- printf("%3.1fkWh\n",useable_kWh);
+ //printf("%3.1fkWh\n",useable_kWh);
+ printf("%3.1f %3.1f\n",useable_kWh,(wh[gids]-400)/1000); //LAJ temp
}
}
if(force||SOC_x10!=lSOC){
@@ -1444,9 +1447,9 @@
// find max/min/avg
if(showWh){
- for(i=0; i<300; i++){
+ for(i=0; i<299; i++){
if(wh[i]>0){
- j=(wh[i]-wh[i+1]);
+ j=(wh[i+1]-wh[i]);
avg+=j;
if(j>maxVal) maxVal=j;
if(j<minVal) minVal=j;
@@ -1455,7 +1458,7 @@
}
}
}else{
- for(i=0; i<300; i++){
+ for(i=0; i<299; i++){
if(whpg[i]>0){
j=(whpg[i]-whpg[i+1]);
avg+=j;
@@ -1481,30 +1484,24 @@
// draw the Frame, 2 pixels wide
tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1, Red);
tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2, Green);
+ // draw grid
+ for( i=20; i<yWinMax-yWinMin; i+=20){
+ tt.line(xWinMin,yWinMax-i,xWinMax,yWinMax-i,DarkGrey);
+ }
+ for( i=20; i<xWinMax-xWinMin; i+=20){
+ tt.line(xWinMin+i,yWinMin,xWinMin+i,yWinMax,DarkGrey);
+ }
//----------------
if( maxVal > minVal ) {
// label the Y axis
- tt.locate( 2, yWinMin-14); printf("200\n");
- tt.locate( 2, yWinMax+5); printf("0\n");
- tt.locate( 2, yWinMax-avg-18); printf("%3.1f\n", avg );
- tt.locate( 2, yWinMax-avg+2); printf("avg\n");
+ tt.locate( 2, yWinMin-6); printf("%d\n",yWinMax-yWinMin);
+ tt.locate( 2, yWinMax-6); printf("0\n");
+ //tt.locate( xWinMin+3, yWinMax-avg-6); printf("%3.1f avg\n", avg );
+ tt.locate( xWinMin+4, yWinMin+4); printf("%3.1f avg\n", avg );
for( i=4; i<=286; i++) {
- if(showWh){
- y = wh[i]-wh[i-1];
- tt.fillcircle(i+xWinMin,yWinMax-y,2,Green);
- }else{
- if((whpg[i-4]>0)&&(whpg[i+4]>0)){
- y = (whpg[i-4]-whpg[i+4])/4;
- }else{
- y = whpg[i];
- }
- if( (y>20) && (y<180) && whpg[i]>0){
- tt.fillcircle(i+xWinMin,yWinMax-y,2,Yellow);
- }
- }
if(i%40 == 0){
// label the x axis each 40
tt.line( i+xWinMin,yWinMax+2, i+xWinMin,yWinMax+8, White ); // a white tick mark
@@ -1518,6 +1515,19 @@
// tic mark the x axis each 10
tt.line( i+xWinMin,yWinMax+2, i+xWinMin,yWinMax+4, White ); // a white tick mark
}
+ if(showWh){
+ y = wh[i]-wh[i-1];
+ tt.fillcircle(i+xWinMin,yWinMax-y,2,Green);
+ }else{
+ if((whpg[i-4]>0)&&(whpg[i+4]>0)){
+ y = (whpg[i-4]-whpg[i+4])/8;
+ }else{
+ y = whpg[i];
+ }
+ if( (y>20) && (y<180) && whpg[i]>0){
+ tt.fillcircle(i+xWinMin,yWinMax-y,2,Yellow);
+ }
+ }
}
}
}
--- a/main.cpp Mon Mar 24 01:18:05 2014 +0000
+++ b/main.cpp Tue Mar 25 19:57:08 2014 +0000
@@ -11,8 +11,8 @@
// * Be more efficient with write buffer (use msgLen instead of always storing 8 bytes)
-// rev180
-// added wh lookup table with correction from whpg real use
+// rev181
+// Added grid to whpg displays
#include "mbed.h"
#include "CAN.h"
@@ -23,7 +23,7 @@
#include "displayModes.h"
#include "TOUCH_TFTx2.h"
-char revStr[7] = "180";
+char revStr[7] = "181";
unsigned long maxTarget = 1000;
FATFS USBdrive;
LocalFileSystem local("local");
@@ -237,7 +237,7 @@
printMsg(sTemp); // revision
for(i=0;i<300;i++){ // initialize wh lookup
- wh[i]=i*80;
+ wh[i]=i*kWperGid*1000;
}
//read efficiency history data
@@ -887,32 +887,35 @@
seconds = time(NULL);
t = *localtime(&seconds);
if((t.tm_yday>lt.tm_yday)&&(t.tm_hour>effCheckTime)&&(miles_trip[1]<1)){
- // Check and reset daily efficiency if charged since last trip
- if (!ignoreDayData&&(miles_trip[3]>25)){ // Ignore low mileage data
- curEff = miles_trip[3]/kWh_trip[3];
+ // Check and reset daily efficiency if charged since last trip and at least 24 hours has past
+ if (!ignoreDayData&&(miles_trip[3]>15)){ // Ignore low mileage data
+ curEff = miles_trip[3]/kWh_trip[3]; // Get current daily efficiency
if (maxTripEff<curEff) {
maxTripEff=curEff;
maxTripMiles=miles_trip[3];
maxTripkWh=kWh_trip[3];
maxTripCCkWh=CCkWh_trip[3];
+ printMsg("New max efficiency.\n");
}
if (minTripEff>curEff) {
minTripEff=curEff;
minTripMiles=miles_trip[3];
minTripkWh=kWh_trip[3];
minTripCCkWh=CCkWh_trip[3];
+ printMsg("New min efficiency.\n");
}
}
+ // Clear daily efficiency data
dailyGids=0;
miles_trip[3]=0;
kWh_trip[3]=0;
CCkWh_trip[3]=0;
ignoreDayData=false;
- lt=t; // Remember when counters were cleared
+ lt=t; // Remember when counters were cleared (start time for new data)
maxWhpg=0;
minWh=0;
whOff=0;
- // Adjust wh lookup with whpg data weighted 20% and clear array
+ // Adjust wh lookup with whpg data weighted 20%
for(i=1;i<300;i++){
if(whpg[i]>maxWhpg){
maxWhpg=whpg[i];
@@ -930,6 +933,8 @@
}
wh[i] /=5;
}
+ }
+ for(i=1;i<300;i++){ // clear array
whpg[i]=0;
}
}
