-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·125 lines (92 loc) · 1.53 KB
/
main.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
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
#include "main.h"
#include "time.h"
#include "config.h"
#include "system.h"
#include "serial.h"
#include "esp12.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <signal.h>
#include <iostream>
using namespace std;
#define TURN_ON_SCALING_FREQ
void terminate(int n);
struct sysConfig_s new_cfg = {
{
"LemonDog",
"WWL001",
"v1.0",
"WWL001_ap",
"123456",
"SiddharthNet",
"siddharth",
{{ 1, 2, 3, 4 }},
80,
{{ 0, 0, 0, 0 }},
0
},
0
};
void sys_setup(char *port)
{
sysConfigInit();
sysParamInit();
calculateChecksum(&new_cfg);
if (loadConfig(&new_cfg)) {
serialPrintln("Failed to Load Config");
terminate();
}
printSysCfg();
setup(port);
delay(100);
}
void sys_loop()
{
unsigned long _ms = millis();
static unsigned long _1Hz_interval;
if (_ms - _1Hz_interval >= 1000) {
loop_1Hz();
_1Hz_interval = _ms;
}
static unsigned long _2Hz_interval;
if (_ms - _2Hz_interval >= 500) {
loop_2Hz();
_2Hz_interval = _ms;
}
static unsigned long _10Hz_interval;
if (_ms - _10Hz_interval >= 100) {
loop_10Hz();
_10Hz_interval = _ms;
}
loop_fast();
}
int _init_()
{
signal(SIGTSTP, SIG_DFL);
return 0;
}
void event()
{
}
int main(int argc, char *argv[])
{
if (_init_()) return -1;
sys_setup(argv[1]);
while (1) {
#ifdef TURN_ON_SCALING_FREQ
scaleDownToFreq(CPU_FREQ);
#endif
sys_loop();
event();
}
return 0;
}
void terminate(int n)
{
cout<<"-----------Terminated-------------"<<endl;
exit(1);
}