From e38d4bcb7170c2af4214ec30edf1aa843b8a91c2 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 11 Jul 2018 19:41:53 +0200 Subject: [PATCH] started to add alarm feature --- main.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index dd00129..7803561 100644 --- a/main.c +++ b/main.c @@ -9,8 +9,9 @@ #define button2 5678 #define button3 whatever -typedef enum {CLOCK_INIT = 0, CLOCK_IDLE, CLOCK_ALARM} clock_state_e; +typedef enum {CLOCK_INIT = 0, CLOCK_IDLE, CLOCK_ALARM, CLOCK_STOPWATCH_RUNNING, CLOCK_STOPWATCH_STOPPED, CLOCK_STOPWATCH_NOT_SET, CLOCK_USER_INPUT, CLOCK_SET_TIME} clock_state_e; +clock_state_e clock_old_state = NULL; clock_state_e clock_state = CLOCK_INIT; clock_state_e clock_new_state = CLOCK_INIT; @@ -26,6 +27,9 @@ bool stopwatch_set = false int stopwatch_started = 0; int stopwatch_stopped = 0; +//other variables +int user_input = 0; //variable to store user input +int current_time = 0; int main(void) { //-----------INIT---------------- @@ -59,7 +63,7 @@ int main(void) //check buttons if(button_pressed(1)){ - //do something + timer_new_state = CLOCK_ALARM; } else if(button_pressed(2){ //do something @@ -67,6 +71,21 @@ int main(void) else if(button_pressed(3)){ //do something } + + case CLOCK_ALARM: + //CLOCK ALARM + //check if the alarm time was set + if(user_input == 0){ + alarm_time = user_input; + user_input = 0; + } + if(alarm_active){ + lcd.goto(0,0); + lcd.print(current_time); + lcd.goto(0,1); + lcd.print("alarm >"); + + } } //do some other stuff (like checking if an alarm has been triggered)