-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.cpp
89 lines (77 loc) · 1.37 KB
/
app.cpp
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
// wifi
#include <ESP8266WiFi.h>
#include "app.h"
// https://www.tinkercad.com/things/dJn6LkhyR5E-interface-test
uint16_t run_time = 0;
// timing
int timezone = 8;
uint32_t epoch = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
uint8_t day = 0;
uint8_t month = 0;
uint16_t year = 0;
void appSetup()
{
ntpSetup();
// srne @ D7 D8
// snat @ D5 D6
if (display_enable)
displayLoop();
// if (dht11_enable)
// dht11Loop();
// if (beep_enable)
// beepSetup();
if (analog_enable)
analogSetup();
if (display_enable)
displaySetup();
// if (ads1115_enable)
// ads1115Setup();
if (srne_enable)
srneSetup();
if (snat_enable)
snatSetup();
}
void appLoop()
{
// static float _prev_device_voltage;
static uint32_t msTick = millis();
// static uint8_t sTick;
if (millis() - msTick >= 1000) // 1000ms refresh rate
{
msTick = millis();
ntpLoop();
if (analog_enable)
analogLoop();
delay(1);
if (srne_enable)
srneLoop();
delay(1);
if (snat_enable)
snatLoop();
if (second >= 59)
{
if (post_enable)
postLoop();
second = 0;
/*
if (minute >= 59)
{
minute = 0;
if (hour >= 23)
{
hour = 0;
}
else
hour++;
}
else
minute++;
*/
}
else
second++;
}
}