Skip to content

Commit 6a54383

Browse files
committed
Only allow to press the zero position button from the idle state.
1 parent c4182dd commit 6a54383

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

examples/Braccio_Record_and_Replay/AppState.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ void custom_main_menu()
108108
Braccio.connectJoystickTo(btnm);
109109
}
110110

111-
/**************************************************************************************
112-
* State
113-
**************************************************************************************/
114-
115-
State * State::handle_OnZeroPosition()
116-
{
117-
return new ZeroState();
118-
}
119-
120111
/**************************************************************************************
121112
* IdleState
122113
**************************************************************************************/
@@ -141,6 +132,11 @@ State * IdleState::handle_OnReplay()
141132
return new ReplayState();
142133
}
143134

135+
State * IdleState::handle_OnZeroPosition()
136+
{
137+
return new ZeroState();
138+
}
139+
144140
/**************************************************************************************
145141
* RecordState
146142
**************************************************************************************/
@@ -150,6 +146,7 @@ void RecordState::onEnter()
150146
btnm_map[0] = "STOP";
151147
lv_btnmatrix_set_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_CHECKED);
152148
lv_btnmatrix_set_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_DISABLED);
149+
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_DISABLED);
153150

154151
Braccio.disengage();
155152
delay(100);
@@ -161,6 +158,7 @@ void RecordState::onExit()
161158
btnm_map[0] = "RECORD";
162159
lv_btnmatrix_clear_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_CHECKED);
163160
lv_btnmatrix_clear_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_DISABLED);
161+
lv_btnmatrix_clear_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_DISABLED);
164162
lv_label_set_text_fmt(counter, "Counter: %d" , 0);
165163

166164
Braccio.engage();
@@ -218,13 +216,15 @@ void ReplayState::onEnter()
218216
btnm_map[2] = "STOP";
219217
lv_btnmatrix_set_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_DISABLED);
220218
lv_btnmatrix_set_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_CHECKED);
219+
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_DISABLED);
221220
}
222221

223222
void ReplayState::onExit()
224223
{
225224
btnm_map[2] = "REPLAY";
226225
lv_btnmatrix_clear_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_DISABLED);
227226
lv_btnmatrix_clear_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_CHECKED);
227+
lv_btnmatrix_clear_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_DISABLED);
228228
lv_label_set_text_fmt(counter, "Counter: %d" , 0);
229229
}
230230

examples/Braccio_Record_and_Replay/AppState.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class State
5454
protected:
5555
virtual State * handle_OnRecord() { return this; }
5656
virtual State * handle_OnReplay() { return this; }
57-
virtual State * handle_OnZeroPosition();
57+
virtual State * handle_OnZeroPosition() { return this; }
5858
virtual State * handle_OnTimerTick() { return this; }
5959
};
6060

@@ -67,8 +67,9 @@ class IdleState : public State
6767
virtual void onExit() override;
6868

6969
protected:
70-
virtual State * handle_OnRecord() override;
71-
virtual State * handle_OnReplay() override;
70+
virtual State * handle_OnRecord () override;
71+
virtual State * handle_OnReplay () override;
72+
virtual State * handle_OnZeroPosition() override;
7273
};
7374

7475
class RecordState : public State

0 commit comments

Comments
 (0)