diff --git a/src/eggTimer.c b/src/eggTimer.c index ffb503b..d476500 100644 --- a/src/eggTimer.c +++ b/src/eggTimer.c @@ -12,9 +12,11 @@ #include "eggTimer.h" #include "displayMuxer.h" #include "button.h" +#include "gpio.h" const uint32_t EGG_TIMER_CYCLE = 1000; +const uint32_t LED_CYCLE = 250; const uint8_t COOKING_TIME = 120; uint8_t restCookingTime; @@ -29,6 +31,10 @@ void eggTimerStart(void *handleArg) { } } +void eggTimerAlarm(void *handleArg) { + gpioTogglePin(LED_1); +} + void eggTimerInit(void *handleArg) { restCookingTime = COOKING_TIME; timerRunning = false; @@ -42,6 +48,7 @@ void eggTimerExec(void *handleArg) { displayMuxerSetValue(restCookingTime, true, TIMER_MUX); if (restCookingTime == 0) { // activate alarm + schAdd(eggTimerAlarm, NULL, 0, LED_CYCLE); timerRunning = false; } } diff --git a/src/gpio.c b/src/gpio.c index 46d5812..4d64ed6 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -77,6 +77,15 @@ void gpioSetPin(tPin p, tPinState v) { } } +void gpioTogglePin(tPin p) { + tPinCfg pin = pinCfg[p]; + if (pin.portId == PORT1) { + P1OUT ^= pin.bit; + } else if (pin.portId == PORT2) { + P2OUT ^= pin.bit; + } +} + tPinState gpioGetPin(tPin p) { tPinCfg pin = pinCfg[p]; uint16_t pinValue = 0; diff --git a/src/gpio.h b/src/gpio.h index 4bef9ea..ffae80c 100644 --- a/src/gpio.h +++ b/src/gpio.h @@ -50,12 +50,13 @@ typedef enum { DIGIT_0, DIGIT_1, BUTTON_1, - TESTPIN1, + LED_1, PINS_END } tPin; void gpioInitPins(); void gpioSetPin(tPin p, tPinState v); +void gpioTogglePin(tPin p); tPinState gpioGetPin(tPin p);