The Code Repository for the REV0 Steering Wheel.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Diff: Steering.cpp
- Revision:
- 32:535acb159709
- Parent:
- 26:e0256fd314eb
- Child:
- 35:b42afc973902
- Child:
- 43:47a3ac562be8
diff -r e0256fd314eb -r 535acb159709 Steering.cpp --- 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(); }