diff --git a/.vs/AtTiny_alarm_clock/v14/.atsuo b/.vs/AtTiny_alarm_clock/v14/.atsuo new file mode 100644 index 0000000..135d58c Binary files /dev/null and b/.vs/AtTiny_alarm_clock/v14/.atsuo differ diff --git a/AtTiny_alarm_clock.atsln b/AtTiny_alarm_clock.atsln new file mode 100644 index 0000000..0631184 --- /dev/null +++ b/AtTiny_alarm_clock.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "AtTiny_alarm_clock", "AtTiny_alarm_clock.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/AtTiny_alarm_clock.componentinfo.xml b/AtTiny_alarm_clock.componentinfo.xml new file mode 100644 index 0000000..1295b29 --- /dev/null +++ b/AtTiny_alarm_clock.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.3.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include + + include + C + + + include + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include\avr\iotn2313a.h + + header + C + S5kp0bTA63lv+OH62wjqfA== + + include/avr/iotn2313a.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\templates\main.c + template + source + C Exe + 2YdP1NP06ldLfwWqlY0byw== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\templates\main.cpp + template + source + C Exe + YXFphlh0CtZJU+ebktABgQ== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny2313a + + libraryPrefix + GCC + + + gcc/dev/attiny2313a + + + + + ATtiny_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/Atmel.ATtiny_DFP.pdsc + 1.3.172 + true + ATtiny2313A + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/AtTiny_alarm_clock.cproj b/AtTiny_alarm_clock.cproj new file mode 100644 index 0000000..f60c36d --- /dev/null +++ b/AtTiny_alarm_clock.cproj @@ -0,0 +1,128 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny2313A + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + AtTiny_alarm_clock + AtTiny_alarm_clock + AtTiny_alarm_clock + Native + true + false + true + true + + + true + + 2 + 0 + 0 + + + + + + + + + + + + + + + + + + -mmcu=attiny2313a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny2313a" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\include + + + + + + + + + -mmcu=attiny2313a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny2313a" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\include + + + Default (-Wa,-g) + + + + + + compile + + + + \ No newline at end of file diff --git a/main.c b/main.c index 7803561..5b8686e 100644 --- a/main.c +++ b/main.c @@ -1,100 +1,18 @@ /* - * GccApplication1.c + * AtTiny_alarm_clock.c * - * Created: 10.07.2018 19:39:28 + * Created: 16.07.2018 13:55:13 * Author : dozed */ -#define button1 1234 -#define button2 5678 -#define button3 whatever +#include -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; - -int counter = 0; //the counter variable that is being set by the interrupt -//variables for the alarm -bool alarm_active = false; -bool alarm_triggered = false; -int alarm_time = 0; - -//variables for the stopwatch -bool stopwatch_running = false; -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---------------- - //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)){ - timer_new_state = CLOCK_ALARM; - } - else if(button_pressed(2){ - //do something - } - 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 >"); - - } + /* Replace with your application code */ + while (1) + { } - //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); } diff --git a/main_old.c b/main_old.c new file mode 100644 index 0000000..7803561 --- /dev/null +++ b/main_old.c @@ -0,0 +1,100 @@ +/* + * GccApplication1.c + * + * Created: 10.07.2018 19:39:28 + * Author : dozed + */ + +#define button1 1234 +#define button2 5678 +#define button3 whatever + +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; + +int counter = 0; //the counter variable that is being set by the interrupt +//variables for the alarm +bool alarm_active = false; +bool alarm_triggered = false; +int alarm_time = 0; + +//variables for the stopwatch +bool stopwatch_running = false; +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---------------- + //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)){ + timer_new_state = CLOCK_ALARM; + } + else if(button_pressed(2){ + //do something + } + 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) + + } +} + +bool button_pressed(int button_number) +{ + bool button_state = /*check the state of the button here*/; + return(button_state); +} +