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:
- 22:ab33195882e3
- Parent:
- 21:56890c41ecf1
- Child:
- 25:fc63a5bffffc
diff -r 56890c41ecf1 -r ab33195882e3 Steering.cpp --- a/Steering.cpp Sat Oct 25 17:24:58 2014 +0000 +++ b/Steering.cpp Tue Nov 04 08:12:34 2014 +0000 @@ -1,5 +1,10 @@ #include "Steering.h" +#define Reset_Threshold 32000 +#define Drive_Threshold 32000 +int BL_Button_Status = 0; +int BR_Button_Status = 0; + void HomeScreen() { @@ -208,7 +213,7 @@ } -void request_status_change() +void Drive_Request() { char drive_status_request = !drive_status; @@ -225,10 +230,20 @@ CAN_Steering_Buffer.txWrite(Txmsg_drive_status_request); } - display.ClearScreen(); - display.SelectFont(Arial12,BLACK,ReadData); - display.GotoXY(26,16); - display.PrintString("DRIVE STATUS REQUEST"); +//Button Press code + if (BL_Button_Status == 0) + { + display.ClearScreen(); + display.SelectFont(Arial12,BLACK,ReadData); + display.GotoXY(26,16); + display.PrintString("Drive Initiated"); + printf("Drive Initiated\n\r"); + BL_Button_Status = BL_Button_Status + 1; + } + else + { + BL_Button_Status = BL_Button_Status + 1; + } printf("%s\n\r", status_string); return; @@ -236,15 +251,29 @@ void reset() { - CAN_Steering_Buffer.txWriteDirect(Txmsg_reset); - mbed_reset(); - display.ClearScreen(); - display.SelectFont(Arial12,BLACK,ReadData); - display.GotoXY(16,16); - display.PrintString(" RESET INITIATED"); - printf("Reset Initiated\n\r"); - - return; + if (BR_Button_Status == 0) + { + display.ClearScreen(); + display.SelectFont(Arial12,BLACK,ReadData); + display.GotoXY(16,16); + display.PrintString("Hold To Reset"); + printf("Hold to reset\n\r"); + BR_Button_Status = BR_Button_Status + 1; + } + else if (BR_Button_Status < Reset_Threshold) + { + BR_Button_Status = BR_Button_Status + 1; + } + else if (BR_Button_Status >= Reset_Threshold) + { + for (int i = 0; i < 10; i ++) + { + CAN_Steering_Buffer.txWriteDirect(Txmsg_reset); + printf("Reset Initiated\n\r"); + } + BR_Button_Status = BR_Button_Status + 1; + mbed_reset(); + } } void Powerstream() @@ -310,12 +339,17 @@ { if(biSWBL.read()) { - request_status_change(); + Drive_Request; } - if(biSWBR.read()) + else if(biSWBR.read()) { reset(); } - + else + { + BR_Button_Status = 0; + BL_Button_Status = 0; + } + printf("BL %d BR %d \n", 'BL_Button_Status', 'BR_Button_Status'); } }