Skip to content

Commit ac1cfb9

Browse files
umbynosaentinger
authored andcommitted
allow "STOP" during the "REPLAY"
1 parent 0f0d8cc commit ac1cfb9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

examples/Braccio_Learn_and_Repeat/Braccio_Learn_and_Repeat.ino

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,27 @@ static void eventHandlerMenu(lv_event_t * e) {
6161
}
6262
break;
6363
case 1:
64-
state = REPEAT;
6564
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
65+
if (txt == "REPLAY"){
66+
state = REPEAT;
67+
btnm_map[2] = "STOP"; // change the label of the second button to "STOP"
6668
Braccio.engage();
6769
lv_btnmatrix_set_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_CHECKED);
6870
Serial.println("REPEAT");
71+
}
72+
else if (txt=="STOP"){
73+
state = IDLE;
74+
Braccio.engage(); // enable the steppers so that the braccio stands still
75+
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
76+
btnm_map[2] = "REPLAY"; // reset the label of the first button back to "REPLAY"
77+
}
78+
6979
break;
80+
7081
default:
7182
state = IDLE;
7283
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
84+
btnm_map[2] = "REPLAY"; // reset the label of the first button back to "REPLAY"
7385
Braccio.engage();
7486
delay(500);
7587
Braccio.moveTo(homePos[0], homePos[1], homePos[2], homePos[3], homePos[4], homePos[5]);
@@ -138,6 +150,7 @@ void loop() {
138150
if (idx >= final_idx) {
139151
Serial.println("Repeat done");
140152
state = IDLE;
153+
btnm_map[2] = "REPLAY"; // reset the label of the first button back to "REPLAY"
141154
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
142155
}
143156
}

0 commit comments

Comments
 (0)