-
Notifications
You must be signed in to change notification settings - Fork 23
/
ts.c
82 lines (73 loc) · 2.51 KB
/
ts.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
/*
* This file is part of the W1209 firmware replacement project
* (https://github.com/mister-grumbler/w1209-firmware).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "adc.h"
#include "buttons.h"
#include "display.h"
#include "menu.h"
#include "params.h"
#include "relay.h"
#include "timer.h"
#define INTERRUPT_ENABLE __asm rim __endasm;
#define INTERRUPT_DISABLE __asm sim __endasm;
#define WAIT_FOR_INTERRUPT __asm wfi __endasm;
/**
* @brief
*/
int main()
{
static unsigned char* stringBuffer[7];
unsigned char paramMsg[] = {'P', '0', 0};
initMenu();
initButtons();
initParamsEEPROM();
initDisplay();
initADC();
initRelay();
initTimer();
INTERRUPT_ENABLE
// Loop
while (true) {
if (getUptimeSeconds() > 0) {
setDisplayTestMode (false, "");
}
if (getMenuDisplay() == MENU_ROOT) {
int temp = getTemperature();
itofpa (temp, (char*) stringBuffer, 0);
setDisplayStr ( (char*) stringBuffer);
if (getParamById (PARAM_OVERHEAT_INDICATION) ) {
if (temp < getParamById (PARAM_MIN_TEMPERATURE) ) {
setDisplayStr ("LLL");
} else if (temp > getParamById (PARAM_MAX_TEMPERATURE) ) {
setDisplayStr ("HHH");
}
}
} else if (getMenuDisplay() == MENU_SET_THRESHOLD) {
paramToString (PARAM_THRESHOLD, (char*) stringBuffer);
setDisplayStr ( (char*) stringBuffer);
} else if (getMenuDisplay() == MENU_SELECT_PARAM) {
paramMsg[1] = '0' + getParamId();
setDisplayStr ( (unsigned char*) ¶mMsg);
} else if (getMenuDisplay() == MENU_CHANGE_PARAM) {
paramToString (getParamId(), (char*) stringBuffer);
setDisplayStr ( (char *) stringBuffer);
} else {
setDisplayStr ("ERR");
setDisplayOff ( (bool) (getUptime() & 0x40) );
}
WAIT_FOR_INTERRUPT
};
}