Skip to content

Commit 8ce8384

Browse files
umbynosaentinger
authored andcommitted
change and uniform button labels
1 parent ac1cfb9 commit 8ce8384

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

examples/Braccio_Learn_and_Repeat/Braccio_Learn_and_Repeat.ino

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
enum states {
99
LEARN,
10-
REPEAT, // for consistency is better to name this REPLAY or rename the button label repeat TODO
11-
IDLE
10+
REPEAT, // for consistency is better to name this REPEAT or rename the button label repeat TODO
11+
ZERO_POSITION
1212
};
1313

14-
int state = IDLE;
14+
int state = ZERO_POSITION;
1515

1616
float values[10000];
1717
float* idx = values;
@@ -21,15 +21,15 @@ float homePos[6] = {157.5, 157.5, 157.5, 157.5, 157.5, 90.0};
2121
static lv_obj_t * counter;
2222
static lv_obj_t * btnm;
2323

24-
static const char * btnm_map[] = { "LEARN", "\n", "REPLAY", "\n", "IDLE", "\n", "\0" };
24+
static const char * btnm_map[] = { "LEARN", "\n", "REPEAT", "\n", "ZERO_POSITION", "\n", "\0" };
2525

2626

2727
static void eventHandlerMenu(lv_event_t * e) {
2828
lv_event_code_t code = lv_event_get_code(e);
2929
lv_obj_t * obj = lv_event_get_target(e);
3030

3131
if (code == LV_EVENT_KEY && lv_indev_get_key(lv_indev_get_act()) == LV_KEY_HOME) {
32-
state = IDLE;
32+
state = ZERO_POSITION;
3333
return;
3434
}
3535

@@ -54,39 +54,39 @@ static void eventHandlerMenu(lv_event_t * e) {
5454
btnm_map[0] = "STOP"; // change the label of the first button to "STOP"
5555
}
5656
else if (txt == "STOP") {
57-
state = IDLE;
57+
state = ZERO_POSITION;
5858
Braccio.engage(); // enable the steppers so that the braccio stands still
5959
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
6060
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
6161
}
6262
break;
6363
case 1:
6464
btnm_map[0] = "LEARN"; // reset the label of the first button back to "LEARN"
65-
if (txt == "REPLAY"){
65+
if (txt == "REPEAT"){
6666
state = REPEAT;
6767
btnm_map[2] = "STOP"; // change the label of the second button to "STOP"
6868
Braccio.engage();
6969
lv_btnmatrix_set_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_CHECKED);
7070
Serial.println("REPEAT");
7171
}
7272
else if (txt=="STOP"){
73-
state = IDLE;
73+
state = ZERO_POSITION;
7474
Braccio.engage(); // enable the steppers so that the braccio stands still
7575
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"
76+
btnm_map[2] = "REPEAT"; // reset the label of the first button back to "REPEAT"
7777
}
7878

7979
break;
8080

8181
default:
82-
state = IDLE;
82+
state = ZERO_POSITION;
8383
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"
84+
btnm_map[2] = "REPEAT"; // reset the label of the first button back to "REPEAT"
8585
Braccio.engage();
8686
delay(500);
8787
Braccio.moveTo(homePos[0], homePos[1], homePos[2], homePos[3], homePos[4], homePos[5]);
8888
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
89-
Serial.println("IDLE");
89+
Serial.println("ZERO_POSITION");
9090
break;
9191
}
9292
}
@@ -149,17 +149,17 @@ void loop() {
149149
idx += 6;
150150
if (idx >= final_idx) {
151151
Serial.println("Repeat done");
152-
state = IDLE;
153-
btnm_map[2] = "REPLAY"; // reset the label of the first button back to "REPLAY"
152+
state = ZERO_POSITION;
153+
btnm_map[2] = "REPEAT"; // reset the label of the first button back to "REPEAT"
154154
lv_btnmatrix_set_btn_ctrl(btnm, 2, LV_BTNMATRIX_CTRL_CHECKED);
155155
}
156156
}
157157
if (idx - values >= sizeof(values)) {
158-
Serial.println("IDLE");
159-
state = IDLE;
158+
Serial.println("ZERO_POSITION");
159+
state = ZERO_POSITION;
160160
}
161161
delay(100);
162-
if (state != IDLE) {
162+
if (state != ZERO_POSITION) {
163163
lv_label_set_text_fmt(counter, "Counter: %d" , idx - values);
164164
}
165165
}

0 commit comments

Comments
 (0)