SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: StateMachine/StateManager.cpp
- Branch:
- Drift
- Revision:
- 82:992ba6f31e24
- Parent:
- 81:32bd7a25a699
--- a/StateMachine/StateManager.cpp Tue Apr 18 19:42:15 2017 +0000 +++ b/StateMachine/StateManager.cpp Tue Apr 18 20:51:06 2017 +0000 @@ -2,9 +2,12 @@ #include "States.h" #include "ArduTouch.h" -#ifdef __cplusplus -extern "C" { -#endif +#include "ArduUTFT.h" + +#include "StandbyState.h" +#include "RunningState.h" +#include "TestingState.h" + static States* stat_manger_curr_stat = NULL; @@ -20,8 +23,6 @@ void state_manager_set_current_state(States* stat) { - state_manager_clear_current_state(); - stat_manger_curr_stat = stat; if(stat_manger_curr_stat) { @@ -43,7 +44,7 @@ { if(stat_manger_curr_stat) { - delete stat_manger_curr_stat; + //delete stat_manger_curr_stat; stat_manger_curr_stat = NULL; } @@ -59,6 +60,29 @@ } } -#ifdef __cplusplus +void state_manager_switch_state(uint8_t state) +{ + static StandbyState standby; + static RunningState running; + static TestingState testing; + + state_manager_clear_current_state(); + + //ardu_utft_print("X", 20, 20); + switch(state) + { + case STANDBY_STATE: + state_manager_set_current_state(&standby); + break; + case RUNNING_STATE: + state_manager_set_current_state(&running); + break; + case TESTING_STATE: + state_manager_set_current_state(&testing); + break; + default: + + break; + } + //ardu_utft_print("X", 30, 30); } -#endif \ No newline at end of file