test fork

Dependencies:   SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary_9341 by Tick Tock

Revision:
49:a3d2c5bb3cfa
Parent:
48:d1ce92104a1f
Child:
50:83d5864c64a0
--- a/displayModes.cpp	Sat Apr 06 04:18:49 2013 +0000
+++ b/displayModes.cpp	Sun Apr 07 08:29:04 2013 +0000
@@ -79,7 +79,7 @@
 void mainDisplay (bool force, bool showButtons){
     unsigned short gids, SOC, packV;
     static unsigned short lgids=0, lSOC=0, lpackV=0;
-    static float lkW=0, laccV=0;;
+    static float lkW=0, laccV=0, lmpkWh=0;
     CANMessage msg;
 
     msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
@@ -94,16 +94,17 @@
     tt.set_font((unsigned char*) Arial28x28);
     if(force) tt.cls();
     if(skin==ttSkin){
-        if(force||gids!=lgids){
+        if(force||gids!=lgids||mpkWh[9]!=lmpkWh){
             tt.locate(10,10);
             printf("%4d gids \n",gids);
-            tt.locate(20,40);
-            printf("%4.1f kWh  \n",(float)gids*0.08);
+            tt.locate(10,40);
+            printf("%4.1f kWh \n",(float)(gids-5)*0.075);
             tt.set_font((unsigned char*) SCProSB31x55);
             tt.foreground(Green);
             tt.locate(60,96);
-            printf("%4.1f mi  \n",(float)(gids-5)*0.31); // Approx for now
+            printf("%4.1f mi  \n",mpkWh[9]*((float)(gids-5)*.075)); // Use 1 minute average
             lgids=gids;
+            lmpkWh-mpkWh[9];
             tt.foreground(Yellow);
             tt.set_font((unsigned char*) Arial28x28);
         }
@@ -122,10 +123,11 @@
             printf("%3.1fV  \n",accV);
             laccV=accV;
         }
-        if(force||kW!=lkW){
+        if(force||kW[0]!=lkW){
             tt.locate(180,40);
-            printf("%3.2fkW  \n",kW);
-            lkW=kW;
+            printf("%3.2fkW  \n",kW[0]);
+            //printf("%3.1f mpkWh  \n",mpkWh[0]);
+            lkW=kW[0];
         }
     }else {//if(skin==ggSkin){
         if(force||gids!=lgids){
@@ -163,10 +165,10 @@
             printf("%3.1fV  \n",accV);
             laccV=accV;
         }
-        if(force||kW!=lkW){
+        if(force||kW[0]!=lkW){
             tt.locate(160,40); // gg - move left to keep from wrap
-            printf("%3.2fkw \n",kW); // use small w to save space
-            lkW=kW;
+            printf("%3.2fkw \n",kW[0]); // use small w to save space
+            lkW=kW[0];
         }
     }
 }
@@ -726,19 +728,67 @@
 }
 
 void dteDisplay(bool force, bool showButtons){
-    static float lmpkWh=0;
-    static float lMPH=0;
+    unsigned short i,x,y,lx,ly;
     tt.background(Navy);
-    if(force) tt.cls();
-    if(force||mpkWh!=lmpkWh||MPH!=lMPH){
-        tt.foreground(Yellow);
-        tt.set_font((unsigned char*) Arial28x28);
-        tt.locate(10,200);
-        printf("%3.1f  \n",MPH);
-        tt.locate(200,200);
-        printf("%3.1f   \n",mpkWh);
-        lmpkWh=mpkWh;
-        lMPH=MPH;
+    tt.foreground(Yellow);
+    if(force||updateDTE){
+        tt.cls();
+        tt.set_font((unsigned char*) Arial12x12);
+        for(i=0;i<10;i++){
+            y=200-i*20;
+            tt.locate(10,y-8);
+            printf("%d.0\n",i);
+            tt.line(40,y,280,y,LightGrey);
+        }
+
+        x=50+0*6;
+        tt.locate(x-8,226);
+        printf("sec\n");  
+        tt.line(x,10,x,220,LightGrey);     
+        x=50+9*6;
+        tt.locate(x-8,226);
+        printf("min\n");  
+        tt.line(x,10,x,220,LightGrey);     
+        x=50+18*6;
+        tt.locate(x-8,226);
+        printf("hour\n");  
+        tt.line(x,10,x,220,LightGrey);     
+        x=50+25*6;
+        tt.locate(x-8,226);
+        printf("day\n");  
+        tt.line(x,10,x,220,LightGrey);     
+        x=50+32*6;
+        tt.locate(x-8,226);
+        printf("mon\n");  
+        tt.line(x,10,x,220,LightGrey);     
+        x=50+38*6;
+        tt.locate(x-8,226);
+        printf("year\n");  
+        tt.line(x,10,x,220,LightGrey);     
+        
+        lx=50;
+        ly=mpkWh[0]*20;
+        if(ly<200) {
+            ly=200-ly;
+        }else{
+            ly=0;
+        }
+        tt.fillcircle(lx,ly,4,Green);
+
+        for(i=1;i<39;i++){
+            x=50+i*6;
+            y=mpkWh[i]*20;
+            if(y<200) {
+                y=200-y;
+            }else{
+                y=0;
+            }
+            tt.circle(x,y,2,Green);
+            tt.line(lx,ly,x,y,White);
+            lx=x;
+            ly=y;
+        }
+    updateDTE=false;
     }
 }