Integrated Changes from Original repository
This commit is contained in:
+205
-187
@@ -53,14 +53,14 @@
|
|||||||
|
|
||||||
//SPIFFS Save
|
//SPIFFS Save
|
||||||
#if !defined(ENABLE_HOMEASSISTANT) and defined(ENABLE_STATE_SAVE_SPIFFS)
|
#if !defined(ENABLE_HOMEASSISTANT) and defined(ENABLE_STATE_SAVE_SPIFFS)
|
||||||
#include <ArduinoJson.h> //
|
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MQTT
|
// MQTT
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
@@ -123,6 +123,9 @@ NeoAnimationFX<NEOMETHOD> strip(neoStrip);
|
|||||||
// https://github.com/kitesurfer1404/WS2812FX
|
// https://github.com/kitesurfer1404/WS2812FX
|
||||||
#include "WS2812FX.h"
|
#include "WS2812FX.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef RGBW
|
#ifdef RGBW
|
||||||
WS2812FX strip = WS2812FX(NUMLEDS, PIN, NEO_GRBW + NEO_KHZ800);
|
WS2812FX strip = WS2812FX(NUMLEDS, PIN, NEO_GRBW + NEO_KHZ800);
|
||||||
#else
|
#else
|
||||||
@@ -137,10 +140,10 @@ NeoAnimationFX<NEOMETHOD> strip(neoStrip);
|
|||||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||||
|
|
||||||
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
|
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
|
||||||
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
|
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
|
||||||
// and minimize distance between Arduino and first pixel. Avoid connecting
|
// and minimize distance between Arduino and first pixel. Avoid connecting
|
||||||
// on a live circuit...if you must, connect GND first.
|
// on a live circuit...if you must, connect GND first.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -252,7 +255,9 @@ void saveConfigCallback () {
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Include: Color modes
|
// Include: Color modes
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
#include "colormodes.h"
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
#include "colormodes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// MAIN
|
// MAIN
|
||||||
@@ -270,9 +275,6 @@ void setup() {
|
|||||||
pinMode(BUTTON, INPUT_PULLUP);
|
pinMode(BUTTON, INPUT_PULLUP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBG_OUTPUT_PORT.println("");
|
|
||||||
DBG_OUTPUT_PORT.println("Starting....");
|
|
||||||
|
|
||||||
#ifdef ENABLE_BUTTON_GY33
|
#ifdef ENABLE_BUTTON_GY33
|
||||||
pinMode(BUTTON_GY33, INPUT_PULLUP);
|
pinMode(BUTTON_GY33, INPUT_PULLUP);
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<256; i++) {
|
||||||
@@ -289,6 +291,9 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DBG_OUTPUT_PORT.println("");
|
||||||
|
DBG_OUTPUT_PORT.println("Starting....");
|
||||||
|
|
||||||
// start ticker with 0.5 because we start in AP mode and try to connect
|
// start ticker with 0.5 because we start in AP mode and try to connect
|
||||||
ticker.attach(0.5, tick);
|
ticker.attach(0.5, tick);
|
||||||
|
|
||||||
@@ -583,7 +588,7 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
server.on("/set_brightness", []() {
|
server.on("/set_brightness", []() {
|
||||||
getArgs();
|
getArgs();
|
||||||
mode = BRIGHTNESS;
|
mode = BRIGHTNESS;
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String(String("OK %") + String(brightness)).c_str());
|
mqtt_client.publish(mqtt_outtopic, String(String("OK %") + String(brightness)).c_str());
|
||||||
#endif
|
#endif
|
||||||
@@ -639,7 +644,6 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/get_color", []() {
|
server.on("/get_color", []() {
|
||||||
//String rgbcolor = String(main_color.white, HEX) + String(main_color.red, HEX) + String(main_color.green, HEX) + String(main_color.blue, HEX);
|
|
||||||
char rgbcolor[9];
|
char rgbcolor[9];
|
||||||
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", main_color.white, main_color.red, main_color.green, main_color.blue);
|
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", main_color.white, main_color.red, main_color.green, main_color.blue);
|
||||||
server.send(200, "text/plain", rgbcolor );
|
server.send(200, "text/plain", rgbcolor );
|
||||||
@@ -652,7 +656,9 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/off", []() {
|
server.on("/off", []() {
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
exit_func = true;
|
||||||
|
#endif
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
@@ -671,8 +677,12 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/all", []() {
|
server.on("/all", []() {
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
mode = ALL;
|
exit_func = true;
|
||||||
|
#endif
|
||||||
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
|
//mode = ALL;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
@@ -689,138 +699,140 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/wipe", []() {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
exit_func = true;
|
server.on("/wipe", []() {
|
||||||
mode = WIPE;
|
exit_func = true;
|
||||||
getArgs();
|
mode = WIPE;
|
||||||
getStatusJSON();
|
getArgs();
|
||||||
#ifdef ENABLE_MQTT
|
getStatusJSON();
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =wipe").c_str());
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.publish(mqtt_outtopic, String("OK =wipe").c_str());
|
||||||
#ifdef ENABLE_AMQTT
|
#endif
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =wipe").c_str());
|
#ifdef ENABLE_AMQTT
|
||||||
#endif
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =wipe").c_str());
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#endif
|
||||||
stateOn = true;
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#endif
|
stateOn = true;
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#endif
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
#endif
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
});
|
#endif
|
||||||
|
});
|
||||||
|
|
||||||
server.on("/rainbow", []() {
|
server.on("/rainbow", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = RAINBOW;
|
mode = RAINBOW;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =rainbow").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =rainbow").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbow").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbow").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/rainbowCycle", []() {
|
server.on("/rainbowCycle", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = RAINBOWCYCLE;
|
mode = RAINBOWCYCLE;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =rainbowCycle").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =rainbowCycle").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbowCycle").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbowCycle").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/theaterchase", []() {
|
server.on("/theaterchase", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = THEATERCHASE;
|
mode = THEATERCHASE;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchase").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchase").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchase").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchase").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/twinkleRandom", []() {
|
server.on("/twinkleRandom", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = TWINKLERANDOM;
|
mode = TWINKLERANDOM;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =twinkleRandom").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =twinkleRandom").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =twinkleRandom").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =twinkleRandom").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/theaterchaseRainbow", []() {
|
server.on("/theaterchaseRainbow", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = THEATERCHASERAINBOW;
|
mode = THEATERCHASERAINBOW;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchaseRainbow").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchaseRainbow").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchaseRainbow").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchaseRainbow").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/tv", []() {
|
server.on("/tv", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = TV;
|
mode = TV;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =tv").c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =tv").c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
server.on("/get_modes", []() {
|
server.on("/get_modes", []() {
|
||||||
getModesJSON();
|
getModesJSON();
|
||||||
@@ -875,13 +887,16 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
#ifdef ENABLE_BUTTON
|
#ifdef ENABLE_BUTTON
|
||||||
button();
|
button();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_BUTTON_GY33
|
#ifdef ENABLE_BUTTON_GY33
|
||||||
button_gy33();
|
button_gy33();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
webSocket.loop();
|
webSocket.loop();
|
||||||
|
|
||||||
@@ -921,73 +936,77 @@ void loop() {
|
|||||||
// Simple statemachine that handles the different modes
|
// Simple statemachine that handles the different modes
|
||||||
if (mode == SET_MODE) {
|
if (mode == SET_MODE) {
|
||||||
DBG_OUTPUT_PORT.printf("SET_MODE: %d %d\n", ws2812fx_mode, mode);
|
DBG_OUTPUT_PORT.printf("SET_MODE: %d %d\n", ws2812fx_mode, mode);
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
|
||||||
strip.setMode(ws2812fx_mode);
|
strip.setMode(ws2812fx_mode);
|
||||||
mode = SETSPEED;
|
prevmode = SET_MODE;
|
||||||
|
mode = SETCOLOR;
|
||||||
}
|
}
|
||||||
if (mode == OFF) {
|
if (mode == OFF) {
|
||||||
// strip.setColor(0,0,0,0);
|
|
||||||
// strip.setMode(FX_MODE_STATIC);
|
|
||||||
if(strip.isRunning()) strip.stop(); //should clear memory
|
if(strip.isRunning()) strip.stop(); //should clear memory
|
||||||
// mode = HOLD;
|
// mode = HOLD;
|
||||||
}
|
}
|
||||||
if (mode == ALL) {
|
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
|
||||||
strip.setMode(FX_MODE_STATIC);
|
|
||||||
mode = HOLD;
|
|
||||||
}
|
|
||||||
if (mode == SETCOLOR) {
|
if (mode == SETCOLOR) {
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
mode = (prevmode == SET_MODE) ? SETSPEED : HOLD;
|
||||||
}
|
}
|
||||||
if (mode == SETSPEED) {
|
if (mode == SETSPEED) {
|
||||||
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
||||||
mode = BRIGHTNESS;
|
mode = (prevmode == SET_MODE) ? BRIGHTNESS : HOLD;
|
||||||
}
|
}
|
||||||
if (mode == BRIGHTNESS) {
|
if (mode == BRIGHTNESS) {
|
||||||
strip.setBrightness(brightness);
|
strip.setBrightness(brightness);
|
||||||
|
if (prevmode == SET_MODE) prevmode == HOLD;
|
||||||
mode = HOLD;
|
mode = HOLD;
|
||||||
}
|
}
|
||||||
if (mode == WIPE) {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
if (mode == WIPE) {
|
||||||
strip.setMode(FX_MODE_COLOR_WIPE);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_COLOR_WIPE);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == RAINBOW) {
|
}
|
||||||
strip.setMode(FX_MODE_RAINBOW);
|
if (mode == RAINBOW) {
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_RAINBOW);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == RAINBOWCYCLE) {
|
}
|
||||||
strip.setMode(FX_MODE_RAINBOW_CYCLE);
|
if (mode == RAINBOWCYCLE) {
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_RAINBOW_CYCLE);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == THEATERCHASE) {
|
}
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
if (mode == THEATERCHASE) {
|
||||||
strip.setMode(FX_MODE_THEATER_CHASE);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_THEATER_CHASE);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == TWINKLERANDOM) {
|
}
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
if (mode == TWINKLERANDOM) {
|
||||||
strip.setMode(FX_MODE_TWINKLE_RANDOM);
|
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_TWINKLE_RANDOM);
|
||||||
}
|
mode = HOLD;
|
||||||
if (mode == THEATERCHASERAINBOW) {
|
}
|
||||||
strip.setMode(FX_MODE_THEATER_CHASE_RAINBOW);
|
if (mode == THEATERCHASERAINBOW) {
|
||||||
mode = HOLD;
|
strip.setMode(FX_MODE_THEATER_CHASE_RAINBOW);
|
||||||
}
|
mode = HOLD;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (mode == HOLD || mode == CUSTOM) {
|
if (mode == HOLD || mode == CUSTOM) {
|
||||||
if(!strip.isRunning()) strip.start();
|
if(!strip.isRunning()) strip.start();
|
||||||
if (exit_func) {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
exit_func = false;
|
if (exit_func) {
|
||||||
|
exit_func = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
if (mode == TV) {
|
||||||
|
if(!strip.isRunning()) strip.start();
|
||||||
|
tv();
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
if (mode == TV) {
|
|
||||||
if(!strip.isRunning()) strip.start();
|
|
||||||
tv();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only for modes with WS2812FX functionality
|
// Only for modes with WS2812FX functionality
|
||||||
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
if (mode != TV && mode != CUSTOM) {
|
if (mode != TV && mode != CUSTOM) {
|
||||||
|
#else
|
||||||
|
if (mode != CUSTOM) {
|
||||||
|
#endif
|
||||||
strip.service();
|
strip.service();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1015,4 +1034,3 @@ void loop() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,328 @@
|
|||||||
|
#ifndef NeoAnimationFX_h
|
||||||
|
#define NeoAnimationFX_h
|
||||||
|
|
||||||
|
#include <NeoPixelBrightnessBus.h>
|
||||||
|
|
||||||
|
#define DEFAULT_BRIGHTNESS 50
|
||||||
|
#define DEFAULT_MODE 0
|
||||||
|
#define DEFAULT_SPEED 1000
|
||||||
|
#define DEFAULT_COLOR 0x00FF0000
|
||||||
|
|
||||||
|
#define SPEED_MIN 10
|
||||||
|
#define SPEED_MAX 65535
|
||||||
|
|
||||||
|
#define BRIGHTNESS_MIN 0
|
||||||
|
#define BRIGHTNESS_MAX 255
|
||||||
|
|
||||||
|
/* each segment uses 34 bytes of SRAM memory, so if you're application fails because of
|
||||||
|
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
||||||
|
#define MAX_NUM_SEGMENTS 10
|
||||||
|
#define NUM_COLORS 4 /* number of colors per segment */
|
||||||
|
#define SEGMENT _segments[_segment_index]
|
||||||
|
#define SEGMENT_RUNTIME _segment_runtimes[_segment_index]
|
||||||
|
#define SEGMENT_LENGTH (SEGMENT.stop - SEGMENT.start + 1)
|
||||||
|
#define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
|
||||||
|
|
||||||
|
// some common colors
|
||||||
|
#define RED 0x00FF0000
|
||||||
|
#define GREEN 0x0000FF00
|
||||||
|
#define BLUE 0x000000FF
|
||||||
|
#define WHITE 0x00FFFFFF
|
||||||
|
#define BLACK 0x00000000
|
||||||
|
#define YELLOW 0x00FFFF00
|
||||||
|
#define CYAN 0x0000FFFF
|
||||||
|
#define MAGENTA 0x00FF00FF
|
||||||
|
#define PURPLE 0x00400080
|
||||||
|
#define ORANGE 0x00FF3000
|
||||||
|
#define ULTRAWHITE 0xFFFFFFFF
|
||||||
|
|
||||||
|
#define MODE_COUNT 58
|
||||||
|
|
||||||
|
#define FX_MODE_STATIC 0
|
||||||
|
#define FX_MODE_BLINK 1
|
||||||
|
#define FX_MODE_BREATH 2
|
||||||
|
#define FX_MODE_COLOR_WIPE 3
|
||||||
|
#define FX_MODE_COLOR_WIPE_INV 4
|
||||||
|
#define FX_MODE_COLOR_WIPE_REV 5
|
||||||
|
#define FX_MODE_COLOR_WIPE_REV_INV 6
|
||||||
|
#define FX_MODE_COLOR_WIPE_RANDOM 7
|
||||||
|
#define FX_MODE_RANDOM_COLOR 8
|
||||||
|
#define FX_MODE_SINGLE_DYNAMIC 9
|
||||||
|
#define FX_MODE_MULTI_DYNAMIC 10
|
||||||
|
#define FX_MODE_RAINBOW 11
|
||||||
|
#define FX_MODE_RAINBOW_CYCLE 12
|
||||||
|
#define FX_MODE_SCAN 13
|
||||||
|
#define FX_MODE_DUAL_SCAN 14
|
||||||
|
#define FX_MODE_FADE 15
|
||||||
|
#define FX_MODE_THEATER_CHASE 16
|
||||||
|
#define FX_MODE_THEATER_CHASE_RAINBOW 17
|
||||||
|
#define FX_MODE_RUNNING_LIGHTS 18
|
||||||
|
#define FX_MODE_TWINKLE 19
|
||||||
|
#define FX_MODE_TWINKLE_RANDOM 20
|
||||||
|
#define FX_MODE_TWINKLE_FADE 21
|
||||||
|
#define FX_MODE_TWINKLE_FADE_RANDOM 22
|
||||||
|
#define FX_MODE_SPARKLE 23
|
||||||
|
#define FX_MODE_FLASH_SPARKLE 24
|
||||||
|
#define FX_MODE_HYPER_SPARKLE 25
|
||||||
|
#define FX_MODE_STROBE 26
|
||||||
|
#define FX_MODE_STROBE_RAINBOW 27
|
||||||
|
#define FX_MODE_MULTI_STROBE 28
|
||||||
|
#define FX_MODE_BLINK_RAINBOW 29
|
||||||
|
#define FX_MODE_CHASE_WHITE 30
|
||||||
|
#define FX_MODE_CHASE_COLOR 31
|
||||||
|
#define FX_MODE_CHASE_RANDOM 32
|
||||||
|
#define FX_MODE_CHASE_RAINBOW 33
|
||||||
|
#define FX_MODE_CHASE_FLASH 34
|
||||||
|
#define FX_MODE_CHASE_FLASH_RANDOM 35
|
||||||
|
#define FX_MODE_CHASE_RAINBOW_WHITE 36
|
||||||
|
#define FX_MODE_CHASE_BLACKOUT 37
|
||||||
|
#define FX_MODE_CHASE_BLACKOUT_RAINBOW 38
|
||||||
|
#define FX_MODE_COLOR_SWEEP_RANDOM 39
|
||||||
|
#define FX_MODE_RUNNING_COLOR 40
|
||||||
|
#define FX_MODE_RUNNING_RED_BLUE 41
|
||||||
|
#define FX_MODE_RUNNING_RANDOM 42
|
||||||
|
#define FX_MODE_LARSON_SCANNER 43
|
||||||
|
#define FX_MODE_COMET 44
|
||||||
|
#define FX_MODE_FIREWORKS 45
|
||||||
|
#define FX_MODE_FIREWORKS_RANDOM 46
|
||||||
|
#define FX_MODE_MERRY_CHRISTMAS 47
|
||||||
|
#define FX_MODE_FIRE_FLICKER 48
|
||||||
|
#define FX_MODE_FIRE_FLICKER_SOFT 49
|
||||||
|
#define FX_MODE_FIRE_FLICKER_INTENSE 50
|
||||||
|
#define FX_MODE_CIRCUS_COMBUSTUS 51
|
||||||
|
#define FX_MODE_HALLOWEEN 52
|
||||||
|
#define FX_MODE_BICOLOR_CHASE 53
|
||||||
|
#define FX_MODE_TRICOLOR_CHASE 54
|
||||||
|
#define FX_MODE_ICU 55
|
||||||
|
#define FX_MODE_CUSTOM 56
|
||||||
|
#define FX_MODE_METEOR_RAIN 57
|
||||||
|
|
||||||
|
#define MAX_PIXEL_CT 3000
|
||||||
|
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, Neo800KbpsMethod> NeoPBBGRB800; // Use this for WS2812
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, Neo400KbpsMethod> NeoPBBGRB400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> NeoPBBGRBU800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Uart400KbpsMethod> NeoPBBGRBU400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> NeoPBBGRBD800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Dma400KbpsMethod> NeoPBBGRBD400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> NeoPBBGRBBB800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266BitBang400KbpsMethod> NeoPBBGRBBB400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoGrbFeature, NeoWs2813Method> NeoPBBGRBws2813;
|
||||||
|
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, Neo800KbpsMethod> NeoPBBRGB800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, Neo400KbpsMethod> NeoPBBRGB400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoEsp8266Uart800KbpsMethod> NeoPBBRGBU800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoEsp8266Uart400KbpsMethod> NeoPBBRGBU400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoEsp8266Dma800KbpsMethod> NeoPBBRGBD800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoEsp8266Dma400KbpsMethod> NeoPBBRGBD400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoEsp8266BitBang800KbpsMethod> NeoPBBRGBBB800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoEsp8266BitBang400KbpsMethod> NeoPBBRGBBB400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRgbFeature, NeoWs2813Method> NeoPBBRGBws2813;
|
||||||
|
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, Neo800KbpsMethod> NeoPBBBRG800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, Neo400KbpsMethod> NeoPBBBRG400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoEsp8266Uart800KbpsMethod> NeoPBBBRGU800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoEsp8266Uart400KbpsMethod> NeoPBBBRGU400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoEsp8266Dma800KbpsMethod> NeoPBBBRGD800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoEsp8266Dma400KbpsMethod> NeoPBBBRGD400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoEsp8266BitBang800KbpsMethod> NeoPBBBRGBB800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoEsp8266BitBang400KbpsMethod> NeoPBBBRGBB400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoBrgFeature, NeoWs2813Method> NeoPBBBRGws2813;
|
||||||
|
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, Neo800KbpsMethod> NeoPBBRBG800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, Neo400KbpsMethod> NeoPBBRBG400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoEsp8266Uart800KbpsMethod> NeoPBBRBGU800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoEsp8266Uart400KbpsMethod> NeoPBBRBGU400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoEsp8266Dma800KbpsMethod> NeoPBBRBGD800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoEsp8266Dma400KbpsMethod> NeoPBBRBGD400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoEsp8266BitBang800KbpsMethod> NeoPBBRBGBB800;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoEsp8266BitBang400KbpsMethod> NeoPBBRBGBB400;
|
||||||
|
typedef NeoPixelBrightnessBus<NeoRbgFeature, NeoWs2813Method> NeoPBBRBGws2813;
|
||||||
|
|
||||||
|
//typedef NeoPixelBrightnessBus <NeoRgbwFeature, Neo800KbpsMethod> NeoPBBRGBW800; // Not supported yet
|
||||||
|
|
||||||
|
template<typename T_PIXEL_METHOD> class NeoAnimationFX {
|
||||||
|
typedef uint16_t (NeoAnimationFX::*mode_ptr)(void);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// segment parameters
|
||||||
|
|
||||||
|
/* set default values c way
|
||||||
|
struct segment_struct {
|
||||||
|
uint8_t mode;
|
||||||
|
RgbColor color;
|
||||||
|
uint16_t speed;
|
||||||
|
uint16_t start;
|
||||||
|
uint16_t stop;
|
||||||
|
bool reverse;
|
||||||
|
} segment_default = { FX_MODE_STATIC, (RgbColor) HtmlColor(DEFAULT_COLOR), DEFAULT_SPEED, 0, 7, false};
|
||||||
|
|
||||||
|
typedef struct segment_struct segment; */
|
||||||
|
|
||||||
|
typedef struct Segment {
|
||||||
|
uint8_t mode;
|
||||||
|
RgbColor colors[NUM_COLORS];
|
||||||
|
uint16_t speed;
|
||||||
|
uint16_t start;
|
||||||
|
uint16_t stop;
|
||||||
|
bool reverse;
|
||||||
|
// set default values c++ way
|
||||||
|
Segment():
|
||||||
|
mode(FX_MODE_STATIC),
|
||||||
|
colors({(RgbColor) HtmlColor(DEFAULT_COLOR), (RgbColor) HtmlColor(BLACK), (RgbColor) HtmlColor(GREEN)}),
|
||||||
|
speed(DEFAULT_SPEED),
|
||||||
|
start(0),
|
||||||
|
stop(7),
|
||||||
|
reverse(false) {}
|
||||||
|
} segment;
|
||||||
|
|
||||||
|
// segment runtime parameters
|
||||||
|
typedef struct Segment_runtime {
|
||||||
|
uint32_t counter_mode_step;
|
||||||
|
uint32_t counter_mode_call;
|
||||||
|
unsigned long next_time;
|
||||||
|
uint16_t aux_param;
|
||||||
|
} segment_runtime;
|
||||||
|
|
||||||
|
NeoAnimationFX(T_PIXEL_METHOD& pixelStrip) :
|
||||||
|
_strip(pixelStrip) {
|
||||||
|
_mode[FX_MODE_STATIC] = &NeoAnimationFX::mode_static;
|
||||||
|
_mode[FX_MODE_BLINK] = &NeoAnimationFX::mode_blink;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE] = &NeoAnimationFX::mode_color_wipe;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_INV] = &NeoAnimationFX::mode_color_wipe_inv;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_REV] = &NeoAnimationFX::mode_color_wipe_rev;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_REV_INV] = &NeoAnimationFX::mode_color_wipe_rev_inv;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_RANDOM] = &NeoAnimationFX::mode_color_wipe_random;
|
||||||
|
_mode[FX_MODE_RANDOM_COLOR] = &NeoAnimationFX::mode_random_color;
|
||||||
|
_mode[FX_MODE_SINGLE_DYNAMIC] = &NeoAnimationFX::mode_single_dynamic;
|
||||||
|
_mode[FX_MODE_MULTI_DYNAMIC] = &NeoAnimationFX::mode_multi_dynamic;
|
||||||
|
_mode[FX_MODE_RAINBOW] = &NeoAnimationFX::mode_rainbow;
|
||||||
|
_mode[FX_MODE_RAINBOW_CYCLE] = &NeoAnimationFX::mode_rainbow_cycle;
|
||||||
|
_mode[FX_MODE_SCAN] = &NeoAnimationFX::mode_scan;
|
||||||
|
_mode[FX_MODE_DUAL_SCAN] = &NeoAnimationFX::mode_dual_scan;
|
||||||
|
_mode[FX_MODE_FADE] = &NeoAnimationFX::mode_fade;
|
||||||
|
_mode[FX_MODE_THEATER_CHASE] = &NeoAnimationFX::mode_theater_chase;
|
||||||
|
_mode[FX_MODE_THEATER_CHASE_RAINBOW] = &NeoAnimationFX::mode_theater_chase_rainbow;
|
||||||
|
_mode[FX_MODE_TWINKLE] = &NeoAnimationFX::mode_twinkle;
|
||||||
|
_mode[FX_MODE_TWINKLE_RANDOM] = &NeoAnimationFX::mode_twinkle_random;
|
||||||
|
_mode[FX_MODE_TWINKLE_FADE] = &NeoAnimationFX::mode_twinkle_fade;
|
||||||
|
_mode[FX_MODE_TWINKLE_FADE_RANDOM] = &NeoAnimationFX::mode_twinkle_fade_random;
|
||||||
|
_mode[FX_MODE_SPARKLE] = &NeoAnimationFX::mode_sparkle;
|
||||||
|
_mode[FX_MODE_FLASH_SPARKLE] = &NeoAnimationFX::mode_flash_sparkle;
|
||||||
|
_mode[FX_MODE_HYPER_SPARKLE] = &NeoAnimationFX::mode_hyper_sparkle;
|
||||||
|
_mode[FX_MODE_STROBE] = &NeoAnimationFX::mode_strobe;
|
||||||
|
_mode[FX_MODE_STROBE_RAINBOW] = &NeoAnimationFX::mode_strobe_rainbow;
|
||||||
|
_mode[FX_MODE_MULTI_STROBE] = &NeoAnimationFX::mode_multi_strobe;
|
||||||
|
_mode[FX_MODE_BLINK_RAINBOW] = &NeoAnimationFX::mode_blink_rainbow;
|
||||||
|
_mode[FX_MODE_CHASE_WHITE] = &NeoAnimationFX::mode_chase_white;
|
||||||
|
_mode[FX_MODE_CHASE_COLOR] = &NeoAnimationFX::mode_chase_color;
|
||||||
|
_mode[FX_MODE_CHASE_RANDOM] = &NeoAnimationFX::mode_chase_random;
|
||||||
|
_mode[FX_MODE_CHASE_RAINBOW] = &NeoAnimationFX::mode_chase_rainbow;
|
||||||
|
_mode[FX_MODE_CHASE_FLASH] = &NeoAnimationFX::mode_chase_flash;
|
||||||
|
_mode[FX_MODE_CHASE_FLASH_RANDOM] = &NeoAnimationFX::mode_chase_flash_random;
|
||||||
|
_mode[FX_MODE_CHASE_RAINBOW_WHITE] = &NeoAnimationFX::mode_chase_rainbow_white;
|
||||||
|
_mode[FX_MODE_CHASE_BLACKOUT] = &NeoAnimationFX::mode_chase_blackout;
|
||||||
|
_mode[FX_MODE_CHASE_BLACKOUT_RAINBOW] = &NeoAnimationFX::mode_chase_blackout_rainbow;
|
||||||
|
_mode[FX_MODE_COLOR_SWEEP_RANDOM] = &NeoAnimationFX::mode_color_sweep_random;
|
||||||
|
_mode[FX_MODE_RUNNING_COLOR] = &NeoAnimationFX::mode_running_color;
|
||||||
|
_mode[FX_MODE_RUNNING_RED_BLUE] = &NeoAnimationFX::mode_running_red_blue;
|
||||||
|
_mode[FX_MODE_RUNNING_RANDOM] = &NeoAnimationFX::mode_running_random;
|
||||||
|
_mode[FX_MODE_LARSON_SCANNER] = &NeoAnimationFX::mode_larson_scanner;
|
||||||
|
_mode[FX_MODE_COMET] = &NeoAnimationFX::mode_comet;
|
||||||
|
_mode[FX_MODE_FIREWORKS] = &NeoAnimationFX::mode_fireworks;
|
||||||
|
_mode[FX_MODE_FIREWORKS_RANDOM] = &NeoAnimationFX::mode_fireworks_random;
|
||||||
|
_mode[FX_MODE_MERRY_CHRISTMAS] = &NeoAnimationFX::mode_merry_christmas;
|
||||||
|
_mode[FX_MODE_HALLOWEEN] = &NeoAnimationFX::mode_halloween;
|
||||||
|
_mode[FX_MODE_FIRE_FLICKER] = &NeoAnimationFX::mode_fire_flicker;
|
||||||
|
_mode[FX_MODE_FIRE_FLICKER_SOFT] = &NeoAnimationFX::mode_fire_flicker_soft;
|
||||||
|
_mode[FX_MODE_FIRE_FLICKER_INTENSE] = &NeoAnimationFX::mode_fire_flicker_intense;
|
||||||
|
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &NeoAnimationFX::mode_circus_combustus;
|
||||||
|
_mode[FX_MODE_BICOLOR_CHASE] = &NeoAnimationFX::mode_bicolor_chase;
|
||||||
|
_mode[FX_MODE_TRICOLOR_CHASE] = &NeoAnimationFX::mode_tricolor_chase;
|
||||||
|
// if flash memory is constrained (I'm looking at you Arduino Nano), replace modes
|
||||||
|
// that use a lot of flash with mode_static (reduces flash footprint by about 3600 bytes)
|
||||||
|
#ifdef REDUCED_MODES
|
||||||
|
_mode[FX_MODE_BREATH] = &NeoAnimationFX::mode_static;
|
||||||
|
_mode[FX_MODE_RUNNING_LIGHTS] = &NeoAnimationFX::mode_static;
|
||||||
|
_mode[FX_MODE_ICU] = &NeoAnimationFX::mode_static;
|
||||||
|
#else
|
||||||
|
_mode[FX_MODE_BREATH] = &NeoAnimationFX::mode_breath;
|
||||||
|
_mode[FX_MODE_RUNNING_LIGHTS] = &NeoAnimationFX::mode_running_lights;
|
||||||
|
_mode[FX_MODE_ICU] = &NeoAnimationFX::mode_icu;
|
||||||
|
#endif
|
||||||
|
_mode[FX_MODE_CUSTOM] = &NeoAnimationFX::mode_custom;
|
||||||
|
_mode[FX_MODE_METEOR_RAIN] = &NeoAnimationFX::mode_meteor_rain;
|
||||||
|
|
||||||
|
_name[FX_MODE_STATIC] = F("Static");
|
||||||
|
_name[FX_MODE_BLINK] = F("Blink");
|
||||||
|
_name[FX_MODE_BREATH] = F("Breath");
|
||||||
|
_name[FX_MODE_COLOR_WIPE] = F("Color Wipe");
|
||||||
|
_name[FX_MODE_COLOR_WIPE_INV ] = F("Color Wipe Inverse");
|
||||||
|
_name[FX_MODE_COLOR_WIPE_REV] = F("Color Wipe Reverse");
|
||||||
|
_name[FX_MODE_COLOR_WIPE_REV_INV] = F("Color Wipe Reverse Inverse");
|
||||||
|
_name[FX_MODE_COLOR_WIPE_RANDOM] = F("Color Wipe Random");
|
||||||
|
_name[FX_MODE_RANDOM_COLOR] = F("Random Color");
|
||||||
|
_name[FX_MODE_SINGLE_DYNAMIC] = F("Single Dynamic");
|
||||||
|
_name[FX_MODE_MULTI_DYNAMIC] = F("Multi Dynamic");
|
||||||
|
_name[FX_MODE_RAINBOW] = F("Rainbow");
|
||||||
|
_name[FX_MODE_RAINBOW_CYCLE] = F("Rainbow Cycle");
|
||||||
|
_name[FX_MODE_SCAN] = F("Scan");
|
||||||
|
_name[FX_MODE_DUAL_SCAN] = F("Dual Scan");
|
||||||
|
_name[FX_MODE_FADE] = F("Fade");
|
||||||
|
_name[FX_MODE_THEATER_CHASE] = F("Theater Chase");
|
||||||
|
_name[FX_MODE_THEATER_CHASE_RAINBOW] = F("Theater Chase Rainbow");
|
||||||
|
_name[FX_MODE_RUNNING_LIGHTS] = F("Running Lights");
|
||||||
|
_name[FX_MODE_TWINKLE] = F("Twinkle");
|
||||||
|
_name[FX_MODE_TWINKLE_RANDOM] = F("Twinkle Random");
|
||||||
|
_name[FX_MODE_TWINKLE_FADE] = F("Twinkle Fade");
|
||||||
|
_name[FX_MODE_TWINKLE_FADE_RANDOM] = F("Twinkle Fade Random");
|
||||||
|
_name[FX_MODE_SPARKLE] = F("Sparkle");
|
||||||
|
_name[FX_MODE_FLASH_SPARKLE] = F("Flash Sparkle");
|
||||||
|
_name[FX_MODE_HYPER_SPARKLE] = F("Hyper Sparkle");
|
||||||
|
_name[FX_MODE_STROBE] = F("Strobe");
|
||||||
|
_name[FX_MODE_STROBE_RAINBOW] = F("Strobe Rainbow");
|
||||||
|
_name[FX_MODE_MULTI_STROBE] = F("Multi Strobe");
|
||||||
|
_name[FX_MODE_BLINK_RAINBOW] = F("Blink Rainbow");
|
||||||
|
_name[FX_MODE_CHASE_WHITE] = F("Chase White");
|
||||||
|
_name[FX_MODE_CHASE_COLOR] = F("Chase Color");
|
||||||
|
_name[FX_MODE_CHASE_RANDOM] = F("Chase Random");
|
||||||
|
_name[FX_MODE_CHASE_RAINBOW] = F("Chase Rainbow");
|
||||||
|
_name[FX_MODE_CHASE_FLASH] = F("Chase Flash");
|
||||||
|
_name[FX_MODE_CHASE_FLASH_RANDOM] = F("Chase Flash Random");
|
||||||
|
_name[FX_MODE_CHASE_RAINBOW_WHITE] = F("Chase Rainbow White");
|
||||||
|
_name[FX_MODE_CHASE_BLACKOUT] = F("Chase Blackout");
|
||||||
|
_name[FX_MODE_CHASE_BLACKOUT_RAINBOW] = F("Chase Blackout Rainbow");
|
||||||
|
_name[FX_MODE_COLOR_SWEEP_RANDOM] = F("Color Sweep Random");
|
||||||
|
_name[FX_MODE_RUNNING_COLOR] = F("Running Color");
|
||||||
|
_name[FX_MODE_RUNNING_RED_BLUE] = F("Running Red Blue");
|
||||||
|
_name[FX_MODE_RUNNING_RANDOM] = F("Running Random");
|
||||||
|
_name[FX_MODE_LARSON_SCANNER] = F("Larson Scanner");
|
||||||
|
_name[FX_MODE_COMET] = F("Comet");
|
||||||
|
_name[FX_MODE_FIREWORKS] = F("Fireworks");
|
||||||
|
_name[FX_MODE_FIREWORKS_RANDOM] = F("Fireworks Random");
|
||||||
|
_name[FX_MODE_MERRY_CHRISTMAS] = F("Merry Christmas");
|
||||||
|
_name[FX_MODE_HALLOWEEN] = F("Halloween");
|
||||||
|
_name[FX_MODE_FIRE_FLICKER] = F("Fire Flicker");
|
||||||
|
_name[FX_MODE_FIRE_FLICKER_SOFT] = F("Fire Flicker (soft)");
|
||||||
|
_name[FX_MODE_FIRE_FLICKER_INTENSE] = F("Fire Flicker (intense)");
|
||||||
|
_name[FX_MODE_CIRCUS_COMBUSTUS] = F("Circus Combustus");
|
||||||
|
_name[FX_MODE_BICOLOR_CHASE] = F("Bicolor Chase");
|
||||||
|
_name[FX_MODE_TRICOLOR_CHASE] = F("Tricolor Chase");
|
||||||
|
_name[FX_MODE_ICU] = F("ICU");
|
||||||
|
_name[FX_MODE_CUSTOM] = F("Custom");
|
||||||
|
_name[FX_MODE_METEOR_RAIN] = F("Meteor Rain");
|
||||||
|
|
||||||
|
_brightness = DEFAULT_BRIGHTNESS;
|
||||||
|
_running = false;
|
||||||
|
_num_segments = 1;
|
||||||
|
_segments[0].mode = DEFAULT_MODE;
|
||||||
|
_segments[0].colors[0] = (RgbColor) HtmlColor(DEFAULT_COLOR);
|
||||||
|
_segments[0].start = 0;
|
||||||
|
(_strip.PixelCount() >= MAX_PIXEL_CT) ? _segments[0].stop = MAX_PIXEL_CT : _segments[0].stop = _strip.PixelCount() ;
|
||||||
|
_segments[0].speed = DEFAULT_SPEED;
|
||||||
|
RESET_RUNTIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
<!--
|
|
||||||
FSWebServer - Example Index Page
|
|
||||||
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
|
|
||||||
This file is part of the ESP8266WebServer library for Arduino environment.
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
-->
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
||||||
<title>ESP Monitor</title>
|
|
||||||
<script type="text/javascript" src="graphs.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var heap,temp,digi;
|
|
||||||
var reloadPeriod = 1000;
|
|
||||||
var running = false;
|
|
||||||
|
|
||||||
function loadValues(){
|
|
||||||
if(!running) return;
|
|
||||||
var xh = new XMLHttpRequest();
|
|
||||||
xh.onreadystatechange = function(){
|
|
||||||
if (xh.readyState == 4){
|
|
||||||
if(xh.status == 200) {
|
|
||||||
var res = JSON.parse(xh.responseText);
|
|
||||||
heap.add(res.heap);
|
|
||||||
temp.add(res.analog);
|
|
||||||
digi.add(res.gpio);
|
|
||||||
if(running) setTimeout(loadValues, reloadPeriod);
|
|
||||||
} else running = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xh.open("GET", "/status", true);
|
|
||||||
xh.send(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
function run(){
|
|
||||||
if(!running){
|
|
||||||
running = true;
|
|
||||||
loadValues();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onBodyLoad(){
|
|
||||||
var refreshInput = document.getElementById("refresh-rate");
|
|
||||||
refreshInput.value = reloadPeriod;
|
|
||||||
refreshInput.onchange = function(e){
|
|
||||||
var value = parseInt(e.target.value);
|
|
||||||
reloadPeriod = (value > 0)?value:0;
|
|
||||||
e.target.value = reloadPeriod;
|
|
||||||
}
|
|
||||||
var stopButton = document.getElementById("stop-button");
|
|
||||||
stopButton.onclick = function(e){
|
|
||||||
running = false;
|
|
||||||
}
|
|
||||||
var startButton = document.getElementById("start-button");
|
|
||||||
startButton.onclick = function(e){
|
|
||||||
run();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Example with 10K thermistor
|
|
||||||
//function calcThermistor(v) {
|
|
||||||
// var t = Math.log(((10230000 / v) - 10000));
|
|
||||||
// t = (1/(0.001129148+(0.000234125*t)+(0.0000000876741*t*t*t)))-273.15;
|
|
||||||
// return (t>120)?0:Math.round(t*10)/10;
|
|
||||||
//}
|
|
||||||
//temp = createGraph(document.getElementById("analog"), "Temperature", 100, 128, 10, 40, false, "cyan", calcThermistor);
|
|
||||||
|
|
||||||
temp = createGraph(document.getElementById("analog"), "Analog Input", 100, 128, 0, 1023, false, "cyan");
|
|
||||||
heap = createGraph(document.getElementById("heap"), "Current Heap", 100, 125, 0, 30000, true, "orange");
|
|
||||||
digi = createDigiGraph(document.getElementById("digital"), "GPIO", 100, 146, [0, 4, 5, 16], "gold");
|
|
||||||
run();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body id="index" style="margin:0; padding:0;" onload="onBodyLoad()">
|
|
||||||
<div id="controls" style="display: block; border: 1px solid rgb(68, 68, 68); padding: 5px; margin: 5px; width: 362px; background-color: rgb(238, 238, 238);">
|
|
||||||
<label>Period (ms):</label>
|
|
||||||
<input type="number" id="refresh-rate"/>
|
|
||||||
<input type="button" id="start-button" value="Start"/>
|
|
||||||
<input type="button" id="stop-button" value="Stop"/>
|
|
||||||
</div>
|
|
||||||
<div id="heap"></div>
|
|
||||||
<div id="analog"></div>
|
|
||||||
<div id="digital"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//#define USE_NEOANIMATIONFX // Uses NeoAnimationFX, PIN is ignored & set to RX/GPIO3, see: https://github.com/debsahu/NeoAnimationFX
|
//#define USE_NEOANIMATIONFX // Uses NeoAnimationFX, PIN is ignored & set to RX/GPIO3 or UART method: D4/GPIO2, see: https://github.com/debsahu/NeoAnimationFX
|
||||||
#define USE_WS2812FX // Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
#define USE_WS2812FX // Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||||
|
|
||||||
// Neopixel
|
// Neopixel
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#define BUTTON_GY33 12 // Input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
#define BUTTON_GY33 12 // Input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
||||||
#define RGBW
|
#define RGBW
|
||||||
|
|
||||||
const char HOSTNAME[] = "ESPLightRGBW02"; // Friedly hostname
|
const char HOSTNAME[] = "McLightingRGBW01"; // Friedly hostname
|
||||||
|
|
||||||
#define HTTP_OTA // If defined, enable Added ESP8266HTTPUpdateServer
|
#define HTTP_OTA // If defined, enable Added ESP8266HTTPUpdateServer
|
||||||
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
|
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
|
||||||
@@ -19,7 +19,7 @@ const char HOSTNAME[] = "ESPLightRGBW02"; // Friedly hostname
|
|||||||
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
||||||
//#define ENABLE_BUTTON_GY33 //
|
//#define ENABLE_BUTTON_GY33 //
|
||||||
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
||||||
|
#define ENABLE_LEGACY_ANIMATIONS
|
||||||
|
|
||||||
#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX)
|
#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX)
|
||||||
#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one."
|
#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one."
|
||||||
@@ -88,17 +88,22 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
|||||||
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
||||||
|
|
||||||
// List of all color modes
|
// List of all color modes
|
||||||
enum MODE { SET_MODE, HOLD, OFF, ALL, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, AUTO };
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM };
|
||||||
|
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
||||||
|
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
|
||||||
|
#else
|
||||||
|
enum MODE { SET_MODE, HOLD, OFF, SETCOLOR, SETSPEED, BRIGHTNESS, CUSTOM };
|
||||||
|
MODE mode = SET_MODE; // Standard mode that is active when software starts
|
||||||
|
#endif
|
||||||
|
|
||||||
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
MODE prevmode = mode;
|
||||||
|
|
||||||
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
|
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
|
||||||
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
int brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
||||||
|
|
||||||
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
|
int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
|
||||||
|
|
||||||
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
|
|
||||||
|
|
||||||
bool shouldSaveConfig = false; // For WiFiManger custom config
|
bool shouldSaveConfig = false; // For WiFiManger custom config
|
||||||
|
|
||||||
struct ledstate // Data structure to store a state of a single led
|
struct ledstate // Data structure to store a state of a single led
|
||||||
@@ -127,7 +132,6 @@ LEDState main_color = { 0, 255, 0, 0}; // Store the "main color" of the strip u
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Button handling
|
// Button handling
|
||||||
|
|
||||||
#ifdef ENABLE_BUTTON || ENABLE_BUTTON_GY33
|
#ifdef ENABLE_BUTTON || ENABLE_BUTTON_GY33
|
||||||
boolean buttonState = false;
|
boolean buttonState = false;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,11 +35,10 @@ void getArgs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (server.arg("c").toInt() > 0) {
|
if (server.arg("c").toInt() > 0) {
|
||||||
brightness = (int) server.arg("c").toInt() * 2.55;
|
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
||||||
} else {
|
} else if (server.arg("p").toInt() > 0) {
|
||||||
brightness = server.arg("p").toInt();
|
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||||
}
|
}
|
||||||
brightness = constrain(brightness, 0, 255);
|
|
||||||
|
|
||||||
main_color.white = constrain(main_color.white, 0, 255);
|
main_color.white = constrain(main_color.white, 0, 255);
|
||||||
main_color.red = constrain(main_color.red, 0, 255);
|
main_color.red = constrain(main_color.red, 0, 255);
|
||||||
@@ -88,6 +87,7 @@ void handleSetMainColor(uint8_t * mypayload) {
|
|||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
main_color.blue = ((rgb ) & 0xFF);
|
main_color.blue = ((rgb ) & 0xFF);
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
||||||
|
mode = SETCOLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetAllMode(uint8_t * mypayload) {
|
void handleSetAllMode(uint8_t * mypayload) {
|
||||||
@@ -99,13 +99,16 @@ void handleSetAllMode(uint8_t * mypayload) {
|
|||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
main_color.blue = ((rgb ) & 0xFF);
|
main_color.blue = ((rgb ) & 0xFF);
|
||||||
|
|
||||||
for (int i = 0; i < strip.numPixels(); i++) {
|
// for (int i = 0; i < strip.numPixels(); i++) {
|
||||||
strip.setPixelColor(i, main_color.red, main_color.green, main_color.blue, main_color.white);
|
// strip.setPixelColor(i, main_color.red, main_color.green, main_color.blue);
|
||||||
}
|
// }
|
||||||
strip.show();
|
// strip.show();
|
||||||
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: W: [%u] R: [%u] G: [%u] B: [%u]\n", main_color.white, main_color.red, main_color.green, main_color.blue);
|
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: W: [%u] R: [%u] G: [%u] B: [%u]\n", main_color.white, main_color.red, main_color.green, main_color.blue);
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
mode = ALL;
|
exit_func = true;
|
||||||
|
#endif
|
||||||
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||||
@@ -136,7 +139,9 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
|||||||
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, ledstates[led].white);
|
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, ledstates[led].white);
|
||||||
strip.show();
|
strip.show();
|
||||||
}
|
}
|
||||||
exit_func = true;
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
|
exit_func = true;
|
||||||
|
#endif
|
||||||
mode = CUSTOM;
|
mode = CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,82 +223,82 @@ void setModeByStateString(String saved_state_string) {
|
|||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetNamedMode(String str_mode) {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
exit_func = true;
|
void handleSetNamedMode(String str_mode) {
|
||||||
|
exit_func = true;
|
||||||
|
|
||||||
if (str_mode.startsWith("=off")) {
|
if (str_mode.startsWith("=off")) {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
stateOn = false;
|
stateOn = false;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=all")) {
|
||||||
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=wipe")) {
|
||||||
|
mode = WIPE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=rainbow")) {
|
||||||
|
mode = RAINBOW;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=rainbowCycle")) {
|
||||||
|
mode = RAINBOWCYCLE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=theaterchase")) {
|
||||||
|
mode = THEATERCHASE;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=twinkleRandom")) {
|
||||||
|
mode = TWINKLERANDOM;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=theaterchaseRainbow")) {
|
||||||
|
mode = THEATERCHASERAINBOW;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (str_mode.startsWith("=tv")) {
|
||||||
|
mode = TV;
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
stateOn = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (str_mode.startsWith("=all")) {
|
#endif
|
||||||
mode = ALL;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=wipe")) {
|
|
||||||
mode = WIPE;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=rainbow")) {
|
|
||||||
mode = RAINBOW;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=rainbowCycle")) {
|
|
||||||
mode = RAINBOWCYCLE;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=theaterchase")) {
|
|
||||||
mode = THEATERCHASE;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=twinkleRandom")) {
|
|
||||||
mode = TWINKLERANDOM;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=theaterchaseRainbow")) {
|
|
||||||
mode = THEATERCHASERAINBOW;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (str_mode.startsWith("=tv")) {
|
|
||||||
mode = TV;
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
|
||||||
stateOn = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
||||||
mode = HOLD;
|
mode = SET_MODE;
|
||||||
uint8_t ws2812fx_mode = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
uint8_t ws2812fx_mode_tmp = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
||||||
ws2812fx_mode = constrain(ws2812fx_mode, 0, 255);
|
ws2812fx_mode = constrain(ws2812fx_mode_tmp, 0, strip.getModeCount() - 1);
|
||||||
strip.setColor(main_color.white, main_color.red, main_color.green, main_color.blue);
|
|
||||||
strip.setMode(ws2812fx_mode);
|
|
||||||
strip.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* listStatusJSON() {
|
char* listStatusJSON() {
|
||||||
char json[255];
|
char json[255];
|
||||||
|
|
||||||
char modeName[30];
|
char modeName[30];
|
||||||
strncpy_P(modeName, (PGM_P)strip.getModeName(strip.getMode()), sizeof(modeName)); // copy from progmem
|
uint8_t tmp_mode = (mode == SET_MODE) ? (uint8_t) ws2812fx_mode : strip.getMode();
|
||||||
|
|
||||||
snprintf(json, sizeof(json), "{\"mode\":%d, \"ws2812fx_mode\":%d, \"ws2812fx_mode_name\":\"%s\", \"speed\":%d, \"brightness\":%d, \"color\":[%d, %d, %d, %d]}",
|
strncpy_P(modeName, (PGM_P)strip.getModeName(tmp_mode), sizeof(modeName)); // copy from progmem
|
||||||
mode, strip.getMode(), modeName, ws2812fx_speed, brightness, main_color.white, main_color.red, main_color.green, main_color.blue);
|
snprintf(json, sizeof(json), "{\"mode\":%d, \"ws2812fx_mode\":%d, \"ws2812fx_mode_name\":\"%s\", \"speed\":%d, \"brightness\":%d, \"color\":[%d, %d, %d]}",
|
||||||
|
mode, tmp_mode, modeName, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,28 +530,30 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// = ==> Activate named mode
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
if (payload[0] == '=') {
|
// = ==> Activate named mode
|
||||||
// we get mode data
|
if (payload[0] == '=') {
|
||||||
String str_mode = String((char *) &payload[0]);
|
// we get mode data
|
||||||
|
String str_mode = String((char *) &payload[0]);
|
||||||
|
|
||||||
handleSetNamedMode(str_mode);
|
handleSetNamedMode(str_mode);
|
||||||
|
|
||||||
DBG_OUTPUT_PORT.printf("Activated mode [%u]!\n", mode);
|
DBG_OUTPUT_PORT.printf("Activated mode [%u]!\n", mode);
|
||||||
webSocket.sendTXT(num, "OK");
|
webSocket.sendTXT(num, "OK");
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_AMQTT
|
#ifdef ENABLE_AMQTT
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// $ ==> Get status Info.
|
// $ ==> Get status Info.
|
||||||
if (payload[0] == '$') {
|
if (payload[0] == '$') {
|
||||||
@@ -619,13 +626,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkForRequests() {
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
webSocket.loop();
|
void checkForRequests() {
|
||||||
server.handleClient();
|
webSocket.loop();
|
||||||
#ifdef ENABLE_MQTT
|
server.handleClient();
|
||||||
mqtt_client.loop();
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.loop();
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -746,7 +755,8 @@ void checkForRequests() {
|
|||||||
const char* state_in = root["state"];
|
const char* state_in = root["state"];
|
||||||
if (strcmp(state_in, on_cmd) == 0 and !(animation_on)) {
|
if (strcmp(state_in, on_cmd) == 0 and !(animation_on)) {
|
||||||
stateOn = true;
|
stateOn = true;
|
||||||
mode = ALL;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
mode = SET_MODE;
|
||||||
}
|
}
|
||||||
else if (strcmp(state_in, off_cmd) == 0) {
|
else if (strcmp(state_in, off_cmd) == 0) {
|
||||||
stateOn = false;
|
stateOn = false;
|
||||||
@@ -949,24 +959,26 @@ void checkForRequests() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// = ==> Activate named mode
|
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||||
if (payload[0] == '=') {
|
// = ==> Activate named mode
|
||||||
String str_mode = String((char *) &payload[0]);
|
if (payload[0] == '=') {
|
||||||
handleSetNamedMode(str_mode);
|
String str_mode = String((char *) &payload[0]);
|
||||||
DBG_OUTPUT_PORT.printf("MQTT: Activate named mode [%s]\n", payload);
|
handleSetNamedMode(str_mode);
|
||||||
#ifdef ENABLE_MQTT
|
DBG_OUTPUT_PORT.printf("MQTT: Activate named mode [%s]\n", payload);
|
||||||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
#ifdef ENABLE_MQTT
|
||||||
#endif
|
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#ifdef ENABLE_AMQTT
|
#endif
|
||||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
#ifdef ENABLE_AMQTT
|
||||||
#endif
|
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#endif
|
||||||
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
#endif
|
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
#endif
|
||||||
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
#endif
|
if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState);
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// $ ==> Get status Info.
|
// $ ==> Get status Info.
|
||||||
if (payload[0] == '$') {
|
if (payload[0] == '$') {
|
||||||
@@ -1440,14 +1452,14 @@ bool writeStateFS(){
|
|||||||
DynamicJsonBuffer jsonBuffer(JSON_OBJECT_SIZE(7));
|
DynamicJsonBuffer jsonBuffer(JSON_OBJECT_SIZE(7));
|
||||||
// StaticJsonBuffer<JSON_OBJECT_SIZE(7)> jsonBuffer;
|
// StaticJsonBuffer<JSON_OBJECT_SIZE(7)> jsonBuffer;
|
||||||
JsonObject& json = jsonBuffer.createObject();
|
JsonObject& json = jsonBuffer.createObject();
|
||||||
json["mode"] = static_cast<int>(mode);
|
json["mode"] = static_cast<int>(mode);
|
||||||
json["strip_mode"] = (int) strip.getMode();
|
json["strip_mode"] = (int) strip.getMode();
|
||||||
json["brightness"] = brightness;
|
json["brightness"] = brightness;
|
||||||
json["speed"] = ws2812fx_speed;
|
json["speed"] = ws2812fx_speed;
|
||||||
json["white"] = main_color.white;
|
json["white"] = main_color.white;
|
||||||
json["red"] = main_color.red;
|
json["red"] = main_color.red;
|
||||||
json["green"] = main_color.green;
|
json["green"] = main_color.green;
|
||||||
json["blue"] = main_color.blue;
|
json["blue"] = main_color.blue;
|
||||||
|
|
||||||
// SPIFFS.remove("/state.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
|
// SPIFFS.remove("/state.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
|
||||||
File configFile = SPIFFS.open("/stripstate.json", "w");
|
File configFile = SPIFFS.open("/stripstate.json", "w");
|
||||||
@@ -1487,9 +1499,9 @@ bool readStateFS() {
|
|||||||
json.printTo(DBG_OUTPUT_PORT);
|
json.printTo(DBG_OUTPUT_PORT);
|
||||||
if (json.success()) {
|
if (json.success()) {
|
||||||
mode = static_cast<MODE>((int) json["mode"]);
|
mode = static_cast<MODE>((int) json["mode"]);
|
||||||
ws2812fx_mode = json["strip_mode"];
|
ws2812fx_mode = json["strip_mode"];
|
||||||
brightness = json["brightness"];
|
brightness = json["brightness"];
|
||||||
ws2812fx_speed = json["speed"];
|
ws2812fx_speed = json["speed"];
|
||||||
main_color.white = json["white"];
|
main_color.white = json["white"];
|
||||||
main_color.red = json["red"];
|
main_color.red = json["red"];
|
||||||
main_color.green = json["green"];
|
main_color.green = json["green"];
|
||||||
@@ -1516,4 +1528,3 @@ bool readStateFS() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ There are some informations in the [Wiki](https://github.com/toblum/McLighting/w
|
|||||||
|
|
||||||
Update 17.02.2018:
|
Update 17.02.2018:
|
||||||
User @debsahu contributed code for integration with homeassistant. It's currently in a separate branch (https://github.com/toblum/McLighting/tree/feature/ha_integration). If you're using Homeassistant, please try it out and give feedback.
|
User @debsahu contributed code for integration with homeassistant. It's currently in a separate branch (https://github.com/toblum/McLighting/tree/feature/ha_integration). If you're using Homeassistant, please try it out and give feedback.
|
||||||
User @FabLab-Luenen created a version of McLighting (https://github.com/FabLab-Luenen/McLighting) for 6812 and other RGBW strips. Give it a try, if you own such strips.
|
User @FabLab-Luenn created a version of McLighting (https://github.com/FabLab-Luenen/McLighting) for 6812 and other RGBW strips. Give it a try, if you own such strips.
|
||||||
A thank you goes to all contributors.
|
A thank you goes to all contributors.
|
||||||
|
|
||||||
Update 12. / 15.02.2018:
|
Update 12. / 15.02.2018:
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
|||||||
|
The following liscence applies to the inclueded Websocket class which was created by G33kDude (https://github.com/G33kDude/WebSocket.ahk):
|
||||||
|
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 GeekDude
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,418 @@
|
|||||||
|
#NoEnv
|
||||||
|
#SingleInstance force ; only lets one run
|
||||||
|
SetBatchLines, -1
|
||||||
|
|
||||||
|
#Persistent ; prevents the script from exiting automatically
|
||||||
|
|
||||||
|
; Register a function to be called on exit:
|
||||||
|
OnExit("ExitFunc")
|
||||||
|
|
||||||
|
; make the notification box
|
||||||
|
notificationEnable := true ; set this to false to disable the notification popups
|
||||||
|
notificationTime := 1 ; seconds the notifications stay
|
||||||
|
|
||||||
|
n := new Notification("Starting led shortcuts!", 200,14, ,notificationTime)
|
||||||
|
|
||||||
|
; make the socket
|
||||||
|
socket := new McLightingServer("ws://192.168.1.33:81") ; replace with the ip address of the mclighting controller
|
||||||
|
|
||||||
|
incrementAmount := 10 ; how finely you adjust the color, speed, and brightness per keypress
|
||||||
|
maxColor := 255
|
||||||
|
maxMode := 56 ; the maximum mode id number
|
||||||
|
|
||||||
|
red := 127
|
||||||
|
green := 127
|
||||||
|
blue := 127
|
||||||
|
|
||||||
|
brightness := 127
|
||||||
|
speed := 127
|
||||||
|
mode := 1
|
||||||
|
|
||||||
|
^#Numpad4:: ; switch modes down
|
||||||
|
mode := mode - 1
|
||||||
|
if(mode < 0)
|
||||||
|
mode := maxMode
|
||||||
|
cmd = /%mode% ; / is the set effect mode command
|
||||||
|
setNotification("Mode: " + mode)
|
||||||
|
sendCmd(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
^#Numpad6:: ; switch modes up
|
||||||
|
mode := mode + 1
|
||||||
|
if(mode > maxMode)
|
||||||
|
mode := 0
|
||||||
|
setNotification("Mode: " + mode)
|
||||||
|
cmd = /%mode%
|
||||||
|
sendCmd(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad5:: ; turn off
|
||||||
|
setNotification("Leds are off")
|
||||||
|
sendCmd("=off") ; = is the set control command
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad0:: ; turn on to static color
|
||||||
|
setNotification("Leds are on")
|
||||||
|
cmd := "*"+toHexColor(red,green,blue) ; * is the set all command
|
||||||
|
sendCmd(cmd) ; = is the set control command
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
^#NumpadSub:: ; decreases brightness
|
||||||
|
brightness := brightness - incrementAmount
|
||||||
|
if(brightness < 0)
|
||||||
|
brightness := 0
|
||||||
|
cmd = `%%brightness% ; % is the set brightness mode command. ` is the escape character
|
||||||
|
setNotification("Brightness: " + brightness)
|
||||||
|
sendCmd(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
return
|
||||||
|
|
||||||
|
^#NumpadAdd:: ; increases brightness
|
||||||
|
brightness := brightness + incrementAmount
|
||||||
|
if(brightness > maxColor)
|
||||||
|
brightness := maxColor
|
||||||
|
cmd = `%%brightness% ; % is the set brightness mode command
|
||||||
|
setNotification("Brightness: " + brightness)
|
||||||
|
sendCmd(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
return
|
||||||
|
|
||||||
|
^#NumpadDiv:: ; decreases speed
|
||||||
|
speed := speed - incrementAmount
|
||||||
|
if(speed < 0)
|
||||||
|
speed := 0
|
||||||
|
cmd = ?%speed% ; ? is the set brightness mode command
|
||||||
|
setNotification("Speed: "+ speed)
|
||||||
|
sendCmd(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
return
|
||||||
|
|
||||||
|
^#NumpadMult:: ; increases speed
|
||||||
|
speed := speed + incrementAmount
|
||||||
|
if(speed > maxColor)
|
||||||
|
speed := maxColor
|
||||||
|
cmd = ?%speed% ; ? is the set brightness mode command
|
||||||
|
setNotification("Speed: "+ speed)
|
||||||
|
sendCmd(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
^#Numpad7:: ; increase red amount
|
||||||
|
red := red + incrementAmount
|
||||||
|
if(red > maxColor)
|
||||||
|
red := maxColor
|
||||||
|
|
||||||
|
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||||
|
; MsgBox %cmd%
|
||||||
|
setNotification("Red: " + red)
|
||||||
|
sendCmd(cmd)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad1:: ; decrease red amount
|
||||||
|
red := red - incrementAmount
|
||||||
|
if(red < 0)
|
||||||
|
red := 0
|
||||||
|
|
||||||
|
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||||
|
; MsgBox %cmd%
|
||||||
|
setNotification("Red: " + red)
|
||||||
|
sendCmd(cmd)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad8:: ; increase green amount
|
||||||
|
green := green + incrementAmount
|
||||||
|
if(green > maxColor)
|
||||||
|
green := maxColor
|
||||||
|
|
||||||
|
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||||
|
; MsgBox %cmd%
|
||||||
|
setNotification("Green: " + green)
|
||||||
|
sendCmd(cmd)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad2:: ; decrease green amount
|
||||||
|
green := green - incrementAmount
|
||||||
|
if(green < 0)
|
||||||
|
green := 0
|
||||||
|
|
||||||
|
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||||
|
; MsgBox %cmd%
|
||||||
|
setNotification("Green: " + green)
|
||||||
|
sendCmd(cmd)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad9:: ; increase blue amount
|
||||||
|
blue := blue + incrementAmount
|
||||||
|
if(blue > maxColor)
|
||||||
|
blue := maxColor
|
||||||
|
|
||||||
|
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||||
|
; MsgBox %cmd%
|
||||||
|
setNotification("Blue: " + blue)
|
||||||
|
sendCmd(cmd)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
^#Numpad3:: ; decrease blue amount
|
||||||
|
blue := blue - incrementAmount
|
||||||
|
if(blue < 0)
|
||||||
|
blue := 0
|
||||||
|
|
||||||
|
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||||
|
; MsgBox %cmd%
|
||||||
|
setNotification("Blue: " + blue)
|
||||||
|
sendCmd(cmd)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
sendCmd(cmd)
|
||||||
|
{
|
||||||
|
global socket
|
||||||
|
; MsgBox connected: %connected%
|
||||||
|
if( socket.connected )
|
||||||
|
{
|
||||||
|
socket.Send(cmd)
|
||||||
|
; MsgBox %cmd%
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setNotification("Not connected to server!")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
toHexColor(r, g, b)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, hex ; To print values as hexadecimal
|
||||||
|
colorNum := r*65536 + g*256 + b
|
||||||
|
color = 000000%colorNum% ; convert to string and add preceeding zeros
|
||||||
|
color := StrReplace(color, "0x") ; replace the 0x from the middle
|
||||||
|
color := SubStr( color, -5 ) ; get last 6 characters
|
||||||
|
|
||||||
|
SetFormat, IntegerFast, dec ; sets the print mode back to decimal
|
||||||
|
return ""+color ;
|
||||||
|
}
|
||||||
|
|
||||||
|
setNotification(message)
|
||||||
|
{
|
||||||
|
global notificationEnable
|
||||||
|
global n ; the notification class
|
||||||
|
if(notificationEnable)
|
||||||
|
{
|
||||||
|
n.updateMessage(message)
|
||||||
|
n.nshow()
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ExitFunc(ExitReason, ExitCode)
|
||||||
|
{
|
||||||
|
; MsgBox Exiting
|
||||||
|
global n ; notification class
|
||||||
|
n.ndestroy() ; deletes the notification
|
||||||
|
return 0 ; must return zero to exit
|
||||||
|
}
|
||||||
|
|
||||||
|
class McLightingServer extends WebSocket
|
||||||
|
{
|
||||||
|
OnOpen(Event)
|
||||||
|
{
|
||||||
|
setNotification("Connection established!")
|
||||||
|
; InputBox, Data, WebSocket, Enter some text to send through the websocket.
|
||||||
|
; this.Send(Data)
|
||||||
|
|
||||||
|
; global connected
|
||||||
|
this.connected := 1
|
||||||
|
; MsgBox connection %connected%
|
||||||
|
}
|
||||||
|
|
||||||
|
OnMessage(Event)
|
||||||
|
{
|
||||||
|
; MsgBox, % "Received Data: " Event.data
|
||||||
|
; this.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
OnClose(Event)
|
||||||
|
{
|
||||||
|
setNotification("Websocket Closed!")
|
||||||
|
; MsgBox closed!
|
||||||
|
this.connected := 0
|
||||||
|
this.Disconnect()
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
|
|
||||||
|
OnError(Event)
|
||||||
|
{
|
||||||
|
setNotification("Websocket Error")
|
||||||
|
; MsgBox error!
|
||||||
|
this.connected := 0
|
||||||
|
this.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
__Delete()
|
||||||
|
{
|
||||||
|
; setNotification(" Exiting Led controller ") ; sticks after program closes
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WebSocket
|
||||||
|
{
|
||||||
|
__New(WS_URL)
|
||||||
|
{
|
||||||
|
this.connected := false ; flag for connection status
|
||||||
|
static wb
|
||||||
|
|
||||||
|
; Create an IE instance
|
||||||
|
Gui, +hWndhOld
|
||||||
|
Gui, New, +hWndhWnd
|
||||||
|
this.hWnd := hWnd
|
||||||
|
Gui, Add, ActiveX, vWB, Shell.Explorer
|
||||||
|
Gui, %hOld%: Default
|
||||||
|
|
||||||
|
; Write an appropriate document
|
||||||
|
WB.Navigate("about:<!DOCTYPE html><meta http-equiv='X-UA-Compatible'"
|
||||||
|
. "content='IE=edge'><body></body>")
|
||||||
|
while (WB.ReadyState < 4)
|
||||||
|
sleep, 50
|
||||||
|
this.document := WB.document
|
||||||
|
|
||||||
|
; Add our handlers to the JavaScript namespace
|
||||||
|
this.document.parentWindow.ahk_savews := this._SaveWS.Bind(this)
|
||||||
|
this.document.parentWindow.ahk_event := this._Event.Bind(this)
|
||||||
|
this.document.parentWindow.ahk_ws_url := WS_URL
|
||||||
|
|
||||||
|
; Add some JavaScript to the page to open a socket
|
||||||
|
Script := this.document.createElement("script")
|
||||||
|
Script.text := "ws = new WebSocket(ahk_ws_url);`n"
|
||||||
|
. "ws.onopen = function(event){ ahk_event('Open', event); };`n"
|
||||||
|
. "ws.onclose = function(event){ ahk_event('Close', event); };`n"
|
||||||
|
. "ws.onerror = function(event){ ahk_event('Error', event); };`n"
|
||||||
|
. "ws.onmessage = function(event){ ahk_event('Message', event); };"
|
||||||
|
this.document.body.appendChild(Script)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Called by the JS in response to WS events
|
||||||
|
_Event(EventName, Event)
|
||||||
|
{
|
||||||
|
this["On" EventName](Event)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Sends data through the WebSocket
|
||||||
|
Send(Data)
|
||||||
|
{
|
||||||
|
; MsgBox %Data%
|
||||||
|
this.document.parentWindow.ws.send(Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Closes the WebSocket connection
|
||||||
|
Close(Code:=1000, Reason:="")
|
||||||
|
{
|
||||||
|
this.document.parentWindow.ws.close(Code, Reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Closes and deletes the WebSocket, removing
|
||||||
|
; references so the class can be garbage collected
|
||||||
|
Disconnect()
|
||||||
|
{
|
||||||
|
if this.hWnd
|
||||||
|
{
|
||||||
|
this.Close()
|
||||||
|
Gui, % this.hWnd ": Destroy"
|
||||||
|
this.hWnd := False
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Notification
|
||||||
|
{
|
||||||
|
__New(message, pnW=700, pnH=300, position="b r", time=10000)
|
||||||
|
{
|
||||||
|
this.showTime := time ; time that the notification shows up for
|
||||||
|
|
||||||
|
global pn_msg
|
||||||
|
this.pn_msg := message ; message to display
|
||||||
|
|
||||||
|
Gui, Notify: +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
|
||||||
|
this.PN_hwnd := WinExist()
|
||||||
|
|
||||||
|
WinSet, ExStyle, +0x20
|
||||||
|
WinSet, Transparent, 0 ; makes the box transparent so that it can fade in and out. 255 -> opaque; 0 -> transparent
|
||||||
|
Gui, Notify: Color, 0x111111 ; background color
|
||||||
|
Gui, Notify: Font, cWhite s10 w500, Terminal ; message color, size, weight, and font
|
||||||
|
Gui, Notify: Add, Text, % " x" 20 " y" 12 " vpn_msg", % this.pn_msg ; add message
|
||||||
|
RealW := pnW + 50
|
||||||
|
RealH := pnH + 20
|
||||||
|
Gui, Notify: Show, W%RealW% H%RealH% NoActivate
|
||||||
|
this.WinMove(this.PN_hwnd, position)
|
||||||
|
global windowID := ("ahk_id "this.PN_hwnd) ; window id
|
||||||
|
this.nshow()
|
||||||
|
}
|
||||||
|
|
||||||
|
ndestroy() {
|
||||||
|
this.winfade(windowID,0,50) ; fades the box out
|
||||||
|
Gui, Notify: Destroy
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nhide(){ ; called by the timer
|
||||||
|
showTimer:
|
||||||
|
SetTimer, showTimer, Off ; turn off the timer
|
||||||
|
global windowID
|
||||||
|
winfade(windowID,0,50) ; fades the box out
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nshow(){
|
||||||
|
w:= ("ahk_id "+this.PN_hwnd)
|
||||||
|
|
||||||
|
WinGet,s,Transparent,%w% ; makes the notification visible
|
||||||
|
s:=(s="")?255:s ;prevent trans unset bug
|
||||||
|
WinSet,Transparent,210,%w%
|
||||||
|
|
||||||
|
Closetick := this.showTime*1000
|
||||||
|
SetTimer, showTimer, % Closetick ; reset the hide timer
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMessage(message) {
|
||||||
|
this.pn_msg := message
|
||||||
|
GuiControl, Notify: Text, pn_msg, % this.pn_msg
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
WinMove(hwnd,position) {
|
||||||
|
SysGet, Mon, MonitorWorkArea
|
||||||
|
WinGetPos,ix,iy,w,h, ahk_id %hwnd%
|
||||||
|
x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ? (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
|
||||||
|
y := InStr(position,"t") ? MonTop : InStr(position,"vc") ? (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
|
||||||
|
WinMove, ahk_id %hwnd%,,x,y
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; winfade must be global for the timer to use it
|
||||||
|
winfade(w:="",t:=128,i:=1,d:=10) {
|
||||||
|
w:=(w="")?("ahk_id " WinActive("A")):w
|
||||||
|
t:=(t>255)?255:(t<0)?0:t
|
||||||
|
WinGet,s,Transparent,%w%
|
||||||
|
s:=(s="")?255:s ;prevent trans unset bug
|
||||||
|
WinSet,Transparent,%s%,%w%
|
||||||
|
i:=(s<t)?abs(i):-1*abs(i)
|
||||||
|
while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
|
||||||
|
WinGet,s,Transparent,%w%
|
||||||
|
s+=i
|
||||||
|
WinSet,Transparent,%s%,%w%
|
||||||
|
sleep %d%
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
!!! Make sure that the ip address is edited to match the ip address of your McLighting server !!!
|
||||||
|
|
||||||
|
If you are not familiar with AutoHotKey, this tutorial will get you started: https://autohotkey.com/docs/Tutorial.htm
|
||||||
|
Once you have AutoHotKey installed, double click it to start the script.
|
||||||
|
|
||||||
|
If the Mclighting server goes down for some reason, a socket error notification will appear and you will have to restart the script to reconnect.
|
||||||
|
|
||||||
|
The script is not aware of the current state of the McLighting server and will override what is currently being displayed with its own internal values.
|
||||||
|
|
||||||
|
This has been tested on windows 7 and windows 10.
|
||||||
|
Set the notificationTime variable to the time in seconds that you want the notification to stay on the screen.
|
||||||
|
You can prevent notifications from appearing by setting the notificationEnable variable to false.
|
||||||
|
|
||||||
|
|
||||||
|
The shortcuts only work on the numberpad and only when num lock is on! If you don't have a numberpad you must change the shortcuts to something else. Just be aware that you might be overrriding previously existing shortcuts! Here is the list of windows shortcuts: https://support.microsoft.com/en-us/help/12445/windows-keyboard-shortcuts
|
||||||
|
|
||||||
|
The shortcuts are as follows:
|
||||||
|
|
||||||
|
ctrl+windows+numpad4 decrements the animation mode
|
||||||
|
|
||||||
|
ctrl+windows+numpad6 increments the animation mode
|
||||||
|
|
||||||
|
ctrl+windows+numpad5 turns off the lights
|
||||||
|
|
||||||
|
ctrl+windows+numpad0 turns on all of the lights to the current color
|
||||||
|
|
||||||
|
ctrl+windows+numpadPlus increases the brightness
|
||||||
|
|
||||||
|
ctrl+windows+numpadSubtract decreases the brightness
|
||||||
|
|
||||||
|
ctrl+windows+numpadMultiply increases the speed
|
||||||
|
|
||||||
|
ctrl+windows+numpadDivide decreases the speed
|
||||||
|
|
||||||
|
ctrl+windows+numpad7 increments the red component of the current color
|
||||||
|
|
||||||
|
ctrl+windows+numpad1 decrements the red component of the current color
|
||||||
|
|
||||||
|
ctrl+windows+numpad8 increments the green component of the current color
|
||||||
|
|
||||||
|
ctrl+windows+numpad2 decrements the green component of the current color
|
||||||
|
|
||||||
|
ctrl+windows+numpad9 increments the blue component of the current color
|
||||||
|
|
||||||
|
ctrl+windows+numpad3 decrements the blue component of the current color
|
||||||
@@ -7,6 +7,7 @@ light:
|
|||||||
effect: true
|
effect: true
|
||||||
effect_list:
|
effect_list:
|
||||||
######
|
######
|
||||||
|
- "Static"
|
||||||
- "Blink"
|
- "Blink"
|
||||||
- "Breath"
|
- "Breath"
|
||||||
- "Color Wipe"
|
- "Color Wipe"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<!--Let browser know website is optimized for mobile-->
|
<!--Let browser know website is optimized for mobile-->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<title>McLighting (RGBW) v2</title>
|
<title>McLighting (RGBW) v2</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
+11
-14
@@ -9,13 +9,14 @@
|
|||||||
<!--Let browser know website is optimized for mobile-->
|
<!--Let browser know website is optimized for mobile-->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<title>McLighting v2</title>
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
<title>McLighting (RGBW) v2</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<nav class="blue light-blueXXX lighten-1XXX" role="navigation" id="mc-nav">
|
<nav class="blue light-blueXXX lighten-1XXX" role="navigation" id="mc-nav">
|
||||||
<div class="nav-wrapper container">
|
<div class="nav-wrapper container">
|
||||||
<a id="logo-container" href="#" class="brand-logo">Mc Lighting v2</a>
|
<a id="logo-container" href="#" class="brand-logo">McLighting (RGBW) v2</a>
|
||||||
|
|
||||||
<ul class="right hide-on-med-and-down">
|
<ul class="right hide-on-med-and-down">
|
||||||
<li><a href="#" class="mc-navlink" data-pane="pane1">Wheel</a></li>
|
<li><a href="#" class="mc-navlink" data-pane="pane1">Wheel</a></li>
|
||||||
@@ -101,6 +102,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<label for="txt_white">White</label><br/>
|
||||||
|
<p class="range-field"><input type="range" id="rng_white" min="0" max="255" class="update_colors" /></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<label for="txt_delay">Speed</label><br/>
|
<label for="txt_delay">Speed</label><br/>
|
||||||
@@ -118,18 +126,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12 m6 l6 btn_grid">
|
|
||||||
<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="off">OFF
|
|
||||||
<i class="material-icons right">send</i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col s12 m6 l6 btn_grid">
|
|
||||||
<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="tv">TV
|
|
||||||
<i class="material-icons right">send</i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="modes">
|
<div id="modes">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
Loading animations...
|
Loading animations...
|
||||||
@@ -158,4 +154,5 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
|
||||||
<script type="text/javascript">@@include('js/script.js')</script>
|
<script type="text/javascript">@@include('js/script.js')</script>
|
||||||
</body>
|
</body>
|
||||||
|
\ No newline at end of file
|
||||||
</html>
|
</html>
|
||||||
@@ -25,9 +25,9 @@ $(function(){
|
|||||||
$('#' + pane).removeClass('hide');
|
$('#' + pane).removeClass('hide');
|
||||||
$('.button-collapse').sideNav('hide');
|
$('.button-collapse').sideNav('hide');
|
||||||
|
|
||||||
if (pane == "pane2") {
|
//if (pane == "pane2") {
|
||||||
setMainColor();
|
// setMainColor();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,16 +37,60 @@ $(function(){
|
|||||||
function init() {
|
function init() {
|
||||||
console.log("Connection websockets to:", ws_url);
|
console.log("Connection websockets to:", ws_url);
|
||||||
connection = new WebSocket(ws_url, ['arduino']);
|
connection = new WebSocket(ws_url, ['arduino']);
|
||||||
|
var mode = 0;
|
||||||
|
var ws2812fx_mode = 0;
|
||||||
|
$.getJSON("http://" + host + "/status", function(data) {
|
||||||
|
console.log("status", data);
|
||||||
|
mode = data.mode;
|
||||||
|
ws2812fx_mode = data.ws2812fx_mode;
|
||||||
|
$("#rng_brightness").val(data.brightness);
|
||||||
|
$("#rng_white").val(data.color[0]);
|
||||||
|
$("#rng_red").val(data.color[1]);
|
||||||
|
$("#rng_green").val(data.color[2]);
|
||||||
|
$("#rng_blue").val(data.color[3]);
|
||||||
|
$("#rng_delay").val(data.speed);
|
||||||
|
var statusColor = "#" + componentToHex(data.color[1]) + componentToHex(data.color[2]) + componentToHex(data.color[3]);
|
||||||
|
$('#status').css("backgroundColor", statusColor);
|
||||||
|
$('#status_color').text(statusColor + "- R=" + data.color[1] + ", G=" + data.color[2] + ", B=" + data.color[3]);
|
||||||
|
});
|
||||||
|
|
||||||
// Load modes async
|
// Load modes async
|
||||||
|
// List of all color modes
|
||||||
|
// enum MODE { SET_MODE, HOLD, OFF, ALL, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, AUTO };
|
||||||
$.getJSON("http://" + host + "/get_modes", function(data) {
|
$.getJSON("http://" + host + "/get_modes", function(data) {
|
||||||
//console.log("modes", data);
|
console.log("modes", data);
|
||||||
|
|
||||||
var modes_html = "";
|
var modes_html = "";
|
||||||
|
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||||
|
if (mode == 2) {
|
||||||
|
modes_html += '<a class="btn waves-effect waves-light btn_mode_static red" name="action" data-mode="off">OFF';
|
||||||
|
} else {
|
||||||
|
modes_html += '<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="off">OFF';
|
||||||
|
}
|
||||||
|
modes_html += '<i class="material-icons right">send</i>';
|
||||||
|
modes_html += '</a>';
|
||||||
|
modes_html += '</div>'
|
||||||
|
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||||
|
if (mode == 10) {
|
||||||
|
modes_html += '<a class="btn waves-effect waves-light btn_mode_static red" name="action" data-mode="tv">TV';
|
||||||
|
} else {
|
||||||
|
modes_html += '<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="tv">TV';
|
||||||
|
}
|
||||||
|
modes_html += '<i class="material-icons right">send</i>';
|
||||||
|
modes_html += '</a>';
|
||||||
|
modes_html += '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data.forEach(function(current_mode){
|
data.forEach(function(current_mode){
|
||||||
if (current_mode.mode !== undefined) {
|
if (current_mode.mode !== undefined) {
|
||||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||||
modes_html += '<a class="btn waves-effect waves-light btn_mode blue" name="action" data-mode="' + current_mode.mode + '">(' + current_mode.mode +') '+ current_mode.name;
|
if (mode == 1 && current_mode.mode == ws2812fx_mode) {
|
||||||
|
modes_html += '<a class="btn waves-effect waves-light btn_mode red" name="action" data-mode="' + current_mode.mode + '">(' + current_mode.mode +') '+ current_mode.name;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
modes_html += '<a class="btn waves-effect waves-light btn_mode blue" name="action" data-mode="' + current_mode.mode + '">(' + current_mode.mode +') '+ current_mode.name;
|
||||||
|
}
|
||||||
modes_html += '<i class="material-icons right">send</i>';
|
modes_html += '<i class="material-icons right">send</i>';
|
||||||
modes_html += '</a>';
|
modes_html += '</a>';
|
||||||
modes_html += '</div>';
|
modes_html += '</div>';
|
||||||
@@ -130,12 +174,16 @@ $(function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setMainColor() {
|
function setMainColor() {
|
||||||
|
var white = $("#rng_white").val();
|
||||||
var red = $("#rng_red").val();
|
var red = $("#rng_red").val();
|
||||||
var green = $("#rng_green").val();
|
var green = $("#rng_green").val();
|
||||||
var blue = $("#rng_blue").val();
|
var blue = $("#rng_blue").val();
|
||||||
|
|
||||||
var mainColorHex = componentToHex(red) + componentToHex(green) + componentToHex(blue);
|
var hexColor = componentToHex(white) + componentToHex(red) + componentToHex(green) + componentToHex(blue);
|
||||||
wsSetMainColor(mainColorHex);
|
var statusColor = "#" + componentToHex(red) + componentToHex(green) + componentToHex(blue);
|
||||||
|
wsSetMainColor(hexColor);
|
||||||
|
$('#status').css("backgroundColor", statusColor);
|
||||||
|
$('#status_color').text(statusColor + "- R=" + red + ", G=" + green + ", B=" + blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -253,15 +301,18 @@ $(function(){
|
|||||||
|
|
||||||
//display the touch/click position and color info
|
//display the touch/click position and color info
|
||||||
function updateStatus(pos, color) {
|
function updateStatus(pos, color) {
|
||||||
var hexColor = rgbToHex(color);
|
//var hexColor = rgbToHex(color);
|
||||||
wsSetAll(hexColor);
|
//wsSetAll(hexColor);
|
||||||
|
var hexColor = componentToHex(color[0]) + componentToHex(color[1]) + componentToHex(color[2]);
|
||||||
|
wsSetMainColor(hexColor);
|
||||||
|
|
||||||
hexColor = "#" + hexColor;
|
hexColor = "#" + hexColor;
|
||||||
|
|
||||||
$('#status').css("backgroundColor", hexColor);
|
$('#status').css("backgroundColor", hexColor);
|
||||||
$('#status_color').text(hexColor + " - R=" + color[0] + ", G=" + color[1] + ", B=" + color[2]);
|
$('#status_color').text(hexColor + "- R=" + color[0] + ", G=" + color[1] + ", B=" + color[2]);
|
||||||
$('#status_pos').text("x: " + pos.x + " - y: " + pos.y);
|
$('#status_pos').text("x: " + pos.x + " - y: " + pos.y);
|
||||||
|
|
||||||
|
$("#rng_white").val(0);
|
||||||
$("#rng_red").val(color[0]);
|
$("#rng_red").val(color[0]);
|
||||||
$("#rng_green").val(color[1]);
|
$("#rng_green").val(color[1]);
|
||||||
$("#rng_blue").val(color[2]);
|
$("#rng_blue").val(color[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user