forked from UltraFX/eq3-thermostat-alt-fw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelN_Menu.c
140 lines (127 loc) · 2.25 KB
/
ModelN_Menu.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "main.h"
static menu_t eState = MENU_INIT;
void ModelN_Menu(void)
{
static uint8_t bySleep = 1;
static uint8_t byTimer = 0;
static uint16_t wCount = 0;
static uint8_t byChoice = 0;
static int8_t iEncValue = 0;
static uint16_t iTempSet = 0;
Disp_Clear();
Disp_Date(sProtocol.byWeekDay);
Disp_Bargraph_number(sProtocol.bySignal);
switch(eState)
{
case MENU_INIT:
ModelN_Init();
eState = INIT_ENTRANCE;
break;
case MENU_CALIBRATE:
while(ModelN_Calib() != 0);
eState = MENU_SHOW_TIME;
break;
case MENU_SHOW_TIME:
Display_Time();
bySleep = 1;
break;
case MENU_SHOW_TEMP_CUR:
Display_Temperature(TEMP_CURRENT);
bySleep = 1;
break;
case MENU_SHOW_TEMP_SET:
Display_Temperature(TEMP_SET);
bySleep = 1;
break;
case MENU_SHOW_TEMP_OUT:
Display_Temperature(TEMP_OUTSIDE);
bySleep = 1;
break;
case MENU_SHOW_HUMID:
Display_Humidity();
bySleep = 1;
break;
case MENU_SET_TEMP:
if(iTempSet == 0)
{
iTempSet = sProtocol.iTempSet;
}
wCount++;
Disp_Decpoint(2, 1);
Disp_Number(2, iTempSet / 100);
Disp_Number(3, (iTempSet % 100) / 10);
Disp_Number(4, (iTempSet % 100) % 10);
if(byChoice == 0)
{
Disp_Symbol(SYMBOL_DEGREE, 1);
}
if(wCount >= MENU_BLINK)
{
wCount = 0;
byChoice ^= 1;
}
iEncValue += UI_Encoder_Read();
if(iEncValue <= -4)
{
UI_Timeout_Reset();
if(iTempSet > 150)
{
iTempSet -= 5;
}
iEncValue = 0;
}
if(iEncValue >= 4)
{
UI_Timeout_Reset();
if(iTempSet < 350)
{
iTempSet += 5;
}
iEncValue = 0;
}
if(UI_Buttons_Get(BUTTON1) == 1)
{
sProtocol.iTempSet = iTempSet;
iTempSet = 0;
byRunning = 0;
ModelN_Menu_Set_State(MENU_SHOW_TEMP_SET);
}
break;
default:
eState = MENU_INIT;
break;
}
if(bySleep == 1 && byRunning == 0)
{
if(iTempSet != 0)
{
iTempSet = 0;
}
byTimer++;
if(byTimer == MENU_CHANGE)
{
byTimer = 0;
if(eState < MENU_SHOW_HUMID)
{
eState++;
}
else
{
eState = MENU_SHOW_TIME;
}
byTimer = 0;
}
RTC_SetWakeUpCounter(2047);
RTC_WakeUpCmd(ENABLE);
halt();
RTC_WakeUpCmd(DISABLE);
}
}
void ModelN_Menu_Set_State(menu_t eNewState)
{
eState = eNewState;
}
menu_t ModelN_Menu_Get_State(void)
{
return eState;
}