-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp.EXAMPLE
More file actions
79 lines (68 loc) · 1.76 KB
/
main.cpp.EXAMPLE
File metadata and controls
79 lines (68 loc) · 1.76 KB
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
/* Example File for ESP MultiService IO
* see https://github.com/101010b/ESP32MultiServiceIO for details
*/
#include <stdint.h>
#include "config.h"
#include "MultiServiceIO.h"
#include "main.h"
MultiServiceIO *mio = NULL;
UI32Var_t state;
UI32Var_t global;
void setup()
{
Serial.begin(115200);
Serial.println();
delay(1000);
Serial.println("Initializing Device...");
// Try to initialize SPIFFS
Serial.println("SPIFFS initialization");
bool spiffsok = false;
try {
if (SPIFFS.begin())
spiffsok = true;
}
catch (void *) {
}
if (!spiffsok) {
Serial.println("An Error occured initializing the SPIFFS System");
Serial.print("Waiting timout before formatting SPIFFS File.");
for (int i = 0; i < 30; i++)
{
delay(1000);
Serial.print(".");
}
Serial.println();
Serial.println("Trying to format the SPIFFS File System");
Serial.println("This may take some time - please be patient");
SPIFFS.format();
// Retry SPIFFS again
if (!SPIFFS.begin())
{
Serial.println("An Error occured initializing the SPIFFS System --> Stopping");
while (1)
{
Serial.print(".");
delay(1000);
}
}
}
// Initialize MultiServiceIO Object
Serial.println("MultiServiceIO Object");
mio = new MultiServiceIO();
Serial.println("LED Control Object");
// Set some Parameters
X32Set(state, 0, 0, 1); // On/Off
X32Set(global, 1, 1, 31); // An arbitrary value from 1 to 31
// Create Variables
mio->addNewConfigValue("state", &state);
mio->addNewConfigValue("global", &global);
Serial.println("Setting Up MIO");
mio->setup();
Serial.println("Setup finished --> Loop Mode now");
}
void loop()
{
mio->loop();
// Do whatever you want with the Parameters
}
// EOF