Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Sat Apr 13 22:46:31 2013 +0000
Parent:
67:2022fce701d0
Parent:
66:b7476ce7a59e
Child:
70:0700b769ac15
Commit message:
merged

Changed in this revision

displayModes.cpp Show annotated file Show diff for this revision Revisions of this file
displayModes.h 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/common.h	Thu Apr 11 18:52:12 2013 +0000
+++ b/common.h	Sat Apr 13 22:46:31 2013 +0000
@@ -23,8 +23,3 @@
 #define maxBufLen 512
 #define canTimeout 5
 #define userTimeout 15
-
-// gg - 4x4 touch
-// #define tNavRow = 2 ; // for 3x3
-extern unsigned char tNavRow ; // gg - 4x4
-
--- a/displayModes.cpp	Thu Apr 11 18:52:12 2013 +0000
+++ b/displayModes.cpp	Sat Apr 13 22:46:31 2013 +0000
@@ -191,7 +191,7 @@
     steering = (msg.data[1]<<8)+msg.data[0];
     
     if(skin==ttSkin){
-        s= (unsigned short) ((steering/10)+160)%310; // this modulo wraps display
+        s= (unsigned short) ((steering/10)+155)%310; // this modulo wraps display
     }else{// if(skin==ggSkin){    
         // do not go off screen left or right. gg - steering
         short ss = (short) ((steering/15)+160); // less gain 10 -> 15
@@ -751,8 +751,7 @@
                     break;
             }
             tt.background(DarkCyan);
-            showButton(0,1,sTemp1,"",4,4);    
-                       
+            showButton(0,1,sTemp1,"",4,4);                          
             showButton(1,1,"  UP","",4,4);               
             showButton(2,1," DOWN","",4,4);               
         }
@@ -760,10 +759,13 @@
 }
 
 void dteDisplay(bool force, bool showButtons, bool showMiles){
-    unsigned short i,x,y,lx,ly,gids,radius,color;
+    unsigned short i,x,y,lx,ly,gids,radius,color,r,t;
     static unsigned short lgids=0;
     static unsigned char leff[39]={0};
     CANMessage msg;
+    unsigned long targetBraking, regenBraking, temp;
+    static unsigned long maxTarget = 1000, maxRegen = 1000, tarDivReg = 1000;
+    static unsigned char lr=0, lt=0;
 
     msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
     gids = (msg.data[0]<<2)+(msg.data[1]>>6);
@@ -786,7 +788,7 @@
             }else{
                 printf("%d.0\n",i);
             }
-            tt.line(40,y,280,y,DarkGrey);
+            tt.line(40,y,254,y,DarkGrey);
         }
 
         x=50+0*6;
@@ -810,16 +812,16 @@
         printf("mon\n");  
         tt.line(x,10,x,220,DarkGrey);     
         x=50+38*6;
-        tt.locate(x-10,226);
-        printf("year\n");  
-        tt.line(x,10,x,220,DarkGrey);
+        //tt.locate(x-10,226);
+        //printf("year\n");  
+        //tt.line(x,10,x,220,DarkGrey);
         lgids=gids;    
     }
     if(force||updateDTE){
         for(i=0;i<10;i++){
             y=200-i*20;
             if (y>60){
-                tt.line(40,y,280,y,DarkGrey);
+                tt.line(40,y,250,y,DarkGrey);
             } else {
                 tt.line(40,y,150,y,DarkGrey);
             }
@@ -832,19 +834,19 @@
         x=50+18*6;
         tt.line(x,10,x,220,DarkGrey);     
         x=50+25*6;
-        tt.line(x,180,x,220,DarkGrey);     
+        tt.line(x,60,x,220,DarkGrey);     
         x=50+32*6;
-        tt.line(x,180,x,220,DarkGrey);     
-        x=50+38*6;
-        tt.line(x,180,x,220,DarkGrey);     
+        tt.line(x,60,x,220,DarkGrey);     
+        //x=50+38*6;
+        //tt.line(x,60,x,220,DarkGrey);     
         tt.set_font((unsigned char*) SCProSB31x55);
         tt.foreground(Green);
         if (showMiles){
-            tt.locate(160,10);
+            tt.locate(160,8);
             printf("%4.1f \n",mpkWh[dtePeriod]*((float)(gids-5)*.075));
         } else {
             tt.locate(180,10);
-            printf("%3.1f\n",mpkWh[dtePeriod]);
+            printf("%3.1f \n",mpkWh[dtePeriod]);
         }
         lx=50;
         ly=mpkWh[0]*20;
@@ -863,7 +865,7 @@
         tt.fillcircle(lx,leff[0],radius,Navy);
         tt.fillcircle(lx,ly,radius,color);
 
-        for(i=1;i<39;i++){
+        for(i=1;i<33;i++){
             x=50+i*6;
             y=mpkWh[i]*20;
             if(y<200) {
@@ -891,6 +893,38 @@
         leff[i-1]=y;
         updateDTE=false;
     }
+
+    msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
+    regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
+    targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
+    if ((targetBraking>50)&&(regenBraking>50)){
+        temp = targetBraking;
+        temp *= 1000;
+        temp /= regenBraking;
+        if (temp<tarDivReg) tarDivReg=temp;
+    }
+    if (targetBraking>maxTarget) maxTarget=targetBraking;
+    if (regenBraking>maxRegen) maxRegen=regenBraking;
+
+    temp = targetBraking;
+    temp *=200;
+    temp /= maxTarget;
+    t = (char) temp;
+    if (t>175) t=175;
+    temp = regenBraking;
+    temp *= tarDivReg;
+    temp /= maxTarget;
+    temp /= 5;
+    r = (char) temp;
+    if (r>175) r=175;
+    if (r>t) t=r;  //Should never happen
+    if(lr!=r||lt!=t){
+        tt.fillrect(264,64,310,239-t,Navy);
+        tt.fillrect(264,239-t,310,239-r,Red);
+        tt.fillrect(264,239-r,310,239,Green);
+    }
+    lt=t;
+    lr=r;
 }
 
 void updateDisplay(char display){
@@ -1062,6 +1096,8 @@
             tt.fillrect(x1,y1,x2,y2,White); // DarkCyan);
         else
             tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
+    } else {
+        tt.fillrect(x1,y1,x2,y2,Green); // DarkCyan);
     }
 
     // paint the outer pixel as a yellow frame
--- a/displayModes.h	Thu Apr 11 18:52:12 2013 +0000
+++ b/displayModes.h	Sat Apr 13 22:46:31 2013 +0000
@@ -35,6 +35,7 @@
 extern unsigned char skin;
 extern unsigned char dtePeriod;
 extern bool updateDTE;
+extern unsigned char tNavRow ; // gg - 4x4
 
 extern "C" {
     void printLast (bool force, bool showButtons);
--- a/main.cpp	Thu Apr 11 18:52:12 2013 +0000
+++ b/main.cpp	Sat Apr 13 22:46:31 2013 +0000
@@ -157,10 +157,7 @@
     logMsg(sTemp);
     
     // revision
-    //sprintf(sTemp,"CANary firmware rev62\n"); // wrong rev, should be rev63
-    //sprintf(sTemp,"CANary firmware rev64\n");
-    //sprintf(sTemp,"CANary firmware rev64-gg1\n"); // gg - adding Index screen
-    sprintf(sTemp,"CANary firmware rev65\n"); // gg - commit Index screen
+    sprintf(sTemp,"CANary firmware rev68\n");
     logMsg(sTemp);
 
     // Look for new binary on thumbdrive