mirror of
https://github.com/0x1d/esp8266-laser.git
synced 2025-12-15 18:38:20 +01:00
added preset feauture (not completed)
This commit is contained in:
@@ -21,6 +21,10 @@ HTTP endpoints:
|
|||||||
/resetwifi -> POST reconnect wifi (similar to wificonfig->apply=true)
|
/resetwifi -> POST reconnect wifi (similar to wificonfig->apply=true)
|
||||||
/heap -> GET returns free heap of the ESP8266
|
/heap -> GET returns free heap of the ESP8266
|
||||||
/files -> GET returns list of files
|
/files -> GET returns list of files
|
||||||
|
/presetMode -> GET returns current mode 0: presetsOff 1: cycle (not completed feature)
|
||||||
|
POST sets mode (see above)
|
||||||
|
/presets -> GET returns /presets.json
|
||||||
|
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
- install arduino ide (1.8.5) or PlatformIO (see Development section for further instructions)
|
- install arduino ide (1.8.5) or PlatformIO (see Development section for further instructions)
|
||||||
|
|||||||
772
config/presets.json
Normal file
772
config/presets.json
Normal file
@@ -0,0 +1,772 @@
|
|||||||
|
{
|
||||||
|
"presets": {
|
||||||
|
"0": [
|
||||||
|
106,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109
|
||||||
|
],
|
||||||
|
"1": [
|
||||||
|
62,
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65
|
||||||
|
],
|
||||||
|
"2": [
|
||||||
|
67,
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
70
|
||||||
|
],
|
||||||
|
"3": [
|
||||||
|
80,
|
||||||
|
81,
|
||||||
|
82,
|
||||||
|
83
|
||||||
|
],
|
||||||
|
"4": [
|
||||||
|
73,
|
||||||
|
74,
|
||||||
|
75,
|
||||||
|
76
|
||||||
|
],
|
||||||
|
"5": [
|
||||||
|
65,
|
||||||
|
66,
|
||||||
|
67,
|
||||||
|
68
|
||||||
|
],
|
||||||
|
"6": [
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25
|
||||||
|
],
|
||||||
|
"7": [
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14
|
||||||
|
],
|
||||||
|
"8": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"9": [
|
||||||
|
85,
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88
|
||||||
|
],
|
||||||
|
"10": [
|
||||||
|
47,
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50
|
||||||
|
],
|
||||||
|
"11": [
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
94,
|
||||||
|
95
|
||||||
|
],
|
||||||
|
"12": [
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"13": [
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22
|
||||||
|
],
|
||||||
|
"14": [
|
||||||
|
77,
|
||||||
|
78,
|
||||||
|
79,
|
||||||
|
80
|
||||||
|
],
|
||||||
|
"15": [
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25
|
||||||
|
],
|
||||||
|
"16": [
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121,
|
||||||
|
122
|
||||||
|
],
|
||||||
|
"17": [
|
||||||
|
60,
|
||||||
|
61,
|
||||||
|
62,
|
||||||
|
63
|
||||||
|
],
|
||||||
|
"18": [
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114
|
||||||
|
],
|
||||||
|
"19": [
|
||||||
|
75,
|
||||||
|
76,
|
||||||
|
77,
|
||||||
|
78
|
||||||
|
],
|
||||||
|
"20": [
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24
|
||||||
|
],
|
||||||
|
"21": [
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35
|
||||||
|
],
|
||||||
|
"22": [
|
||||||
|
67,
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
70
|
||||||
|
],
|
||||||
|
"23": [
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30
|
||||||
|
],
|
||||||
|
"24": [
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6
|
||||||
|
],
|
||||||
|
"25": [
|
||||||
|
57,
|
||||||
|
58,
|
||||||
|
59,
|
||||||
|
60
|
||||||
|
],
|
||||||
|
"26": [
|
||||||
|
56,
|
||||||
|
57,
|
||||||
|
58,
|
||||||
|
59
|
||||||
|
],
|
||||||
|
"27": [
|
||||||
|
72,
|
||||||
|
73,
|
||||||
|
74,
|
||||||
|
75
|
||||||
|
],
|
||||||
|
"28": [
|
||||||
|
114,
|
||||||
|
115,
|
||||||
|
116,
|
||||||
|
117
|
||||||
|
],
|
||||||
|
"29": [
|
||||||
|
70,
|
||||||
|
71,
|
||||||
|
72,
|
||||||
|
73
|
||||||
|
],
|
||||||
|
"30": [
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
89
|
||||||
|
],
|
||||||
|
"31": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"32": [
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"33": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"34": [
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40
|
||||||
|
],
|
||||||
|
"35": [
|
||||||
|
71,
|
||||||
|
72,
|
||||||
|
73,
|
||||||
|
74
|
||||||
|
],
|
||||||
|
"36": [
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"37": [
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28
|
||||||
|
],
|
||||||
|
"38": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"39": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"40": [
|
||||||
|
115,
|
||||||
|
116,
|
||||||
|
117,
|
||||||
|
118
|
||||||
|
],
|
||||||
|
"41": [
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114
|
||||||
|
],
|
||||||
|
"42": [
|
||||||
|
59,
|
||||||
|
60,
|
||||||
|
61,
|
||||||
|
62
|
||||||
|
],
|
||||||
|
"43": [
|
||||||
|
106,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109
|
||||||
|
],
|
||||||
|
"44": [
|
||||||
|
31,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34
|
||||||
|
],
|
||||||
|
"45": [
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25
|
||||||
|
],
|
||||||
|
"46": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"47": [
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"48": [
|
||||||
|
110,
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113
|
||||||
|
],
|
||||||
|
"49": [
|
||||||
|
97,
|
||||||
|
98,
|
||||||
|
99,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"50": [
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52
|
||||||
|
],
|
||||||
|
"51": [
|
||||||
|
99,
|
||||||
|
100,
|
||||||
|
101,
|
||||||
|
102
|
||||||
|
],
|
||||||
|
"52": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"53": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"54": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"55": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"56": [
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13
|
||||||
|
],
|
||||||
|
"57": [
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5
|
||||||
|
],
|
||||||
|
"58": [
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51
|
||||||
|
],
|
||||||
|
"59": [
|
||||||
|
109,
|
||||||
|
110,
|
||||||
|
111,
|
||||||
|
112
|
||||||
|
],
|
||||||
|
"60": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"61": [
|
||||||
|
83,
|
||||||
|
84,
|
||||||
|
85,
|
||||||
|
86
|
||||||
|
],
|
||||||
|
"62": [
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18
|
||||||
|
],
|
||||||
|
"63": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"64": [
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"65": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"66": [
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
70,
|
||||||
|
71
|
||||||
|
],
|
||||||
|
"67": [
|
||||||
|
103,
|
||||||
|
104,
|
||||||
|
105,
|
||||||
|
106
|
||||||
|
],
|
||||||
|
"68": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"69": [
|
||||||
|
88,
|
||||||
|
89,
|
||||||
|
90,
|
||||||
|
91
|
||||||
|
],
|
||||||
|
"70": [
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19
|
||||||
|
],
|
||||||
|
"71": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"72": [
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21
|
||||||
|
],
|
||||||
|
"73": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"74": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"75": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"76": [
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65,
|
||||||
|
66
|
||||||
|
],
|
||||||
|
"77": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"78": [
|
||||||
|
120,
|
||||||
|
121,
|
||||||
|
122,
|
||||||
|
123
|
||||||
|
],
|
||||||
|
"79": [
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52
|
||||||
|
],
|
||||||
|
"80": [
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114
|
||||||
|
],
|
||||||
|
"81": [
|
||||||
|
57,
|
||||||
|
58,
|
||||||
|
59,
|
||||||
|
60
|
||||||
|
],
|
||||||
|
"82": [
|
||||||
|
102,
|
||||||
|
103,
|
||||||
|
104,
|
||||||
|
105
|
||||||
|
],
|
||||||
|
"83": [
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23
|
||||||
|
],
|
||||||
|
"84": [
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21
|
||||||
|
],
|
||||||
|
"85": [
|
||||||
|
69,
|
||||||
|
70,
|
||||||
|
71,
|
||||||
|
72
|
||||||
|
],
|
||||||
|
"86": [
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48
|
||||||
|
],
|
||||||
|
"87": [
|
||||||
|
110,
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113
|
||||||
|
],
|
||||||
|
"88": [
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12
|
||||||
|
],
|
||||||
|
"89": [
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28
|
||||||
|
],
|
||||||
|
"90": [
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
94,
|
||||||
|
95
|
||||||
|
],
|
||||||
|
"91": [
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"92": [
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23
|
||||||
|
],
|
||||||
|
"93": [
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"94": [
|
||||||
|
106,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109
|
||||||
|
],
|
||||||
|
"95": [
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65,
|
||||||
|
66
|
||||||
|
],
|
||||||
|
"96": [
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28
|
||||||
|
],
|
||||||
|
"97": [
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
89,
|
||||||
|
90
|
||||||
|
],
|
||||||
|
"98": [
|
||||||
|
72,
|
||||||
|
73,
|
||||||
|
74,
|
||||||
|
75
|
||||||
|
],
|
||||||
|
"99": [
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30
|
||||||
|
],
|
||||||
|
"100": [
|
||||||
|
53,
|
||||||
|
54,
|
||||||
|
55,
|
||||||
|
56
|
||||||
|
],
|
||||||
|
"101": [
|
||||||
|
51,
|
||||||
|
52,
|
||||||
|
53,
|
||||||
|
54
|
||||||
|
],
|
||||||
|
"102": [
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9
|
||||||
|
],
|
||||||
|
"103": [
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48
|
||||||
|
],
|
||||||
|
"104": [
|
||||||
|
91,
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
94
|
||||||
|
],
|
||||||
|
"105": [
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51
|
||||||
|
],
|
||||||
|
"106": [
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18
|
||||||
|
],
|
||||||
|
"107": [
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15
|
||||||
|
],
|
||||||
|
"108": [
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9
|
||||||
|
],
|
||||||
|
"109": [
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27
|
||||||
|
],
|
||||||
|
"110": [
|
||||||
|
99,
|
||||||
|
100,
|
||||||
|
101,
|
||||||
|
102
|
||||||
|
],
|
||||||
|
"111": [
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40
|
||||||
|
],
|
||||||
|
"112": [
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
89
|
||||||
|
],
|
||||||
|
"113": [
|
||||||
|
84,
|
||||||
|
85,
|
||||||
|
86,
|
||||||
|
87
|
||||||
|
],
|
||||||
|
"114": [
|
||||||
|
90,
|
||||||
|
91,
|
||||||
|
92,
|
||||||
|
93
|
||||||
|
],
|
||||||
|
"115": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"116": [
|
||||||
|
121,
|
||||||
|
122,
|
||||||
|
123,
|
||||||
|
124
|
||||||
|
],
|
||||||
|
"117": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"118": [
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20
|
||||||
|
],
|
||||||
|
"119": [
|
||||||
|
54,
|
||||||
|
55,
|
||||||
|
56,
|
||||||
|
57
|
||||||
|
],
|
||||||
|
"120": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"121": [
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109,
|
||||||
|
110
|
||||||
|
],
|
||||||
|
"122": [
|
||||||
|
90,
|
||||||
|
91,
|
||||||
|
92,
|
||||||
|
93
|
||||||
|
],
|
||||||
|
"123": [
|
||||||
|
62,
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65
|
||||||
|
],
|
||||||
|
"124": [
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35
|
||||||
|
],
|
||||||
|
"125": [
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19
|
||||||
|
],
|
||||||
|
"126": [
|
||||||
|
123,
|
||||||
|
124,
|
||||||
|
125,
|
||||||
|
126
|
||||||
|
],
|
||||||
|
"127": [
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115,
|
||||||
|
116
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
772
data/presets.json
Normal file
772
data/presets.json
Normal file
@@ -0,0 +1,772 @@
|
|||||||
|
{
|
||||||
|
"presets": {
|
||||||
|
"0": [
|
||||||
|
106,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109
|
||||||
|
],
|
||||||
|
"1": [
|
||||||
|
62,
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65
|
||||||
|
],
|
||||||
|
"2": [
|
||||||
|
67,
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
70
|
||||||
|
],
|
||||||
|
"3": [
|
||||||
|
80,
|
||||||
|
81,
|
||||||
|
82,
|
||||||
|
83
|
||||||
|
],
|
||||||
|
"4": [
|
||||||
|
73,
|
||||||
|
74,
|
||||||
|
75,
|
||||||
|
76
|
||||||
|
],
|
||||||
|
"5": [
|
||||||
|
65,
|
||||||
|
66,
|
||||||
|
67,
|
||||||
|
68
|
||||||
|
],
|
||||||
|
"6": [
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25
|
||||||
|
],
|
||||||
|
"7": [
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14
|
||||||
|
],
|
||||||
|
"8": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"9": [
|
||||||
|
85,
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88
|
||||||
|
],
|
||||||
|
"10": [
|
||||||
|
47,
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50
|
||||||
|
],
|
||||||
|
"11": [
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
94,
|
||||||
|
95
|
||||||
|
],
|
||||||
|
"12": [
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"13": [
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22
|
||||||
|
],
|
||||||
|
"14": [
|
||||||
|
77,
|
||||||
|
78,
|
||||||
|
79,
|
||||||
|
80
|
||||||
|
],
|
||||||
|
"15": [
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25
|
||||||
|
],
|
||||||
|
"16": [
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121,
|
||||||
|
122
|
||||||
|
],
|
||||||
|
"17": [
|
||||||
|
60,
|
||||||
|
61,
|
||||||
|
62,
|
||||||
|
63
|
||||||
|
],
|
||||||
|
"18": [
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114
|
||||||
|
],
|
||||||
|
"19": [
|
||||||
|
75,
|
||||||
|
76,
|
||||||
|
77,
|
||||||
|
78
|
||||||
|
],
|
||||||
|
"20": [
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24
|
||||||
|
],
|
||||||
|
"21": [
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35
|
||||||
|
],
|
||||||
|
"22": [
|
||||||
|
67,
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
70
|
||||||
|
],
|
||||||
|
"23": [
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30
|
||||||
|
],
|
||||||
|
"24": [
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6
|
||||||
|
],
|
||||||
|
"25": [
|
||||||
|
57,
|
||||||
|
58,
|
||||||
|
59,
|
||||||
|
60
|
||||||
|
],
|
||||||
|
"26": [
|
||||||
|
56,
|
||||||
|
57,
|
||||||
|
58,
|
||||||
|
59
|
||||||
|
],
|
||||||
|
"27": [
|
||||||
|
72,
|
||||||
|
73,
|
||||||
|
74,
|
||||||
|
75
|
||||||
|
],
|
||||||
|
"28": [
|
||||||
|
114,
|
||||||
|
115,
|
||||||
|
116,
|
||||||
|
117
|
||||||
|
],
|
||||||
|
"29": [
|
||||||
|
70,
|
||||||
|
71,
|
||||||
|
72,
|
||||||
|
73
|
||||||
|
],
|
||||||
|
"30": [
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
89
|
||||||
|
],
|
||||||
|
"31": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"32": [
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"33": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"34": [
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40
|
||||||
|
],
|
||||||
|
"35": [
|
||||||
|
71,
|
||||||
|
72,
|
||||||
|
73,
|
||||||
|
74
|
||||||
|
],
|
||||||
|
"36": [
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"37": [
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28
|
||||||
|
],
|
||||||
|
"38": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"39": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"40": [
|
||||||
|
115,
|
||||||
|
116,
|
||||||
|
117,
|
||||||
|
118
|
||||||
|
],
|
||||||
|
"41": [
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114
|
||||||
|
],
|
||||||
|
"42": [
|
||||||
|
59,
|
||||||
|
60,
|
||||||
|
61,
|
||||||
|
62
|
||||||
|
],
|
||||||
|
"43": [
|
||||||
|
106,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109
|
||||||
|
],
|
||||||
|
"44": [
|
||||||
|
31,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34
|
||||||
|
],
|
||||||
|
"45": [
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25
|
||||||
|
],
|
||||||
|
"46": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"47": [
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"48": [
|
||||||
|
110,
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113
|
||||||
|
],
|
||||||
|
"49": [
|
||||||
|
97,
|
||||||
|
98,
|
||||||
|
99,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"50": [
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52
|
||||||
|
],
|
||||||
|
"51": [
|
||||||
|
99,
|
||||||
|
100,
|
||||||
|
101,
|
||||||
|
102
|
||||||
|
],
|
||||||
|
"52": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"53": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"54": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"55": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"56": [
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13
|
||||||
|
],
|
||||||
|
"57": [
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5
|
||||||
|
],
|
||||||
|
"58": [
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51
|
||||||
|
],
|
||||||
|
"59": [
|
||||||
|
109,
|
||||||
|
110,
|
||||||
|
111,
|
||||||
|
112
|
||||||
|
],
|
||||||
|
"60": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"61": [
|
||||||
|
83,
|
||||||
|
84,
|
||||||
|
85,
|
||||||
|
86
|
||||||
|
],
|
||||||
|
"62": [
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18
|
||||||
|
],
|
||||||
|
"63": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"64": [
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"65": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"66": [
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
70,
|
||||||
|
71
|
||||||
|
],
|
||||||
|
"67": [
|
||||||
|
103,
|
||||||
|
104,
|
||||||
|
105,
|
||||||
|
106
|
||||||
|
],
|
||||||
|
"68": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"69": [
|
||||||
|
88,
|
||||||
|
89,
|
||||||
|
90,
|
||||||
|
91
|
||||||
|
],
|
||||||
|
"70": [
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19
|
||||||
|
],
|
||||||
|
"71": [
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47
|
||||||
|
],
|
||||||
|
"72": [
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21
|
||||||
|
],
|
||||||
|
"73": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"74": [
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115
|
||||||
|
],
|
||||||
|
"75": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"76": [
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65,
|
||||||
|
66
|
||||||
|
],
|
||||||
|
"77": [
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37
|
||||||
|
],
|
||||||
|
"78": [
|
||||||
|
120,
|
||||||
|
121,
|
||||||
|
122,
|
||||||
|
123
|
||||||
|
],
|
||||||
|
"79": [
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52
|
||||||
|
],
|
||||||
|
"80": [
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
114
|
||||||
|
],
|
||||||
|
"81": [
|
||||||
|
57,
|
||||||
|
58,
|
||||||
|
59,
|
||||||
|
60
|
||||||
|
],
|
||||||
|
"82": [
|
||||||
|
102,
|
||||||
|
103,
|
||||||
|
104,
|
||||||
|
105
|
||||||
|
],
|
||||||
|
"83": [
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23
|
||||||
|
],
|
||||||
|
"84": [
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21
|
||||||
|
],
|
||||||
|
"85": [
|
||||||
|
69,
|
||||||
|
70,
|
||||||
|
71,
|
||||||
|
72
|
||||||
|
],
|
||||||
|
"86": [
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48
|
||||||
|
],
|
||||||
|
"87": [
|
||||||
|
110,
|
||||||
|
111,
|
||||||
|
112,
|
||||||
|
113
|
||||||
|
],
|
||||||
|
"88": [
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12
|
||||||
|
],
|
||||||
|
"89": [
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28
|
||||||
|
],
|
||||||
|
"90": [
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
94,
|
||||||
|
95
|
||||||
|
],
|
||||||
|
"91": [
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"92": [
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23
|
||||||
|
],
|
||||||
|
"93": [
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10
|
||||||
|
],
|
||||||
|
"94": [
|
||||||
|
106,
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109
|
||||||
|
],
|
||||||
|
"95": [
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65,
|
||||||
|
66
|
||||||
|
],
|
||||||
|
"96": [
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28
|
||||||
|
],
|
||||||
|
"97": [
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
89,
|
||||||
|
90
|
||||||
|
],
|
||||||
|
"98": [
|
||||||
|
72,
|
||||||
|
73,
|
||||||
|
74,
|
||||||
|
75
|
||||||
|
],
|
||||||
|
"99": [
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30
|
||||||
|
],
|
||||||
|
"100": [
|
||||||
|
53,
|
||||||
|
54,
|
||||||
|
55,
|
||||||
|
56
|
||||||
|
],
|
||||||
|
"101": [
|
||||||
|
51,
|
||||||
|
52,
|
||||||
|
53,
|
||||||
|
54
|
||||||
|
],
|
||||||
|
"102": [
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9
|
||||||
|
],
|
||||||
|
"103": [
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48
|
||||||
|
],
|
||||||
|
"104": [
|
||||||
|
91,
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
94
|
||||||
|
],
|
||||||
|
"105": [
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51
|
||||||
|
],
|
||||||
|
"106": [
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18
|
||||||
|
],
|
||||||
|
"107": [
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15
|
||||||
|
],
|
||||||
|
"108": [
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9
|
||||||
|
],
|
||||||
|
"109": [
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27
|
||||||
|
],
|
||||||
|
"110": [
|
||||||
|
99,
|
||||||
|
100,
|
||||||
|
101,
|
||||||
|
102
|
||||||
|
],
|
||||||
|
"111": [
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40
|
||||||
|
],
|
||||||
|
"112": [
|
||||||
|
86,
|
||||||
|
87,
|
||||||
|
88,
|
||||||
|
89
|
||||||
|
],
|
||||||
|
"113": [
|
||||||
|
84,
|
||||||
|
85,
|
||||||
|
86,
|
||||||
|
87
|
||||||
|
],
|
||||||
|
"114": [
|
||||||
|
90,
|
||||||
|
91,
|
||||||
|
92,
|
||||||
|
93
|
||||||
|
],
|
||||||
|
"115": [
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
"116": [
|
||||||
|
121,
|
||||||
|
122,
|
||||||
|
123,
|
||||||
|
124
|
||||||
|
],
|
||||||
|
"117": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"118": [
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20
|
||||||
|
],
|
||||||
|
"119": [
|
||||||
|
54,
|
||||||
|
55,
|
||||||
|
56,
|
||||||
|
57
|
||||||
|
],
|
||||||
|
"120": [
|
||||||
|
118,
|
||||||
|
119,
|
||||||
|
120,
|
||||||
|
121
|
||||||
|
],
|
||||||
|
"121": [
|
||||||
|
107,
|
||||||
|
108,
|
||||||
|
109,
|
||||||
|
110
|
||||||
|
],
|
||||||
|
"122": [
|
||||||
|
90,
|
||||||
|
91,
|
||||||
|
92,
|
||||||
|
93
|
||||||
|
],
|
||||||
|
"123": [
|
||||||
|
62,
|
||||||
|
63,
|
||||||
|
64,
|
||||||
|
65
|
||||||
|
],
|
||||||
|
"124": [
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35
|
||||||
|
],
|
||||||
|
"125": [
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19
|
||||||
|
],
|
||||||
|
"126": [
|
||||||
|
123,
|
||||||
|
124,
|
||||||
|
125,
|
||||||
|
126
|
||||||
|
],
|
||||||
|
"127": [
|
||||||
|
113,
|
||||||
|
114,
|
||||||
|
115,
|
||||||
|
116
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,9 +34,19 @@ const char *myHostname = "esplaser";
|
|||||||
// SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64);
|
// SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64);
|
||||||
SoftwareSerial laserSerial(14, 12, false, 256);
|
SoftwareSerial laserSerial(14, 12, false, 256);
|
||||||
|
|
||||||
|
// Presets json buffer
|
||||||
|
const unsigned int maxPresets = 128; // 128 = 19496, 200 = 29864
|
||||||
|
|
||||||
|
// Preset cycleTime
|
||||||
|
unsigned int cycleTime = 1000; // ms
|
||||||
/*
|
/*
|
||||||
End of hard coded config
|
End of hard coded config
|
||||||
*/
|
*/
|
||||||
|
const unsigned int presetsBufferSize = maxPresets * JSON_ARRAY_SIZE(4) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(maxPresets) + 1000;
|
||||||
|
|
||||||
|
byte presets[maxPresets][4] = {1, 1, 1, 128};
|
||||||
|
unsigned int activePreset = 0;
|
||||||
|
unsigned int presetMode = 0;
|
||||||
|
|
||||||
String ssid = "";
|
String ssid = "";
|
||||||
String password = "";
|
String password = "";
|
||||||
@@ -121,6 +131,20 @@ void hReadSpiro()
|
|||||||
responseBuffer = String();
|
responseBuffer = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hReadPresets()
|
||||||
|
{
|
||||||
|
// streamFile instead of rebuild json string
|
||||||
|
String path = "/presets.json";
|
||||||
|
String contentType = getContentType(path);
|
||||||
|
if (SPIFFS.exists(path)) {
|
||||||
|
File file = SPIFFS.open(path, "r");
|
||||||
|
size_t sent = server.streamFile(file, contentType);
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void hWriteSpiro()
|
void hWriteSpiro()
|
||||||
{
|
{
|
||||||
String responseBuffer = String();
|
String responseBuffer = String();
|
||||||
@@ -130,34 +154,34 @@ void hWriteSpiro()
|
|||||||
if (server.hasArg("laser") ) {
|
if (server.hasArg("laser") ) {
|
||||||
lmValues[0] = server.arg("laser").toInt();
|
lmValues[0] = server.arg("laser").toInt();
|
||||||
data["laser"] = (String)lmValues[0];
|
data["laser"] = (String)lmValues[0];
|
||||||
String msg = "AT SLV ";
|
String msg = "AT SLV ";
|
||||||
msg += (String)lmValues[0];
|
msg += (String)lmValues[0];
|
||||||
laserSerial.println(msg);
|
laserSerial.println(msg);
|
||||||
delay(20);
|
delay(20);
|
||||||
}
|
}
|
||||||
if (server.hasArg("motor1") ) {
|
if (server.hasArg("motor1") ) {
|
||||||
lmValues[1] = server.arg("motor1").toInt();
|
lmValues[1] = server.arg("motor1").toInt();
|
||||||
data["motor1"] = (String)lmValues[1];
|
data["motor1"] = (String)lmValues[1];
|
||||||
String msg = "AT SMS 1 ";
|
String msg = "AT SMS 1 ";
|
||||||
msg += (String)lmValues[1];
|
msg += (String)lmValues[1];
|
||||||
laserSerial.println(msg);
|
laserSerial.println(msg);
|
||||||
delay(20);
|
delay(20);
|
||||||
}
|
}
|
||||||
if (server.hasArg("motor2") ) {
|
if (server.hasArg("motor2") ) {
|
||||||
lmValues[2] = server.arg("motor2").toInt();
|
lmValues[2] = server.arg("motor2").toInt();
|
||||||
data["motor2"] = (String)lmValues[2];
|
data["motor2"] = (String)lmValues[2];
|
||||||
String msg = "AT SMS 2 ";
|
String msg = "AT SMS 2 ";
|
||||||
msg += (String)lmValues[2];
|
msg += (String)lmValues[2];
|
||||||
laserSerial.println(msg);
|
laserSerial.println(msg);
|
||||||
delay(20);
|
delay(20);
|
||||||
}
|
}
|
||||||
if (server.hasArg("motor3") ) {
|
if (server.hasArg("motor3") ) {
|
||||||
lmValues[3] = server.arg("motor3").toInt();
|
lmValues[3] = server.arg("motor3").toInt();
|
||||||
data["motor3"] = (String)lmValues[3];
|
data["motor3"] = (String)lmValues[3];
|
||||||
String msg = "AT SMS 3 ";
|
String msg = "AT SMS 3 ";
|
||||||
msg += (String)lmValues[3];
|
msg += (String)lmValues[3];
|
||||||
laserSerial.println(msg);
|
laserSerial.println(msg);
|
||||||
delay(20);
|
delay(20);
|
||||||
}
|
}
|
||||||
root.prettyPrintTo(responseBuffer);
|
root.prettyPrintTo(responseBuffer);
|
||||||
server.send(200, "text/json", responseBuffer);
|
server.send(200, "text/json", responseBuffer);
|
||||||
@@ -219,7 +243,7 @@ void hWriteWifi()
|
|||||||
//root.prettyPrintTo(Serial);
|
//root.prettyPrintTo(Serial);
|
||||||
server.send(200, "text/json", responseBuffer);
|
server.send(200, "text/json", responseBuffer);
|
||||||
if (save) {
|
if (save) {
|
||||||
saveConfigFile();
|
saveWifiConfig();
|
||||||
}
|
}
|
||||||
if (apply) {
|
if (apply) {
|
||||||
setupWifi();
|
setupWifi();
|
||||||
@@ -228,14 +252,66 @@ void hWriteWifi()
|
|||||||
responseBuffer = String();
|
responseBuffer = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool saveConfigFile() {
|
boolean readPresetsFile() {
|
||||||
StaticJsonBuffer<200> jsonBuffer;
|
Serial.println("Reading presets.json");
|
||||||
JsonObject& json = jsonBuffer.createObject();
|
File configFile = SPIFFS.open("/presets.json", "r");
|
||||||
json["apMode"] = apMode;
|
if (!configFile) {
|
||||||
json["SSID"] = ssid;
|
Serial.println("Failed to open config file");
|
||||||
json["Password"] = password;
|
return false;
|
||||||
|
}
|
||||||
|
size_t size = configFile.size();
|
||||||
|
if (size > 10024) {
|
||||||
|
Serial.println("Config file size is too large");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Allocate a buffer to store contents of the file.
|
||||||
|
std::unique_ptr<char[]> buf(new char[size]);
|
||||||
|
|
||||||
File configFile = SPIFFS.open("/wifi.json", "w");
|
DynamicJsonBuffer presetsBuffer(presetsBufferSize);
|
||||||
|
configFile.readBytes(buf.get(), size);
|
||||||
|
|
||||||
|
JsonObject& root = presetsBuffer.parseObject(buf.get());
|
||||||
|
//root.prettyPrintTo(Serial);
|
||||||
|
|
||||||
|
JsonObject& sets = root["presets"];
|
||||||
|
|
||||||
|
for (JsonObject::iterator it = sets.begin(); it != sets.end(); ++it)
|
||||||
|
{
|
||||||
|
const char* keyStr = it->key;
|
||||||
|
unsigned int key = atoi(it->key);
|
||||||
|
|
||||||
|
// it->value contains the JsonVariant which can be casted as usual
|
||||||
|
const char* value = it->value;
|
||||||
|
|
||||||
|
JsonArray& values = sets[keyStr];
|
||||||
|
for (int x = 0; x < 4; x++)
|
||||||
|
{
|
||||||
|
presets[key][x] = values[x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!root.success()) {
|
||||||
|
Serial.println("Failed to parse preset config file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool savePresetFile() {
|
||||||
|
DynamicJsonBuffer presetsBuffer(presetsBufferSize);
|
||||||
|
JsonObject& json = presetsBuffer.createObject();
|
||||||
|
JsonObject& sets = json.createNestedObject("presets");
|
||||||
|
for (int i = 0; i < maxPresets; i++)
|
||||||
|
{
|
||||||
|
JsonArray& set = sets.createNestedArray((String)i);
|
||||||
|
for (int x = 0; x < 4; x++)
|
||||||
|
{
|
||||||
|
set.add(presets[i][x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//json.prettyPrintTo(Serial);
|
||||||
|
|
||||||
|
File configFile = SPIFFS.open("/presets.json", "w");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
//Serial.println("Failed to open config file for writing");
|
//Serial.println("Failed to open config file for writing");
|
||||||
return false;
|
return false;
|
||||||
@@ -244,19 +320,7 @@ bool saveConfigFile() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hSaveConf() {
|
boolean readWifiConfig() {
|
||||||
bool success = saveConfigFile();
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
server.send(200, "text/plain", "saved config to file,<br> reset or /resetwifi to apply settings");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server.send(500, "text/plain", "error saving file");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean readConfigFile() {
|
|
||||||
Serial.println("Reading wifi.json");
|
Serial.println("Reading wifi.json");
|
||||||
File configFile = SPIFFS.open("/wifi.json", "r");
|
File configFile = SPIFFS.open("/wifi.json", "r");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
@@ -294,6 +358,44 @@ boolean readConfigFile() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool saveWifiConfig() {
|
||||||
|
StaticJsonBuffer<200> jsonBuffer;
|
||||||
|
JsonObject& json = jsonBuffer.createObject();
|
||||||
|
json["apMode"] = apMode;
|
||||||
|
json["SSID"] = ssid;
|
||||||
|
json["Password"] = password;
|
||||||
|
|
||||||
|
File configFile = SPIFFS.open("/wifi.json", "w");
|
||||||
|
if (!configFile) {
|
||||||
|
//Serial.println("Failed to open config file for writing");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
json.printTo(configFile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void presetToLaser(int nr)
|
||||||
|
{
|
||||||
|
String msg = "AT SLV ";
|
||||||
|
msg += (String)presets[nr][0];
|
||||||
|
laserSerial.println(msg);
|
||||||
|
delay(20);
|
||||||
|
msg = "AT SMS 1 ";
|
||||||
|
msg += (String)presets[nr][1];
|
||||||
|
laserSerial.println(msg);
|
||||||
|
delay(20);
|
||||||
|
msg = "AT SMS 2 ";
|
||||||
|
msg += (String)presets[nr][2];
|
||||||
|
laserSerial.println(msg);
|
||||||
|
delay(20);
|
||||||
|
msg = "AT SMS 3 ";
|
||||||
|
msg += (String)presets[nr][3];
|
||||||
|
laserSerial.println(msg);
|
||||||
|
delay(20);
|
||||||
|
Serial.print("writenPresetToLaser: ");
|
||||||
|
Serial.println(nr);
|
||||||
|
}
|
||||||
|
|
||||||
void setupWifi()
|
void setupWifi()
|
||||||
{
|
{
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
@@ -362,7 +464,7 @@ void setup(void) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!readConfigFile())
|
if (!readWifiConfig())
|
||||||
{
|
{
|
||||||
Serial.println("reading wifi config failed, start SoftAP");
|
Serial.println("reading wifi config failed, start SoftAP");
|
||||||
_apMode = 1;
|
_apMode = 1;
|
||||||
@@ -371,6 +473,9 @@ void setup(void) {
|
|||||||
|
|
||||||
setupWifi();
|
setupWifi();
|
||||||
|
|
||||||
|
// loading presets
|
||||||
|
readPresetsFile();
|
||||||
|
|
||||||
// Setup MDNS responder
|
// Setup MDNS responder
|
||||||
if (!MDNS.begin(myHostname)) {
|
if (!MDNS.begin(myHostname)) {
|
||||||
Serial.println("Error setting up MDNS responder!");
|
Serial.println("Error setting up MDNS responder!");
|
||||||
@@ -387,15 +492,6 @@ void setup(void) {
|
|||||||
server.on("/files", HTTP_POST, []() {
|
server.on("/files", HTTP_POST, []() {
|
||||||
server.send(400, "text/plain", "400 Bad Request");
|
server.send(400, "text/plain", "400 Bad Request");
|
||||||
});
|
});
|
||||||
server.on("/saveconf", HTTP_GET, []() {
|
|
||||||
server.send(400, "text/plain", "400 Bad Request");
|
|
||||||
});
|
|
||||||
server.on("/saveconf", HTTP_POST, hSaveConf);
|
|
||||||
|
|
||||||
server.on("/resetwifi", HTTP_GET, []() {
|
|
||||||
server.send(400, "text/plain", "400 Bad Request");
|
|
||||||
});
|
|
||||||
server.on("/resetwifi", HTTP_POST, setupWifi);
|
|
||||||
|
|
||||||
server.on("/wificonfig", HTTP_GET, hReadWifi);
|
server.on("/wificonfig", HTTP_GET, hReadWifi);
|
||||||
server.on("/wificonfig", HTTP_POST, hWriteWifi);
|
server.on("/wificonfig", HTTP_POST, hWriteWifi);
|
||||||
@@ -404,6 +500,30 @@ void setup(void) {
|
|||||||
server.on("/spirograph", HTTP_GET, hReadSpiro);
|
server.on("/spirograph", HTTP_GET, hReadSpiro);
|
||||||
server.on("/spirograph", HTTP_POST, hWriteSpiro);
|
server.on("/spirograph", HTTP_POST, hWriteSpiro);
|
||||||
|
|
||||||
|
server.on("/presets", HTTP_GET, hReadPresets);
|
||||||
|
server.on("/presets", HTTP_POST, []() {
|
||||||
|
server.send(400, "text/plain", "400 Bad Request");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
server.on("/presetMode", HTTP_GET, []() {
|
||||||
|
String json = "{";
|
||||||
|
json += "\"presetMode\":" + String(presetMode);
|
||||||
|
json += "}";
|
||||||
|
server.send(200, "text/json", json);
|
||||||
|
json = String();
|
||||||
|
});
|
||||||
|
server.on("/presetMode", HTTP_POST, []() {
|
||||||
|
if (server.hasArg("presetMode") ) {
|
||||||
|
presetMode = server.arg("presetMode").toInt();
|
||||||
|
}
|
||||||
|
String json = "{";
|
||||||
|
json += "\"presetMode\":" + String(presetMode);
|
||||||
|
json += "}";
|
||||||
|
server.send(200, "text/json", json);
|
||||||
|
json = String();
|
||||||
|
});
|
||||||
|
|
||||||
server.on("/heap", HTTP_GET, []() {
|
server.on("/heap", HTTP_GET, []() {
|
||||||
String json = "{";
|
String json = "{";
|
||||||
json += "\"heap\":" + String(ESP.getFreeHeap());
|
json += "\"heap\":" + String(ESP.getFreeHeap());
|
||||||
@@ -417,6 +537,9 @@ void setup(void) {
|
|||||||
server.onNotFound(handleNotFound);
|
server.onNotFound(handleNotFound);
|
||||||
server.begin();
|
server.begin();
|
||||||
Serial.println("HTTP server started");
|
Serial.println("HTTP server started");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNotFound() {
|
void handleNotFound() {
|
||||||
@@ -437,5 +560,23 @@ void handleNotFound() {
|
|||||||
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
|
|
||||||
|
if (presetMode == 1)
|
||||||
|
{
|
||||||
|
if (millis() - previousMillis >= cycleTime)
|
||||||
|
{
|
||||||
|
presetToLaser(activePreset + 1);
|
||||||
|
if (activePreset < 128)
|
||||||
|
{
|
||||||
|
activePreset++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activePreset = 0;
|
||||||
|
}
|
||||||
|
previousMillis = millis();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user