37 {
38#if WIFI_SUPPORTED
39 WiFi.mode(WIFI_STA);
40 WiFi.begin(ssid, password);
41 WiFi.config(ip, gateway, subnet);
42 while (WiFi.waitForConnectResult() != WL_CONNECTED) {
43 Serial.println("Connection Failed! Rebooting...");
44 delay(5000);
45 ESP.restart();
46 }
47
48 Serial.print("WiFi connected, IP = ");
49 Serial.println(WiFi.localIP());
50
51
52 OscWiFi.subscribe(
53 recv_port, "/EmotiBit/0/EDA",
54 [](const OscMessage &m) {
55
57 });
58
59 OscWiFi.subscribe(recv_port, "/EmotiBit/0/GYRO:X", [](const OscMessage &m) {
61 });
62
63 OscWiFi.subscribe(recv_port, "/EmotiBit/0/GYRO:Y", [](const OscMessage &m) {
65 });
66
67 OscWiFi.subscribe(recv_port, "/EmotiBit/0/GYRO:Z", [](const OscMessage &m) {
69 });
70
71
72 OscWiFi.subscribe(recv_port, "/EmotiBit/0/PPG:IR", [](const OscMessage &m) {
73 float reading = m.arg<float>(0);
74 Serial.println(reading);
75
76 int hue = 0;
77
78
80
81 if (gyroTotal < gyroThreshold && lastIrReading >= reading) {
82
83 Serial.print("> ");
89 for (int i = 0; i < 6; i++) {
91 bool firedRipple = false;
92
93 for (int j = 0; j < 30; j++) {
96 15, i, strip0.ColorHSV(hue, 255, 255),
97 float(random(100)) / 100.0 * .2 + .8,
98 500, 2);
99
100 firedRipple = true;
101 }
102 }
103 }
104 }
105 }
106
108 }
109 } else {
111 }
112
116 });
117#endif
118
119#if OTA_SUPPORTED
120
121 ArduinoOTA
122 .onStart([]() {
123 String type;
124 if (ArduinoOTA.getCommand() == U_FLASH)
125 type = "sketch";
126 else
127 type = "filesystem";
128
129
130
131 Serial.println("Start updating " + type);
132 })
133 .onEnd([]() { Serial.println("\nEnd"); })
134 .onProgress([](unsigned int progress, unsigned int total) {
135 Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
136 })
137 .onError([](ota_error_t error) {
138 Serial.printf("Error[%u]: ", error);
139 if (error == OTA_AUTH_ERROR)
140 Serial.println("Auth Failed");
141 else if (error == OTA_BEGIN_ERROR)
142 Serial.println("Begin Failed");
143 else if (error == OTA_CONNECT_ERROR)
144 Serial.println("Connect Failed");
145 else if (error == OTA_RECEIVE_ERROR)
146 Serial.println("Receive Failed");
147 else if (error == OTA_END_ERROR)
148 Serial.println("End Failed");
149 });
150
151 ArduinoOTA.begin();
152
153 Serial.println("Ready for WiFi OTA updates");
154 Serial.print("IP address: ");
155 Serial.println(WiFi.localIP());
156#endif
157}
float lastKnownTemperature
unsigned long lastHeartbeat
Ripple ripples[numberOfRipples]
int nodeConnections[25][6]
float fmap(float x, float in_min, float in_max, float out_min, float out_max)