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: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Diff: Steering.cpp
- Revision:
- 21:56890c41ecf1
- Parent:
- 20:c3f4828f3cbc
- Child:
- 22:ab33195882e3
- Child:
- 23:6681a38918c6
diff -r c3f4828f3cbc -r 56890c41ecf1 Steering.cpp
--- a/Steering.cpp	Sat Oct 25 16:53:34 2014 +0000
+++ b/Steering.cpp	Sat Oct 25 17:24:58 2014 +0000
@@ -2,7 +2,7 @@
 
 void HomeScreen()
 {
-    CANMessage Rxmsg;
+   
     ftc rcv;
     rcv.FLOAT=0.0;
     char dat[4];
@@ -14,6 +14,7 @@
     display.PrintString(" HOME SCREEN");
     while( !(biSWTL.read() || biSWTR.read() || biSWBR.read()) )
     {
+        CANMessage Rxmsg;
         if(CAN_Steering_Buffer.rxRead(Rxmsg))
         {
             for(int i=0; i<4; i++)
@@ -227,11 +228,9 @@
     display.ClearScreen();
     display.SelectFont(Arial12,BLACK,ReadData);
     display.GotoXY(26,16);
-    display.PrintString("REQUEST SENT TO CHANGE\n\r DRIVE STATUS TO: \n\r");
-    display.PrintString(status_string);
-    display.PrintString(".\n\r");
+    display.PrintString("DRIVE STATUS REQUEST");
     
-    printf(status_string);
+    printf("%s\n\r", status_string);
     return;
 }
 
@@ -277,6 +276,19 @@
     call_ledstream.attach(&Powerstream,0.1);
 }
 
+void update_vars(void const *args) {
+    while (true) {
+        CANMessage Rxmsg;
+        if(CAN_Steering_Buffer.rxRead(Rxmsg)){
+               if(Rxmsg.id == PCM_STATE_ID){
+                    ds_mutex.lock();
+                    drive_status = Rxmsg.data[0];
+                    ds_mutex.unlock();
+                }
+        }
+    }
+}
+
 int main()
 {
     // Init all
@@ -288,6 +300,8 @@
     display.SelectFont(Arial_14,BLACK,ReadData);
     display.PrintString("Penn Electric Racing");
     
+    Thread update_thread(update_vars);
+    
     wait(1);
 
     // Start to read buttons on main thread
    