7
7
8
8
enum states {
9
9
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
12
12
};
13
13
14
- int state = IDLE ;
14
+ int state = ZERO_POSITION ;
15
15
16
16
float values[10000 ];
17
17
float * idx = values;
@@ -21,15 +21,15 @@ float homePos[6] = {157.5, 157.5, 157.5, 157.5, 157.5, 90.0};
21
21
static lv_obj_t * counter;
22
22
static lv_obj_t * btnm;
23
23
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 " };
25
25
26
26
27
27
static void eventHandlerMenu (lv_event_t * e) {
28
28
lv_event_code_t code = lv_event_get_code (e);
29
29
lv_obj_t * obj = lv_event_get_target (e);
30
30
31
31
if (code == LV_EVENT_KEY && lv_indev_get_key (lv_indev_get_act ()) == LV_KEY_HOME) {
32
- state = IDLE ;
32
+ state = ZERO_POSITION ;
33
33
return ;
34
34
}
35
35
@@ -54,39 +54,39 @@ static void eventHandlerMenu(lv_event_t * e) {
54
54
btnm_map[0 ] = " STOP" ; // change the label of the first button to "STOP"
55
55
}
56
56
else if (txt == " STOP" ) {
57
- state = IDLE ;
57
+ state = ZERO_POSITION ;
58
58
Braccio.engage (); // enable the steppers so that the braccio stands still
59
59
lv_btnmatrix_set_btn_ctrl (btnm, 2 , LV_BTNMATRIX_CTRL_CHECKED);
60
60
btnm_map[0 ] = " LEARN" ; // reset the label of the first button back to "LEARN"
61
61
}
62
62
break ;
63
63
case 1 :
64
64
btnm_map[0 ] = " LEARN" ; // reset the label of the first button back to "LEARN"
65
- if (txt == " REPLAY " ){
65
+ if (txt == " REPEAT " ){
66
66
state = REPEAT;
67
67
btnm_map[2 ] = " STOP" ; // change the label of the second button to "STOP"
68
68
Braccio.engage ();
69
69
lv_btnmatrix_set_btn_ctrl (btnm, 1 , LV_BTNMATRIX_CTRL_CHECKED);
70
70
Serial.println (" REPEAT" );
71
71
}
72
72
else if (txt==" STOP" ){
73
- state = IDLE ;
73
+ state = ZERO_POSITION ;
74
74
Braccio.engage (); // enable the steppers so that the braccio stands still
75
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 "
76
+ btnm_map[2 ] = " REPEAT " ; // reset the label of the first button back to "REPEAT "
77
77
}
78
78
79
79
break ;
80
80
81
81
default :
82
- state = IDLE ;
82
+ state = ZERO_POSITION ;
83
83
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 "
85
85
Braccio.engage ();
86
86
delay (500 );
87
87
Braccio.moveTo (homePos[0 ], homePos[1 ], homePos[2 ], homePos[3 ], homePos[4 ], homePos[5 ]);
88
88
lv_btnmatrix_set_btn_ctrl (btnm, 2 , LV_BTNMATRIX_CTRL_CHECKED);
89
- Serial.println (" IDLE " );
89
+ Serial.println (" ZERO_POSITION " );
90
90
break ;
91
91
}
92
92
}
@@ -149,17 +149,17 @@ void loop() {
149
149
idx += 6 ;
150
150
if (idx >= final_idx) {
151
151
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 "
154
154
lv_btnmatrix_set_btn_ctrl (btnm, 2 , LV_BTNMATRIX_CTRL_CHECKED);
155
155
}
156
156
}
157
157
if (idx - values >= sizeof (values)) {
158
- Serial.println (" IDLE " );
159
- state = IDLE ;
158
+ Serial.println (" ZERO_POSITION " );
159
+ state = ZERO_POSITION ;
160
160
}
161
161
delay (100 );
162
- if (state != IDLE ) {
162
+ if (state != ZERO_POSITION ) {
163
163
lv_label_set_text_fmt (counter, " Counter: %d" , idx - values);
164
164
}
165
165
}
0 commit comments