Skip to content

Commit 397e91b

Browse files
committed
Fixed extra curly brackets, gave menu and bar graph children seperate threads
1 parent 98b0dfd commit 397e91b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

BUILD_DIR/t4_sensor2.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,20 @@ ESOS_CHILD_TASK(menu) {
132132

133133
ESOS_USER_TASK(loop) {
134134
static uint16_t u16_data;
135-
static ESOS_TASK_HANDLE th_child; //declare storage for handle to child task
136-
ESOS_TASK_BEGIN();{
137-
for (;;) { //same as while(true)
135+
static ESOS_TASK_HANDLE th_child_bar_graph; //declare storage for handle to child task
136+
static ESOS_TASK_HANDLE th_child_menu
137+
ESOS_TASK_BEGIN();
138+
for (;;) { //same as while(true)
138139

139140
ESOS_TASK_WAIT_UNTIL(esos_uiF14_isSW1Pressed() || esos_uiF14_isSW2Pressed()); //on either switch, start the DO loop
140-
if (esos_uiF14_isSW2Pressed()){
141-
b_keepLooping = TRUE; //if sw2 then keep looping; checked at the bottom while statement
142-
}
143-
else {b_keepLooping = FALSE; //if sw1 don't keep looping just do once
144-
}
141+
if (esos_uiF14_isSW2Pressed()){
142+
b_keepLooping = TRUE; //if sw2 then keep looping; checked at the bottom while statement
143+
}
144+
else {b_keepLooping = FALSE; //if sw1 don't keep looping just do once
145+
}
145146
ESOS_TASK_WAIT_UNTIL(esos_uiF14_isSW1Released() && esos_uiF14_isSW2Released()); /*wait for the release so
146-
sw1 can exit the loop when pressed again. The loop is fast enough to go around and sense sw1 still pressed
147-
and begin again*/
147+
sw1 can exit the loop when pressed again. The loop is fast enough to go around and sense sw1 still pressed
148+
and begin again*/
148149
do{ //claim the ADC, setup for CH2(potentiometer) and 3V3 for upper Vref
149150
ESOS_TASK_WAIT_ON_AVAILABLE_SENSOR(ESOS_SENSOR_CH02, ESOS_SENSOR_VREF_3V3);
150151

@@ -156,8 +157,8 @@ ESOS_USER_TASK(loop) {
156157

157158
ESOS_TASK_WAIT_ON_SEND_UINT16_AS_HEX_STRING(u16_data); //extra zeros but acceptable
158159

159-
ESOS_ALLOCATE_CHILD_TASK(th_child);
160-
ESOS_TASK_SPAWN_AND_WAIT(th_child, barGraph_child, u16_data);
160+
ESOS_ALLOCATE_CHILD_TASK(th_child_bar_graph);
161+
ESOS_TASK_SPAWN_AND_WAIT(th_child_bar_graph, barGraph_child, u16_data);
161162

162163
ESOS_TASK_WAIT_ON_SEND_STRING("\n");
163164
ESOS_TASK_WAIT_ON_SEND_STRING(buffer); //wait for data in buffer to be sent and release UART
@@ -172,19 +173,18 @@ ESOS_USER_TASK(loop) {
172173
ESOS_TASK_WAIT_UNTIL(esos_uiF14_isSW2Released());
173174
b_keepLooping = FALSE;
174175
}
175-
176176
if (esos_uiF14_isSW3Pressed()){ //sw1 will stop the sw2 initiated continous looping
177177
ESOS_TASK_WAIT_UNTIL(esos_uiF14_isSW3Released());
178178
b_keepLooping = FALSE;
179-
ESOS_TASK_SPAWN_AND_WAIT(th_child, menu);
179+
ESOS_ALLOCATE_CHILD_TASK(th_child_menu);
180+
ESOS_TASK_SPAWN_AND_WAIT(th_child_menu, menu);
180181
}
181182
ESOS_TASK_WAIT_TICKS(LOOP_DELAY /2); //the other half of the loop sw2 sensor reading delay
182183
}while(b_keepLooping); //keep doing the DO loop if sw2 initiated it
183-
184+
184185
//Release the potentiometer
185186
ESOS_SENSOR_CLOSE();
186-
}
187-
}
187+
}
188188
ESOS_TASK_END();
189189
}
190190

0 commit comments

Comments
 (0)