Added WAIT state to runStopLightTask2 to be closer to the intended solution
This commit is contained in:
parent
1720365a53
commit
61c444beda
@ -14,7 +14,7 @@
|
|||||||
enum{
|
enum{
|
||||||
S1_GREEN, S1_YELLOW, S1_RED, S1_RED_YELLOW,
|
S1_GREEN, S1_YELLOW, S1_RED, S1_RED_YELLOW,
|
||||||
S2_GREEN, S2_YELLOW, S2_RED, S2_RED_YELLOW,
|
S2_GREEN, S2_YELLOW, S2_RED, S2_RED_YELLOW,
|
||||||
INIT,
|
INIT, WAIT
|
||||||
} StoplightState = INIT; /* Emus for the stoplight task (task 3) */
|
} StoplightState = INIT; /* Emus for the stoplight task (task 3) */
|
||||||
|
|
||||||
|
|
||||||
@ -26,12 +26,6 @@ enum{
|
|||||||
SL 1 | Led1 | Led4 | Led6
|
SL 1 | Led1 | Led4 | Led6
|
||||||
SL 2 | Led2 | Led5 | Led7
|
SL 2 | Led2 | Led5 | Led7
|
||||||
|
|
||||||
General rundown:
|
|
||||||
- State is entered
|
|
||||||
- Wait till delay is passed
|
|
||||||
- Switch off running LEDs
|
|
||||||
- Switch on new LEDs
|
|
||||||
- Set next state
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint16_t g_startMS;
|
uint16_t g_startMS;
|
||||||
@ -133,6 +127,10 @@ runStopLightTask2(void)
|
|||||||
setS1ToGreen();
|
setS1ToGreen();
|
||||||
setS2ToRed();
|
setS2ToRed();
|
||||||
|
|
||||||
|
StoplightState = WAIT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT:
|
||||||
if(Taster1_get()) {
|
if(Taster1_get()) {
|
||||||
g_startMS=Timer_getTick();
|
g_startMS=Timer_getTick();
|
||||||
StoplightState = S1_YELLOW;
|
StoplightState = S1_YELLOW;
|
||||||
@ -186,9 +184,9 @@ runStopLightTask2(void)
|
|||||||
setS1ToGreen();
|
setS1ToGreen();
|
||||||
|
|
||||||
// Wait 30 seconds before allowing the button to be pressed again
|
// Wait 30 seconds before allowing the button to be pressed again
|
||||||
if( (Timer_getTick() - g_startMS >= delayLong) && Taster1_get()) {
|
if(Timer_getTick() - g_startMS >= delayLong) {
|
||||||
g_startMS=Timer_getTick();
|
g_startMS=Timer_getTick();
|
||||||
StoplightState = S1_YELLOW;
|
StoplightState = WAIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user