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
StateMachine/StandbyState.cpp@97:0ed9ede9a995, 2017-04-19 (annotated)
- Committer:
- Bobymicjohn
- Date:
- Wed Apr 19 21:17:40 2017 +0000
- Revision:
- 97:0ed9ede9a995
- Parent:
- 86:51048c1f132f
Added Testing State.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hazheng | 80:c85cb93713b3 | 1 | #include "StandbyState.h" |
hazheng | 80:c85cb93713b3 | 2 | |
hazheng | 82:992ba6f31e24 | 3 | #include "ArduUTFT.h" |
hazheng | 82:992ba6f31e24 | 4 | |
hazheng | 82:992ba6f31e24 | 5 | #include "StateManager.h" |
hazheng | 82:992ba6f31e24 | 6 | |
Bobymicjohn | 97:0ed9ede9a995 | 7 | StandbyState::StandbyState() : |
Bobymicjohn | 97:0ed9ede9a995 | 8 | m_nextState(STANDBY_STATE) |
hazheng | 80:c85cb93713b3 | 9 | {} |
hazheng | 80:c85cb93713b3 | 10 | |
hazheng | 80:c85cb93713b3 | 11 | StandbyState::~StandbyState() |
hazheng | 82:992ba6f31e24 | 12 | { |
hazheng | 82:992ba6f31e24 | 13 | ardu_utft_print("X", 10, 10); |
hazheng | 82:992ba6f31e24 | 14 | } |
hazheng | 80:c85cb93713b3 | 15 | |
hazheng | 80:c85cb93713b3 | 16 | void StandbyState::DrawUserInterface() |
hazheng | 80:c85cb93713b3 | 17 | { |
hazheng | 82:992ba6f31e24 | 18 | ardu_utft_clr_scr(); |
hazheng | 80:c85cb93713b3 | 19 | |
hazheng | 82:992ba6f31e24 | 20 | ardu_utft_set_color(0, 0, 255); |
hazheng | 82:992ba6f31e24 | 21 | ardu_utft_fill_rect(10, 10, 310, 110); |
hazheng | 82:992ba6f31e24 | 22 | ardu_utft_set_color(255, 255, 255); |
hazheng | 82:992ba6f31e24 | 23 | ardu_utft_print("Run", 170, 50); |
hazheng | 82:992ba6f31e24 | 24 | |
hazheng | 82:992ba6f31e24 | 25 | ardu_utft_set_color(255, 255, 0); |
hazheng | 82:992ba6f31e24 | 26 | ardu_utft_fill_rect(10, 130, 310, 230); |
hazheng | 82:992ba6f31e24 | 27 | ardu_utft_set_color(255, 255, 255); |
hazheng | 82:992ba6f31e24 | 28 | ardu_utft_print("Test system", 200, 180); |
hazheng | 80:c85cb93713b3 | 29 | } |
hazheng | 80:c85cb93713b3 | 30 | |
hazheng | 80:c85cb93713b3 | 31 | void StandbyState::Update(float deltaTime) |
hazheng | 80:c85cb93713b3 | 32 | { |
Bobymicjohn | 97:0ed9ede9a995 | 33 | switch(m_nextState) |
Bobymicjohn | 97:0ed9ede9a995 | 34 | { |
Bobymicjohn | 97:0ed9ede9a995 | 35 | case RUNNING_STATE: |
Bobymicjohn | 97:0ed9ede9a995 | 36 | m_nextState = STANDBY_STATE; |
Bobymicjohn | 97:0ed9ede9a995 | 37 | state_manager_switch_state(RUNNING_STATE); |
Bobymicjohn | 97:0ed9ede9a995 | 38 | return; |
Bobymicjohn | 97:0ed9ede9a995 | 39 | case TESTING_STATE: |
Bobymicjohn | 97:0ed9ede9a995 | 40 | m_nextState = STANDBY_STATE; |
Bobymicjohn | 97:0ed9ede9a995 | 41 | state_manager_switch_state(TESTING_STATE); |
Bobymicjohn | 97:0ed9ede9a995 | 42 | return; |
Bobymicjohn | 97:0ed9ede9a995 | 43 | default: |
Bobymicjohn | 97:0ed9ede9a995 | 44 | break; |
Bobymicjohn | 97:0ed9ede9a995 | 45 | } |
hazheng | 80:c85cb93713b3 | 46 | } |
hazheng | 80:c85cb93713b3 | 47 | |
hazheng | 80:c85cb93713b3 | 48 | uint8_t StandbyState::HasTouchPosFunction() const |
hazheng | 80:c85cb93713b3 | 49 | { |
hazheng | 82:992ba6f31e24 | 50 | return 1; |
hazheng | 80:c85cb93713b3 | 51 | } |
hazheng | 80:c85cb93713b3 | 52 | |
hazheng | 80:c85cb93713b3 | 53 | uint8_t StandbyState::HasTouchIrqFunction() const |
hazheng | 80:c85cb93713b3 | 54 | { |
hazheng | 82:992ba6f31e24 | 55 | return 0; |
hazheng | 80:c85cb93713b3 | 56 | } |
hazheng | 80:c85cb93713b3 | 57 | |
hazheng | 80:c85cb93713b3 | 58 | void StandbyState::TouchPosCallback(int16_t x, int16_t y) |
hazheng | 80:c85cb93713b3 | 59 | { |
hazheng | 82:992ba6f31e24 | 60 | if(y <= 110) |
hazheng | 82:992ba6f31e24 | 61 | { |
hazheng | 82:992ba6f31e24 | 62 | ardu_utft_print("X", x, y); |
Bobymicjohn | 97:0ed9ede9a995 | 63 | m_nextState = RUNNING_STATE; |
hazheng | 82:992ba6f31e24 | 64 | |
hazheng | 82:992ba6f31e24 | 65 | } |
hazheng | 82:992ba6f31e24 | 66 | else if(y >= 130) |
hazheng | 82:992ba6f31e24 | 67 | { |
Bobymicjohn | 97:0ed9ede9a995 | 68 | ardu_utft_print("X", x, y); |
Bobymicjohn | 97:0ed9ede9a995 | 69 | m_nextState = TESTING_STATE; |
hazheng | 82:992ba6f31e24 | 70 | } |
hazheng | 80:c85cb93713b3 | 71 | } |