Skip to content

Commit 2e842bb

Browse files
committed
change the first button label from "LEARN" to "STOP" when "LEARN" is selected. "STOP" button actually does what it's supposed to do
1 parent 9441850 commit 2e842bb

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

examples/tutorials/projects/p03-learning-mode/01_Braccio_learning_mode/01_Braccio_learning_mode.ino

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,35 @@ static void eventHandlerMenu(lv_event_t * e) {
4444
idx = values;
4545

4646
switch (id) {
47-
case 0:
48-
state = LEARN;
49-
Braccio.disengage();
50-
lv_btnmatrix_set_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_CHECKED);
51-
Serial.println("LEARN");
52-
lv_btnmatrix_clear_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_DISABLED); // remove disabled state of the replay button
47+
case 0: // if the button pressed is the first one
48+
if (txt == "LEARN") {
49+
state = LEARN;
50+
Braccio.disengage(); // allow the user to freely move the braccio
51+
lv_btnmatrix_set_btn_ctrl(btnm, 0, LV_BTNMATRIX_CTRL_CHECKED);
52+
Serial.println("LEARN");
53+
lv_btnmatrix_clear_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_DISABLED); // remove disabled state of the replay button
54+
btnm_map[0] = "STOP"; // change the label of the first button to "STOP"
55+
}
56+
else if (txt == "STOP") {
57+
state = IDLE;
58+
Braccio.engage(); // enable the steppers so that the braccio stands still
59+
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
60+
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
61+
}
5362
break;
5463
case 1:
5564
state = REPEAT;
65+
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
5666
Braccio.engage();
5767
lv_btnmatrix_set_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_CHECKED);
5868
Serial.println("REPEAT");
5969
break;
6070
default:
6171
state = IDLE;
72+
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
73+
Braccio.engage();
6274
delay(500);
6375
Braccio.moveTo(homePos[0], homePos[1], homePos[2], homePos[3], homePos[4], homePos[5]);
64-
6576
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
6677
Serial.println("IDLE");
6778
break;

0 commit comments

Comments
 (0)