-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathWiLED.ino
53 lines (41 loc) · 2.03 KB
/
WiLED.ino
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
/*
ESP8266 LED
*/
#include "src/definitions.h"
void setup() {
////////////////////////////////////////////////////////// OTA and Server////////////////////////////////////////////////////////////////////////
Serial.begin(115200);
Serial.println("Booting...");
UploadOTA uploadOTA;
////////////////////////////////////////////////////////// MVC & Factory ////////////////////////////////////////////////////////////////////////
Model_Factory model_factory;
Model *model = model_factory.create(strip_type);
controller = Controller(model);
wserver = new WebServer(controller);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Serial.println("LED initialization...");
pinMode(BUILTIN_LED, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
////////////////////////////////////////////////////////// ALEXA ////////////////////////////////////////////////////////////////////////////////
#ifdef USE_ALEXA
// Add your alexa virtual devices giving them a name and associated callback
adddevices();
espalexa.begin(&wserver->server); // Give alexa a pointer to server object so it can use server instead of creating its own
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
printf(".............\n");
}
// The loop function runs over and over again forever
void loop() {
#ifdef USE_ALEXA
espalexa.loop(); // Start server
#else
wserver->serverListener(); // Omit this if USE_ALEXA 1
#endif
wserver->webSocketListener(); // Constantly check for websocket events
ArduinoOTA.handle(); // Listen for OTA events
if (strip_type == EWS28_STRIP) { // Continually run the animation service for WS28xx strip
controller.runModelService();
}
controller.run();
}