From e9058086ca79353b59d5093238fd5934e5d3ef30 Mon Sep 17 00:00:00 2001 From: _N0x Date: Thu, 11 Nov 2021 18:46:37 +0100 Subject: [PATCH] Added WAIT state to runStopLightTask2 to be closer to the intended solution --- EmbeddedSystemsTHM/StopLight.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/EmbeddedSystemsTHM/StopLight.c b/EmbeddedSystemsTHM/StopLight.c index e7674f5..87e3211 100644 --- a/EmbeddedSystemsTHM/StopLight.c +++ b/EmbeddedSystemsTHM/StopLight.c @@ -14,7 +14,7 @@ enum{ S1_GREEN, S1_YELLOW, S1_RED, S1_RED_YELLOW, S2_GREEN, S2_YELLOW, S2_RED, S2_RED_YELLOW, - INIT, + INIT, WAIT } StoplightState = INIT; /* Emus for the stoplight task (task 3) */ @@ -133,6 +133,10 @@ runStopLightTask2(void) setS1ToGreen(); setS2ToRed(); + StoplightState = WAIT; + break; + + case WAIT: if(Taster1_get()) { g_startMS=Timer_getTick(); StoplightState = S1_YELLOW; @@ -186,9 +190,9 @@ runStopLightTask2(void) setS1ToGreen(); // 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(); - StoplightState = S1_YELLOW; + StoplightState = WAIT; } break; }