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 haofan Zheng

Revision:
97:0ed9ede9a995
Parent:
86:51048c1f132f
--- a/StateMachine/StandbyState.cpp	Wed Apr 19 19:43:15 2017 +0000
+++ b/StateMachine/StandbyState.cpp	Wed Apr 19 21:17:40 2017 +0000
@@ -4,7 +4,8 @@
 
 #include "StateManager.h"
 
-StandbyState::StandbyState()
+StandbyState::StandbyState() : 
+    m_nextState(STANDBY_STATE)
 {}
 
 StandbyState::~StandbyState()
@@ -29,7 +30,19 @@
 
 void StandbyState::Update(float deltaTime)
 {
-    
+    switch(m_nextState)
+    {
+    case RUNNING_STATE:
+        m_nextState = STANDBY_STATE;
+        state_manager_switch_state(RUNNING_STATE);
+        return;
+    case TESTING_STATE:
+        m_nextState = STANDBY_STATE;
+        state_manager_switch_state(TESTING_STATE);
+        return;
+    default:
+        break;
+    }
 }
 
 uint8_t StandbyState::HasTouchPosFunction() const
@@ -47,11 +60,12 @@
     if(y <= 110)
     {
         ardu_utft_print("X", x, y);
-        state_manager_switch_state(RUNNING_STATE);
+        m_nextState = RUNNING_STATE;
         
     }
     else if(y >= 130)
     {
-        
+        ardu_utft_print("X", x, y);
+        m_nextState = TESTING_STATE;
     }
 }