Penn Electric Racing / Mbed 2 deprecated REVO_Updated_Steering

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Files at this revision

API Documentation at this revision

Comitter:
tmccurbin
Date:
Sat Nov 15 19:07:13 2014 +0000
Parent:
26:e0256fd314eb
Child:
33:3b0157d15182
Commit message:
New font, Toggle Button Added

Changed in this revision

KS0108.lib Show annotated file Show diff for this revision Revisions of this file
Steering.cpp Show annotated file Show diff for this revision Revisions of this file
Steering.h Show annotated file Show diff for this revision Revisions of this file
--- a/KS0108.lib	Fri Nov 14 01:43:42 2014 +0000
+++ b/KS0108.lib	Sat Nov 15 19:07:13 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/DimiterK/code/KS0108/#e4b50f4c13a8
+http://mbed.org/users/DimiterK/code/KS0108/#cd525869e8b2
--- a/Steering.cpp	Fri Nov 14 01:43:42 2014 +0000
+++ b/Steering.cpp	Sat Nov 15 19:07:13 2014 +0000
@@ -1,23 +1,41 @@
 #include "Steering.h"
 
 bool NOT_biSWBL_HELD;
+bool NOT_biSWTR_HELD;
 
-void display_screen(int screen){
+void update_display(void const *args){
+
 
-    switch(screen){
+    while(true){
+        
+        switch(curr_screen){
     
-        case HOME_SCREEN:
+            case HOME_SCREEN:
+            
+                display.ClearScreen();
+                display.SelectFont(Arial10,BLACK,ReadData);
+                display.GotoXY(37,0);
+                display.PrintString("Home Screen");
+                break;
             
-            display.ClearScreen();
-            display.SelectFont(Arial12,BLACK,ReadData);
-            display.GotoXY(0,64);
-            display.PrintString("Chg Drv Stat");
+            case BATTERY_SCREEN:
+            
+                display.ClearScreen();
+                display.SelectFont(Arial10,BLACK,ReadData);
+                display.GotoXY(33,0);
+                display.PrintString("Battery Screen");
+                break;
         
-        default:
-            break;    
+            default:
+                break;    
         
-    }    
-    
+        }
+        wait(2);   
+    }
+}
+
+void toggle_screen(){
+    curr_screen = (curr_screen+1) % 2; 
 }
 
 void request_status_change(){
@@ -75,6 +93,7 @@
     reset_body = 0;
     ledstream.write(0);
     NOT_biSWBL_HELD = true;
+    NOT_biSWTR_HELD = true;
 }
 
 void read_messages(void const *args) {
@@ -118,13 +137,13 @@
     display.PrintString("Penn Electric Racing");
     CAN_Steering_Buffer.mode(NoAck);
     
-     wait(2);
+    wait(2);
      
      //New thread to read messages.
-     Thread update_thread(read_messages);
+    Thread update_thread(read_messages);
     
     // display the screen.
-    display_screen(curr_screen);
+    Thread display_thread(update_display);
       
 
     // Start to read buttons on main thread
@@ -143,6 +162,21 @@
             // ignore BiSWBL.read()
         }
         
+        if(biSWTR.read() && NOT_biSWTR_HELD){
+            printf("ff\r\n");
+            toggle_screen();
+            NOT_biSWTR_HELD = false;
+        }
+        
+        else if(!biSWTR.read()){
+            NOT_biSWTR_HELD = true;
+        }
+        
+        else{
+            // ignore BiSWTR.read()
+        }
+        
+        
         if(biSWBR.read()){ 
             reset();
         }
--- a/Steering.h	Fri Nov 14 01:43:42 2014 +0000
+++ b/Steering.h	Sat Nov 15 19:07:13 2014 +0000
@@ -5,6 +5,7 @@
 #include "rtos.h"
 #include "KS0108.h"
 
+#include "Arial10.h"
 #include "Arial12.h"
 #include "Arial14.h"
 #include "Comic24.h"
@@ -31,6 +32,7 @@
 #define AMS_BATTERY_STATE 0x30E          // AIRS 7 and 6 // Precharge 3
 
 #define HOME_SCREEN 0
+#define BATTERY_SCREEN 1
 
 Serial pc(USBTX,USBRX);
 CANBuffer CAN_Steering_Buffer(CAN1, MEDIUM, p3_26);
@@ -101,7 +103,7 @@
     {102,32},   //tsm
     };
     
-int maxScreen=5;
+int maxScreen=2;
 int curr_screen; 
 
 char drive_status;