started to add alarm feature

This commit is contained in:
Dorian Zedler 2018-07-11 19:41:53 +02:00
parent 38874c6151
commit e38d4bcb71

23
main.c
View file

@ -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)