7#define WIFI_SUPPORTED 0
9#if OTA_SUPPORTED && !WIFI_SUPPORTED
10#error "You can't have OTA without WiFi, dummy"
14#include <ArduinoOSC.h>
18const char *ssid =
"YourMom";
19const char *password =
"is a nice lady";
21const IPAddress ip(4, 20, 6, 9);
22const IPAddress gateway(192, 168, 1, 1);
26const int recv_port = 42069;
31#include <ArduinoOTA.h>
40 WiFi.begin(ssid, password);
41 WiFi.config(ip, gateway, subnet);
42 while (WiFi.waitForConnectResult() != WL_CONNECTED) {
43 Serial.println(
"Connection Failed! Rebooting...");
48 Serial.print(
"WiFi connected, IP = ");
49 Serial.println(WiFi.localIP());
53 recv_port,
"/EmotiBit/0/EDA",
54 [](
const OscMessage &m) {
56 lastKnownTemperature = m.arg<
float>(0);
59 OscWiFi.subscribe(recv_port,
"/EmotiBit/0/GYRO:X", [](
const OscMessage &m) {
60 gyroX = m.arg<
float>(0) * gyroAlpha + gyroX * (1 - gyroAlpha);
63 OscWiFi.subscribe(recv_port,
"/EmotiBit/0/GYRO:Y", [](
const OscMessage &m) {
64 gyroY = m.arg<
float>(0) * gyroAlpha + gyroY * (1 - gyroAlpha);
67 OscWiFi.subscribe(recv_port,
"/EmotiBit/0/GYRO:Z", [](
const OscMessage &m) {
68 gyroZ = m.arg<
float>(0) * gyroAlpha + gyroZ * (1 - gyroAlpha);
72 OscWiFi.subscribe(recv_port,
"/EmotiBit/0/PPG:IR", [](
const OscMessage &m) {
73 float reading = m.arg<
float>(0);
74 Serial.println(reading);
79 float gyroTotal = abs(gyroX) + abs(gyroY) + abs(gyroZ);
81 if (gyroTotal < gyroThreshold && lastIrReading >= reading) {
84 Serial.println(highestIrReading - reading);
85 if (highestIrReading - reading >= heartbeatDelta) {
86 if (millis() - lastHeartbeat >= heartbeatLockout) {
87 hue = fmap(lastKnownTemperature, lowTemperature,
88 highTemperature, 0xFFFF, 0);
89 for (
int i = 0; i < 6; i++) {
90 if (nodeConnections[15][i] > 0) {
91 bool firedRipple =
false;
93 for (
int j = 0; j < 30; j++) {
94 if (!firedRipple && ripples[j].state == dead) {
96 15, i, strip0.ColorHSV(hue, 255, 255),
97 float(random(100)) / 100.0 * .2 + .8,
107 lastHeartbeat = millis();
110 highestIrReading = 0;
113 lastIrReading = reading;
114 if (reading > highestIrReading)
115 highestIrReading = reading;
124 if (ArduinoOTA.getCommand() == U_FLASH)
131 Serial.println(
"Start updating " + type);
133 .onEnd([]() { Serial.println(
"\nEnd"); })
134 .onProgress([](
unsigned int progress,
unsigned int total) {
135 Serial.printf(
"Progress: %u%%\r", (progress / (total / 100)));
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");
153 Serial.println(
"Ready for WiFi OTA updates");
154 Serial.print(
"IP address: ");
155 Serial.println(WiFi.localIP());
central include file for FastLED, defines the CFastLED class/object