Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Revision:
151:3047ebb3c9a8
Parent:
150:ef46ce63345c
Child:
152:a4d66901785d
--- a/displayModes.cpp	Fri Sep 27 04:43:41 2013 +0000
+++ b/displayModes.cpp	Mon Sep 30 15:31:01 2013 +0000
@@ -247,10 +247,6 @@
         printf("%03x : %02x %02x %02x %02x %02x %02x %02x %02x    \n",msg.id,msg.data[0],msg.data[1],msg.data[2],msg.data[3],msg.data[4],msg.data[5],msg.data[6],msg.data[7]);
     }
     if(showButtons){
-        tt.foreground(Yellow);
-        tt.background(DarkCyan);
-        tt.set_font((unsigned char*) Arial12x12);
-        
         showButton(0,0," <up>","",4,4);
         showButton(2,0,"<down>","",4,4);
     }
@@ -275,9 +271,6 @@
         }// if changed
     }while(i<19&&j<99);
     if(showButtons){
-        tt.foreground(Yellow);
-        tt.background(DarkCyan);
-        tt.set_font((unsigned char*) Arial12x12);
         showButton(0,0,"  <up>","",4,4);
         showButton(2,0," <down>","",4,4);
         showButton(1,0," Reset","Baseline",4,4);
@@ -314,16 +307,24 @@
         printf("kWh : %s : Eff\n",distanceUnit());
         for(int i=0; i<3; i++){
             tt.locate(6,20+i*60);
-            printf("%3.2f : %3.1f : %2.1f\n",kWh_trip[i],convertDistance(miles_trip[i]),convertDistance(miles_trip[i])/kWh_trip[i]);
+            printf("%3.2f : %3.1f : %2.1f  \n",kWh_trip[i],convertDistance(miles_trip[i]),convertDistance(miles_trip[i])/kWh_trip[i]);
         }
+        tt.foreground(Navy);
+        tt.set_font((unsigned char*) Arial12x12);
+        tt.locate(274,18);
+        printf("per\n");
+        tt.locate(274,33);
+        printf("trip\n");
+        tt.locate(274,78);
+        printf("per\n");
+        tt.locate(265,93);
+        printf("charge\n");
+        tt.locate(265,145);
+        printf("custom\n");
+        lkWh=kWh_trip[0];
     }
     if(showButtons){
-        tt.set_font((unsigned char*) Arial12x12);
-        tt.background(DarkCyan);
-        tt.foreground(Yellow);
-        showButton(3,1," Reset","   A",4,4);
-        showButton(3,2," Reset","   B",4,4);
-        lkWh=kWh_trip[0];
+        showButton(3,2," Reset"," ",4,4);
     }
 }
 
@@ -611,10 +612,6 @@
         }
     }
     if(showButtons){
-        tt.foreground(Yellow);
-        tt.background(DarkCyan);
-        tt.set_font((unsigned char*) Arial12x12);
-        
         showButton(1,0,"Request","CP Data",4,4);               
     }
 }
@@ -632,11 +629,7 @@
         
         // add the buttons to GoTo to other screens
 
-        tt.foreground(Yellow);
-        tt.background(DarkCyan);
-        tt.set_font((unsigned char*) Arial12x12);
-        
-         // top row
+        // top row
         showButton(0,0," GoTo"," Main",4,4);               
         showButton(1,0," GoTo"," Brake",4,4);               
         showButton(2,0," GoTo"," EFF",4,4);               
@@ -787,10 +780,6 @@
     
     // handle the button
     if(sMode==1&&showButtons){
-        tt.foreground(Yellow);
-        tt.background(DarkCyan);
-        tt.set_font((unsigned char*) Arial12x12);
-        
         showButton(1,0,"Request","CP Data",4,4);               
     }
 }
@@ -899,10 +888,6 @@
     
     // handle the button
     if(sMode==1&&showButtons){
-        tt.foreground(Yellow);
-        tt.background(DarkCyan);
-        tt.set_font((unsigned char*) Arial12x12);
-        
         showButton(1,0,"Request","CP Data",4,4);               
         }
 }
@@ -913,10 +898,6 @@
         tt.background(Black);
         tt.cls();
     }
-    tt.foreground(Yellow);
-    tt.background(DarkCyan);
-    tt.set_font((unsigned char*) Arial12x12);
- 
     //-------- top row --------
     showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4
     showButton(1,0," Reset","",4,4);
@@ -984,9 +965,6 @@
         tt.background(Black);
         tt.cls();
     }
-    tt.foreground(Yellow);
-    tt.background(DarkCyan);
-    tt.set_font((unsigned char*) Arial12x12);
     if(playbackOpen){
         showButton(0,0,"Slower"," <--",4,4);
         
@@ -1045,7 +1023,6 @@
                 default:
                     break;
             }
-            tt.background(DarkCyan);
             showButton(0,1,sTemp1,"",4,4);                          
             showButton(1,1,"  UP","",4,4);               
             showButton(2,1," DOWN","",4,4);               
@@ -1350,10 +1327,6 @@
     if(display==whichTouched){
         switch (sMode) {
             case 1: // Select screens
-                tt.foreground(Yellow);
-                tt.background(DarkCyan);
-                tt.set_font((unsigned char*) Arial12x12);   
-                           
                 showButton(0,tNavRow," <-Prev","",4,4); // gg - 4x4
                 // col 1 see below
                 showButton(2,tNavRow," Go To"," Index",4,4); // gg - index
@@ -1422,25 +1395,20 @@
                 break;
                 
             case 2: // numpad
-                tt.foreground(Yellow);
-                tt.background(DarkCyan);
-                tt.set_font((unsigned char*) Arial24x23);
-
-                sprintf(sTemp2,"");
-                showButton(0,0," 1",sTemp2,4,4);
-                showButton(1,0," 2",sTemp2,4,4);
-                showButton(2,0," 3",sTemp2,4,4);
-                showButton(0,1," 4",sTemp2,4,4);
-                showButton(1,1," 5",sTemp2,4,4);
-                showButton(2,1," 6",sTemp2,4,4);
-                showButton(0,2," 7",sTemp2,4,4);
-                showButton(1,2," 8",sTemp2,4,4);
-                showButton(2,2," 9",sTemp2,4,4);
-                showButton(1,3," 0",sTemp2,4,4);
+                showButton(0,0," 1","",4,4);
+                showButton(1,0," 2","",4,4);
+                showButton(2,0," 3","",4,4);
+                showButton(0,1," 4","",4,4);
+                showButton(1,1," 5","",4,4);
+                showButton(2,1," 6","",4,4);
+                showButton(0,2," 7","",4,4);
+                showButton(1,2," 8","",4,4);
+                showButton(2,2," 9","",4,4);
+                showButton(1,3," 0","",4,4);
                 
-                showButton(0,3,"<--",sTemp2,4,4);
-                showButton(2,3,"-->",sTemp2,4,4);
-                showButton(3,3,"return",sTemp2,4,4);
+                showButton(0,3,"<--","",4,4);
+                showButton(2,3,"-->","",4,4);
+                showButton(3,3,"return","",4,4);
             case 3:
                 break;
             default:
@@ -1487,6 +1455,10 @@
     y1=row*(240/rows)+btnGap/2;
     y2=(row+1)*(240/rows)-btnGap/2;
     tt.fillrect(x1,y1,x2,y2,DarkCyan);
+
+    tt.foreground(Yellow);
+    tt.background(DarkCyan);
+    tt.set_font((unsigned char*) Arial12x12);
     
     // adapt formatting of text to the smaller 4x4 box
     tt.locate(x1+btnGap/2,y1+btnGap); // gg - 4x4