forked from OskarLundgren/WeatherStation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
76 lines (56 loc) · 1.31 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "system_sam3x.h"
#include "at91sam3x8.h"
#include "Common_Variables.h"
#include "Common_Functions.h"
#include "Display_Module.h"
#include "Keypad_Module.h"
#include "Light_Module.h"
#include "Temp_Module.h"
#include <stdlib.h>
int main(){
SystemInit();
Init_Display();
Init_Temp();
Init_Keypad();
Timer_Setup();
Temp_Measure();
Update_Temp();
Print_Temperature();
Light_Init();
PWM_Setup();
ADC_Setup();
Setup_Interrupts(1);
Print_Menu();
int button;
int alarmActive = 0;
while(1){
if(nInterrupts == 1){
alarmActive ^= 1;
Temp_Measure();
Update_Temp();
Print_Temperature();
if(alarmSet && alarmActive%2==0 && (lowerLimit > temp || higherLimit < temp)){
Temp_Alarm();
}
Setup_Interrupts(1);
}
if(oneMinute == 1){
Log_Temp();
oneMinute = 0;
}
if(tempLogPosition == nSample){
Add_Values();
tempLogPosition = 0;
Reset_TempLog();
if(currentMenu == 1){
Print_Statistics();
}
}
button = Read_Keypad();
if(buttonWasPressed == 1){
buttonWasPressed = 0;
Keypad_Menu_Action(&button);
}
}
return 0;
}