From ae95644b995c91b35179aa6f2d3e6b2ddc729d7e Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Tue, 10 Jul 2018 20:33:21 +0200 Subject: [PATCH] added a small skeleton of code --- main.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index bc172b9..2732a2d 100644 --- a/main.c +++ b/main.c @@ -5,15 +5,67 @@ * Author : dozed */ -#include +#define button1 1234 +#define button2 5678 +#define button3 whatever +typedef enum {CLOCK_INIT = 0, CLOCK_IDLE} clock_state_e; + +clock_state_e clock_state = CLOCK_INIT; +clock_state_e clock_new_state = CLOCK_INIT; + +int counter = 0; //the counter variable that is being set by the interrupt int main(void) { - /* Replace with your application code */ - while (1) - { - printf("test"); + //-----------INIT---------------- + //SETUP PINS (needs to be done) + + //attach interrupt (needs to be done) + + //-----------END INIT------------ + while (1) + { + timer_state = timer_new_state; + + switch(clock_state){ + case CLOCK_INIT: + //do some init stuff... + lcd.init(); //I know, it's just c but I don't care + + //INIT done -> change to IDLE + clock_new_state = CLOCK_IDLE; + + break; + + case CLOCK_IDLE: + //IDLE MODE + + //print the IDLE Screen + lcd.goto(0,0); + lcd.print(counter /*do some claculations*/); + lcd.goto(0,1); + lcd.print("< current time >"); + + //check buttons + if(button_pressed(1)){ + //do something + } + else if(button_pressed(2){ + //do something + } + else if(button_pressed(3)){ + //do something + } } + //do some other stuff (like checking if an alarm has been triggered) + + } +} + +bool button_pressed(int button_number) +{ + bool button_state = /*check the state of the button here*/; + return(button_state); }