Bug Fixes
Bug Fixes
This commit is contained in:
@@ -112,7 +112,11 @@ ESP8266HTTPUpdateServer httpUpdater;
|
||||
|
||||
#ifdef USE_WS2812FX_DMA
|
||||
#include <NeoPixelBus.h>
|
||||
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
#ifdef RGBW
|
||||
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 4); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
#else
|
||||
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
#endif
|
||||
//NeoEsp8266Dma400KbpsMethod dma = NeoEsp8266Dma400KbpsMethod(NUMLEDS, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
#endif
|
||||
#ifdef USE_WS2812FX_UART
|
||||
@@ -711,7 +715,7 @@ DBG_OUTPUT_PORT.println("Starting....");
|
||||
|
||||
server.on("/get_color", []() {
|
||||
char rgbcolor[9];
|
||||
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", main_color.red, main_color.green, main_color.blue, main_color.white);
|
||||
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", main_color.white, main_color.red, main_color.green, main_color.blue);
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "text/plain", rgbcolor );
|
||||
DBG_OUTPUT_PORT.print("/get_color: ");
|
||||
|
||||
@@ -193,7 +193,7 @@ void WS2812FX::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
}
|
||||
|
||||
void WS2812FX::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
|
||||
setColor((((uint32_t)r << 24)| ((uint32_t)g << 16) | ((uint32_t)b << 8)| ((uint32_t)w)));
|
||||
setColor((((uint32_t)w << 24)| ((uint32_t)r << 16) | ((uint32_t)g << 8)| ((uint32_t)b)));
|
||||
}
|
||||
|
||||
void WS2812FX::setColor(uint32_t c) {
|
||||
|
||||
@@ -431,7 +431,7 @@ class WS2812FX : public Adafruit_NeoPixel {
|
||||
increaseSpeed(uint8_t s),
|
||||
decreaseSpeed(uint8_t s),
|
||||
setColor(uint8_t r, uint8_t g, uint8_t b),
|
||||
setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
||||
setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
||||
setColor(uint32_t c),
|
||||
setColor(uint8_t seg, uint32_t c),
|
||||
setColors(uint8_t seg, uint32_t* c),
|
||||
|
||||
@@ -49,15 +49,15 @@ void tickerSpiffsSaveState(){
|
||||
void getArgs() {
|
||||
if (server.arg("rgb") != "") {
|
||||
uint32_t rgb = (uint32_t) strtoul(server.arg("rgb").c_str(), NULL, 16);
|
||||
main_color.red = ((rgb >> 24) & 0xFF);
|
||||
main_color.green = ((rgb >> 16) & 0xFF);
|
||||
main_color.blue = ((rgb >> 8) & 0xFF);
|
||||
main_color.white = ((rgb >> 0) & 0xFF);
|
||||
main_color.white = ((rgb >> 24) & 0xFF);
|
||||
main_color.red = ((rgb >> 16) & 0xFF);
|
||||
main_color.green = ((rgb >> 8) & 0xFF);
|
||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||
} else {
|
||||
main_color.red = server.arg("r").toInt();
|
||||
main_color.green = server.arg("g").toInt();
|
||||
main_color.blue = server.arg("b").toInt();
|
||||
main_color.white = server.arg("w").toInt();
|
||||
main_color.white = server.arg("w").toInt();
|
||||
}
|
||||
if (server.arg("s") != "") {
|
||||
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
||||
@@ -115,10 +115,10 @@ uint16_t convertSpeed(uint8_t mcl_speed) {
|
||||
void handleSetMainColor(uint8_t * mypayload) {
|
||||
// decode rgb data
|
||||
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[1], NULL, 16);
|
||||
main_color.red = ((rgb >> 24) & 0xFF);
|
||||
main_color.green = ((rgb >> 16) & 0xFF);
|
||||
main_color.blue = ((rgb >> 8) & 0xFF);
|
||||
main_color.white = ((rgb >> 0) & 0xFF);
|
||||
main_color.white = ((rgb >> 24) & 0xFF);
|
||||
main_color.red = ((rgb >> 16) & 0xFF);
|
||||
main_color.green = ((rgb >> 8) & 0xFF);
|
||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||
// strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
mode = SETCOLOR;
|
||||
}
|
||||
@@ -127,10 +127,10 @@ void handleSetAllMode(uint8_t * mypayload) {
|
||||
// decode rgb data
|
||||
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[1], NULL, 16);
|
||||
|
||||
main_color.red = ((rgb >> 24) & 0xFF);
|
||||
main_color.green = ((rgb >> 16) & 0xFF);
|
||||
main_color.blue = ((rgb >> 8) & 0xFF);
|
||||
main_color.white = ((rgb >> 0) & 0xFF);
|
||||
main_color.white = ((rgb >> 24) & 0xFF);
|
||||
main_color.red = ((rgb >> 16) & 0xFF);
|
||||
main_color.green = ((rgb >> 8) & 0xFF);
|
||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||
|
||||
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: R: [%u] G: [%u] B: [%u] W: [%u]\n", main_color.red, main_color.green, main_color.blue, main_color.white);
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
@@ -151,11 +151,11 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||
char redhex[3];
|
||||
char greenhex[3];
|
||||
char bluehex[3];
|
||||
char whitehex[3];
|
||||
char whitehex[3];
|
||||
strncpy (redhex, (const char *) &mypayload[2 + firstChar], 2 );
|
||||
strncpy (greenhex, (const char *) &mypayload[4 + firstChar], 2 );
|
||||
strncpy (bluehex, (const char *) &mypayload[6 + firstChar], 2 );
|
||||
strncpy (whitehex, (const char *) &mypayload[2 + firstChar], 2 );
|
||||
strncpy (whitehex, (const char *) &mypayload[8 + firstChar], 2 );
|
||||
ledstates[led].red = strtol(redhex, NULL, 16);
|
||||
ledstates[led].green = strtol(greenhex, NULL, 16);
|
||||
ledstates[led].blue = strtol(bluehex, NULL, 16);
|
||||
@@ -250,16 +250,30 @@ void setModeByStateString(String saved_state_string) {
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue, main_color.white);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
void handleSetNamedMode(String str_mode) {
|
||||
|
||||
void handleSetNamedMode(String str_mode) {
|
||||
exit_func = true;
|
||||
|
||||
if (str_mode.startsWith("=off")) {
|
||||
if (str_mode.startsWith("=off") or str_mode.startsWith("/off")) {
|
||||
mode = OFF;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = false;
|
||||
#endif
|
||||
}
|
||||
if (str_mode.startsWith("=tv") or str_mode.startsWith("/tv")) {
|
||||
mode = TV;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
#endif
|
||||
}
|
||||
if (str_mode.startsWith("=e131") or str_mode.startsWith("/e131")) {
|
||||
if(strip.isRunning()) strip.stop();
|
||||
mode = E131;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
#endif
|
||||
}
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
if (str_mode.startsWith("=auto")) {
|
||||
mode = AUTO;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
@@ -309,28 +323,8 @@ void setModeByStateString(String saved_state_string) {
|
||||
stateOn = true;
|
||||
#endif
|
||||
}
|
||||
if (str_mode.startsWith("=tv")) {
|
||||
mode = TV;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_E131
|
||||
void handleE131NamedMode(String str_mode) {
|
||||
exit_func = true;
|
||||
if (str_mode.startsWith("=e131") or str_mode.startsWith("/e131")) {
|
||||
if(strip.isRunning()) strip.stop();
|
||||
mode = E131;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
||||
mode = SET_MODE;
|
||||
uint8_t ws2812fx_mode_tmp = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
||||
@@ -349,10 +343,10 @@ String listStatusJSON(void) {
|
||||
root["speed"] = ws2812fx_speed;
|
||||
root["brightness"] = brightness;
|
||||
JsonArray color = root.createNestedArray("color");
|
||||
color.add(main_color.white);
|
||||
color.add(main_color.red);
|
||||
color.add(main_color.green);
|
||||
color.add(main_color.blue);
|
||||
color.add(main_color.white);
|
||||
|
||||
String json;
|
||||
serializeJson(root, json);
|
||||
@@ -369,6 +363,12 @@ String listModesJSON(void) {
|
||||
const size_t bufferSize = JSON_ARRAY_SIZE(strip.getModeCount()+1) + strip.getModeCount()*JSON_OBJECT_SIZE(2) + 1000;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonArray json = jsonBuffer.to<JsonArray>();
|
||||
JsonObject objectoff = json.createNestedObject();
|
||||
objectoff["mode"] = "off";
|
||||
objectoff["name"] = "OFF";
|
||||
JsonObject objecttv = json.createNestedObject();
|
||||
objecttv["mode"] = "tv";
|
||||
objecttv["name"] = "TV";
|
||||
#ifdef ENABLE_E131
|
||||
JsonObject objecte131 = json.createNestedObject();
|
||||
objecte131["mode"] = "e131";
|
||||
@@ -600,10 +600,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
||||
String str_mode = String((char *) &payload[0]);
|
||||
|
||||
handleSetNamedMode(str_mode);
|
||||
#ifdef ENABLE_E131
|
||||
handleE131NamedMode(str_mode);
|
||||
#endif
|
||||
Dbg_Prefix(mqtt, num);
|
||||
Dbg_Prefix(mqtt, num);
|
||||
DBG_OUTPUT_PORT.printf("Activated mode [%u]!\n", mode);
|
||||
#ifdef ENABLE_MQTT
|
||||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
@@ -670,10 +667,8 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
||||
// / ==> Set WS2812 mode.
|
||||
if (payload[0] == '/') {
|
||||
handleSetWS2812FXMode(payload);
|
||||
#ifdef ENABLE_E131
|
||||
String str_mode = String((char *) &payload[0]);
|
||||
handleE131NamedMode(str_mode);
|
||||
#endif
|
||||
handleSetNamedMode(str_mode);
|
||||
Dbg_Prefix(mqtt, num);
|
||||
DBG_OUTPUT_PORT.printf("Set WS2812 mode: [%s]\n", payload);
|
||||
#ifdef ENABLE_MQTT
|
||||
@@ -815,7 +810,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
color["r"] = main_color.red;
|
||||
color["g"] = main_color.green;
|
||||
color["b"] = main_color.blue;
|
||||
|
||||
color["w"] = main_color.white;
|
||||
|
||||
root["brightness"] = brightness;
|
||||
|
||||
root["color_temp"] = color_temp;
|
||||
|
||||
@@ -208,36 +208,18 @@ $(function(){
|
||||
$('#status').css("backgroundColor", statusColor);
|
||||
$('#status_color').text(statusColor + "- R=" + data.color[1] + ", G=" + data.color[2] + ", B=" + data.color[3]);
|
||||
});
|
||||
|
||||
// Load modes async
|
||||
// List of all color modes
|
||||
// enum MODE { SET_MODE, HOLD, AUTO, OFF, TV, CUSTOM, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW};
|
||||
$.getJSON("http://" + host + "/get_modes", function(data) {
|
||||
console.log("modes", data);
|
||||
var modes_html = "";
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
if (mode == "3") {
|
||||
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 == "4") {
|
||||
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){
|
||||
if (current_mode.mode !== undefined) {
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
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;
|
||||
|
||||
if ((mode == "1" && current_mode.mode == ws2812fx_mode) || (mode == "3" && current_mode.mode == "off") || (mode == "4" && current_mode.mode == "tv") || (mode == "15" && current_mode.mode == "e131")){
|
||||
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;
|
||||
}
|
||||
@@ -457,7 +439,7 @@ $(function(){
|
||||
hexColor = "#" + 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);
|
||||
|
||||
$("#rng_white").val(0);
|
||||
|
||||
@@ -56,34 +56,15 @@ $(function(){
|
||||
|
||||
// Load modes async
|
||||
// List of all color modes
|
||||
// enum MODE { SET_MODE, HOLD, OFF, ALL, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, AUTO };
|
||||
// enum MODE { SET_MODE, HOLD, AUTO, OFF, TV, CUSTOM, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW};
|
||||
$.getJSON("http://" + host + "/get_modes", function(data) {
|
||||
console.log("modes", data);
|
||||
var modes_html = "";
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
if (mode == "3") {
|
||||
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 == "4") {
|
||||
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){
|
||||
if (current_mode.mode !== undefined) {
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
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;
|
||||
|
||||
if ((mode == "1" && current_mode.mode == ws2812fx_mode) || (mode == "3" && current_mode.mode == "off") || (mode == "4" && current_mode.mode == "tv") || (mode == "15" && current_mode.mode == "e131")){
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user