@@ -360,19 +360,26 @@ void initMqtt() {
|
|||||||
#else
|
#else
|
||||||
snprintf(mqtt_clientid, sizeof(mqtt_clientid), "%s", HOSTNAME);
|
snprintf(mqtt_clientid, sizeof(mqtt_clientid), "%s", HOSTNAME);
|
||||||
#endif
|
#endif
|
||||||
|
mqtt_clientid[sizeof(mqtt_clientid) - 1] = 0x00;
|
||||||
snprintf(mqtt_will_topic, sizeof(mqtt_will_topic), "%s/config", HOSTNAME);
|
snprintf(mqtt_will_topic, sizeof(mqtt_will_topic), "%s/config", HOSTNAME);
|
||||||
|
mqtt_will_topic[sizeof(mqtt_will_topic) - 1] = 0x00;
|
||||||
snprintf(mqtt_intopic, sizeof(mqtt_intopic), "%s/in", HOSTNAME);
|
snprintf(mqtt_intopic, sizeof(mqtt_intopic), "%s/in", HOSTNAME);
|
||||||
|
mqtt_intopic[sizeof(mqtt_intopic) - 1] = 0x00;
|
||||||
snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", HOSTNAME);
|
snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", HOSTNAME);
|
||||||
|
mqtt_outtopic[sizeof(mqtt_outtopic) - 1] = 0x00;
|
||||||
#if defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
#if defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
||||||
snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", HOSTNAME);
|
snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", HOSTNAME);
|
||||||
|
mqtt_ha_config[sizeof(mqtt_ha_config) - 1] = 0x00;
|
||||||
snprintf(mqtt_ha_state_in, sizeof(mqtt_ha_state_in), "home/%s_ha/state/in", HOSTNAME);
|
snprintf(mqtt_ha_state_in, sizeof(mqtt_ha_state_in), "home/%s_ha/state/in", HOSTNAME);
|
||||||
|
mqtt_ha_state_in[sizeof(mqtt_ha_state_in) - 1] = 0x00;
|
||||||
snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out), "home/%s_ha/state/out", HOSTNAME);
|
snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out), "home/%s_ha/state/out", HOSTNAME);
|
||||||
|
mqtt_ha_state_out[sizeof(mqtt_ha_state_out) - 1] = 0x00;
|
||||||
#endif
|
#endif
|
||||||
if ((strlen(mqtt_host) != 0) && (mqtt_port != 0)) {
|
if ((strlen(mqtt_host) != 0) && (mqtt_port != 0)) {
|
||||||
#if ENABLE_MQTT == 0
|
#if ENABLE_MQTT == 0
|
||||||
DBG_OUTPUT_PORT.printf("MQTT active: %s:%d\r\n", mqtt_host, mqtt_port);
|
DBG_OUTPUT_PORT.printf("MQTT active: %s:%d\r\n", mqtt_host, mqtt_port);
|
||||||
mqtt_client->setServer(mqtt_host, mqtt_port);
|
mqtt_client->setServer(mqtt_host, mqtt_port);
|
||||||
mqtt_client->setCallback(mqtt_callback);
|
mqtt_client->setCallback(onMqttMessage);
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_MQTT == 1
|
#if ENABLE_MQTT == 1
|
||||||
DBG_OUTPUT_PORT.printf("AMQTT active: %s:%d\r\n", mqtt_host, mqtt_port);
|
DBG_OUTPUT_PORT.printf("AMQTT active: %s:%d\r\n", mqtt_host, mqtt_port);
|
||||||
@@ -451,11 +458,12 @@ void setup() {
|
|||||||
//Strip Config
|
//Strip Config
|
||||||
#if ENABLE_STATE_SAVE == 1
|
#if ENABLE_STATE_SAVE == 1
|
||||||
(readConfigFS()) ? DBG_OUTPUT_PORT.println("WiFiManager config FS read success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Read failure!");
|
(readConfigFS()) ? DBG_OUTPUT_PORT.println("WiFiManager config FS read success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Read failure!");
|
||||||
delay(500);
|
delay(250);
|
||||||
(readStateFS()) ? DBG_OUTPUT_PORT.println("Strip state config FS read Success!") : DBG_OUTPUT_PORT.println("Strip state config FS read failure!");
|
(readStateFS()) ? DBG_OUTPUT_PORT.println("Strip state config FS read Success!") : DBG_OUTPUT_PORT.println("Strip state config FS read failure!");
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#if ENABLE_STATE_SAVE == 0
|
||||||
(setConfByConfString(readEEPROM(0, 222)))? DBG_OUTPUT_PORT.println("WiFiManager config EEPROM read success!"): DBG_OUTPUT_PORT.println("WiFiManager config EEPROM Read failure!");
|
(setConfByConfString(readEEPROM(0, 222)))? DBG_OUTPUT_PORT.println("WiFiManager config EEPROM read success!"): DBG_OUTPUT_PORT.println("WiFiManager config EEPROM Read failure!");
|
||||||
|
delay(250);
|
||||||
(setModeByStateString(readEEPROM(256, 66)))? DBG_OUTPUT_PORT.println("Strip state config EEPROM read Success!") : DBG_OUTPUT_PORT.println("Strip state config EEPROM read failure!");
|
(setModeByStateString(readEEPROM(256, 66)))? DBG_OUTPUT_PORT.println("Strip state config EEPROM read Success!") : DBG_OUTPUT_PORT.println("Strip state config EEPROM read failure!");
|
||||||
#endif
|
#endif
|
||||||
char tmp_strip_size[6], tmp_fxoptions[5], tmp_rgbOrder[5]; //needed tempararily for WiFiManager Settings
|
char tmp_strip_size[6], tmp_fxoptions[5], tmp_rgbOrder[5]; //needed tempararily for WiFiManager Settings
|
||||||
@@ -562,7 +570,7 @@ void setup() {
|
|||||||
#else
|
#else
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
||||||
#endif
|
#endif
|
||||||
last_conf[sizeof(last_conf)]=0;
|
last_conf[sizeof(last_conf)] = 0x00;
|
||||||
writeEEPROM(0, 222, last_conf);
|
writeEEPROM(0, 222, last_conf);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
shouldSaveConfig = false;
|
shouldSaveConfig = false;
|
||||||
@@ -677,6 +685,7 @@ void setup() {
|
|||||||
#if defined(ENABLE_REMOTE)
|
#if defined(ENABLE_REMOTE)
|
||||||
irrecv.enableIRIn(); // Start the receiver
|
irrecv.enableIRIn(); // Start the receiver
|
||||||
snprintf(last_state, sizeof(last_state), "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", mode, ws2812fx_mode, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white, back_color.red, back_color.green, back_color.blue, back_color.white, xtra_color.red, xtra_color.green, xtra_color.blue,xtra_color.white);
|
snprintf(last_state, sizeof(last_state), "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", mode, ws2812fx_mode, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white, back_color.red, back_color.green, back_color.blue, back_color.white, xtra_color.red, xtra_color.green, xtra_color.blue,xtra_color.white);
|
||||||
|
last_state[sizeof(last_state)]= 0x00;
|
||||||
#endif
|
#endif
|
||||||
DBG_OUTPUT_PORT.println("finished Main Setup!");
|
DBG_OUTPUT_PORT.println("finished Main Setup!");
|
||||||
|
|
||||||
@@ -865,6 +874,7 @@ void loop() {
|
|||||||
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
|
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
|
||||||
#endif
|
#endif
|
||||||
snprintf(last_state, sizeof(last_state), "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", prevmode, ws2812fx_mode, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white, back_color.red, back_color.green, back_color.blue, back_color.white, xtra_color.red, xtra_color.green, xtra_color.blue, xtra_color.white);
|
snprintf(last_state, sizeof(last_state), "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", prevmode, ws2812fx_mode, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white, back_color.red, back_color.green, back_color.blue, back_color.white, xtra_color.red, xtra_color.green, xtra_color.blue, xtra_color.white);
|
||||||
|
last_state[sizeof(last_state) - 1] = 0x00;
|
||||||
}
|
}
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
#if ENABLE_MQTT == 0
|
#if ENABLE_MQTT == 0
|
||||||
@@ -901,7 +911,7 @@ void loop() {
|
|||||||
#else
|
#else
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
||||||
#endif
|
#endif
|
||||||
last_conf[sizeof(last_conf)-1]= 0x00;
|
last_conf[sizeof(last_conf) - 1] = 0x00;
|
||||||
writeEEPROM(0, 222, last_conf);
|
writeEEPROM(0, 222, last_conf);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
shouldSaveConfig = false;
|
shouldSaveConfig = false;
|
||||||
|
|||||||
@@ -58,98 +58,103 @@ void convertColors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getArgs() {
|
void getArgs() {
|
||||||
if (server.arg("rgb") != "") {
|
|
||||||
uint32_t rgb = (uint32_t) strtoul(server.arg("rgb").c_str(), NULL, 16);
|
if (mode == SET_ALL || mode == SET_MODE || mode == SET_COLOR) {
|
||||||
main_color.white = ((rgb >> 24) & 0xFF);
|
if (server.arg("rgb") != "") {
|
||||||
main_color.red = ((rgb >> 16) & 0xFF);
|
uint32_t rgb = (uint32_t) strtoul(server.arg("rgb").c_str(), NULL, 16);
|
||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.white = ((rgb >> 24) & 0xFF);
|
||||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
main_color.red = ((rgb >> 16) & 0xFF);
|
||||||
} else {
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
if ((server.arg("r") != "") && (server.arg("r").toInt() >= 0) && (server.arg("r").toInt() <= 255)) {
|
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
main_color.red = server.arg("r").toInt();
|
} else {
|
||||||
|
if ((server.arg("r") != "") && (server.arg("r").toInt() >= 0) && (server.arg("r").toInt() <= 255)) {
|
||||||
|
main_color.red = server.arg("r").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("g") != "") && (server.arg("g").toInt() >= 0) && (server.arg("g").toInt() <= 255)) {
|
||||||
|
main_color.green = server.arg("g").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("b") != "") && (server.arg("b").toInt() >= 0) && (server.arg("b").toInt() <= 255)) {
|
||||||
|
main_color.blue = server.arg("b").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("w") != "") && (server.arg("w").toInt() >= 0) && (server.arg("w").toInt() <= 255)){
|
||||||
|
main_color.white = server.arg("w").toInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((server.arg("g") != "") && (server.arg("g").toInt() >= 0) && (server.arg("g").toInt() <= 255)) {
|
if (server.arg("rgb2") != "") {
|
||||||
main_color.green = server.arg("g").toInt();
|
uint32_t rgb2 = (uint32_t) strtoul(server.arg("rgb2").c_str(), NULL, 16);
|
||||||
|
back_color.white = ((rgb2 >> 24) & 0xFF);
|
||||||
|
back_color.red = ((rgb2 >> 16) & 0xFF);
|
||||||
|
back_color.green = ((rgb2 >> 8) & 0xFF);
|
||||||
|
back_color.blue = ((rgb2 >> 0) & 0xFF);
|
||||||
|
} else {
|
||||||
|
if ((server.arg("r2") != "") && (server.arg("r2").toInt() >= 0) && (server.arg("r2").toInt() <= 255)) {
|
||||||
|
back_color.red = server.arg("r2").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("g2") != "") && (server.arg("g2").toInt() >= 0) && (server.arg("g2").toInt() <= 255)) {
|
||||||
|
back_color.green = server.arg("g2").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("b2") != "") && (server.arg("b2").toInt() >= 0) && (server.arg("b2").toInt() <= 255)) {
|
||||||
|
back_color.blue = server.arg("b2").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("w2") != "") && (server.arg("w2").toInt() >= 0) && (server.arg("w2").toInt() <= 255)){
|
||||||
|
back_color.white = server.arg("w2").toInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((server.arg("b") != "") && (server.arg("b").toInt() >= 0) && (server.arg("b").toInt() <= 255)) {
|
if (server.arg("rgb3") != "") {
|
||||||
main_color.blue = server.arg("b").toInt();
|
uint32_t rgb3 = (uint32_t) strtoul(server.arg("rgb3").c_str(), NULL, 16);
|
||||||
|
xtra_color.white = ((rgb3 >> 24) & 0xFF);
|
||||||
|
xtra_color.red = ((rgb3 >> 16) & 0xFF);
|
||||||
|
xtra_color.green = ((rgb3 >> 8) & 0xFF);
|
||||||
|
xtra_color.blue = ((rgb3 >> 0) & 0xFF);
|
||||||
|
} else {
|
||||||
|
if ((server.arg("r3") != "") && (server.arg("r3").toInt() >= 0) && (server.arg("r3").toInt() <= 255)) {
|
||||||
|
xtra_color.red = server.arg("r3").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("g3") != "") && (server.arg("g3").toInt() >= 0) && (server.arg("g3").toInt() <= 255)) {
|
||||||
|
xtra_color.green = server.arg("g3").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("b3") != "") && (server.arg("b3").toInt() >= 0) && (server.arg("b3").toInt() <= 255)) {
|
||||||
|
xtra_color.blue = server.arg("b3").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("w3") != "") && (server.arg("w3").toInt() >= 0) && (server.arg("w3").toInt() <= 255)){
|
||||||
|
xtra_color.white = server.arg("w3").toInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((server.arg("w") != "") && (server.arg("w").toInt() >= 0) && (server.arg("w").toInt() <= 255)){
|
main_color.red = constrain(main_color.red, 0, 255);
|
||||||
main_color.white = server.arg("w").toInt();
|
main_color.green = constrain(main_color.green, 0, 255);
|
||||||
|
main_color.blue = constrain(main_color.blue, 0, 255);
|
||||||
|
main_color.white = constrain(main_color.white, 0, 255);
|
||||||
|
back_color.red = constrain(back_color.red, 0, 255);
|
||||||
|
back_color.green = constrain(back_color.green, 0, 255);
|
||||||
|
back_color.blue = constrain(back_color.blue, 0, 255);
|
||||||
|
back_color.white = constrain(back_color.white, 0, 255);
|
||||||
|
xtra_color.red = constrain(xtra_color.red, 0, 255);
|
||||||
|
xtra_color.green = constrain(xtra_color.green, 0, 255);
|
||||||
|
xtra_color.blue = constrain(xtra_color.blue, 0, 255);
|
||||||
|
xtra_color.white = constrain(xtra_color.white, 0, 255);
|
||||||
|
convertColors();
|
||||||
|
}
|
||||||
|
if (mode == SET_ALL || mode == SET_MODE || mode == SET_SPEED || mode == TV) {
|
||||||
|
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
|
||||||
|
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (server.arg("rgb2") != "") {
|
if (mode == SET_ALL || mode == SET_MODE) {
|
||||||
uint32_t rgb2 = (uint32_t) strtoul(server.arg("rgb2").c_str(), NULL, 16);
|
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) {
|
||||||
back_color.white = ((rgb2 >> 24) & 0xFF);
|
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
|
||||||
back_color.red = ((rgb2 >> 16) & 0xFF);
|
|
||||||
back_color.green = ((rgb2 >> 8) & 0xFF);
|
|
||||||
back_color.blue = ((rgb2 >> 0) & 0xFF);
|
|
||||||
} else {
|
|
||||||
if ((server.arg("r2") != "") && (server.arg("r2").toInt() >= 0) && (server.arg("r2").toInt() <= 255)) {
|
|
||||||
back_color.red = constrain(server.arg("r2").toInt(), 0, 255);
|
|
||||||
}
|
|
||||||
if ((server.arg("g2") != "") && (server.arg("g2").toInt() >= 0) && (server.arg("g2").toInt() <= 255)) {
|
|
||||||
back_color.green = server.arg("g2").toInt();
|
|
||||||
}
|
|
||||||
if ((server.arg("b2") != "") && (server.arg("b2").toInt() >= 0) && (server.arg("b2").toInt() <= 255)) {
|
|
||||||
back_color.blue = server.arg("b2").toInt();
|
|
||||||
}
|
|
||||||
if ((server.arg("w2") != "") && (server.arg("w2").toInt() >= 0) && (server.arg("w2").toInt() <= 255)){
|
|
||||||
back_color.white = server.arg("w2").toInt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (server.arg("rgb3") != "") {
|
if (mode == SET_ALL || mode == SET_MODE || mode == SET_BRIGHTNESS || mode == AUTO || mode == TV || mode == E131) {
|
||||||
uint32_t rgb3 = (uint32_t) strtoul(server.arg("rgb3").c_str(), NULL, 16);
|
if ((server.arg("c") != "") && (server.arg("c").toInt() >= 0) && (server.arg("c").toInt() <= 100)) {
|
||||||
xtra_color.white = ((rgb3 >> 24) & 0xFF);
|
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
||||||
xtra_color.red = ((rgb3 >> 16) & 0xFF);
|
} else if ((server.arg("p") != "") && (server.arg("p").toInt() >= 0) && (server.arg("p").toInt() <= 255)) {
|
||||||
xtra_color.green = ((rgb3 >> 8) & 0xFF);
|
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||||
xtra_color.blue = ((rgb3 >> 0) & 0xFF);
|
|
||||||
} else {
|
|
||||||
if ((server.arg("r3") != "") && (server.arg("r3").toInt() >= 0) && (server.arg("r3").toInt() <= 255)) {
|
|
||||||
xtra_color.red = server.arg("r3").toInt();
|
|
||||||
}
|
|
||||||
if ((server.arg("g3") != "") && (server.arg("g3").toInt() >= 0) && (server.arg("g3").toInt() <= 255)) {
|
|
||||||
xtra_color.green = server.arg("g3").toInt();
|
|
||||||
}
|
|
||||||
if ((server.arg("b3") != "") && (server.arg("b3").toInt() >= 0) && (server.arg("b3").toInt() <= 255)) {
|
|
||||||
xtra_color.blue = server.arg("b3").toInt();
|
|
||||||
}
|
|
||||||
if ((server.arg("w3") != "") && (server.arg("w3").toInt() >= 0) && (server.arg("w3").toInt() <= 255)){
|
|
||||||
xtra_color.white = server.arg("w3").toInt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
|
|
||||||
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStatusJSON());
|
||||||
}
|
|
||||||
|
|
||||||
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) {
|
|
||||||
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((server.arg("c") != "") && (server.arg("c").toInt() >= 0) && (server.arg("c").toInt() <= 100)) {
|
|
||||||
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
|
||||||
} else if ((server.arg("p") != "") && (server.arg("p").toInt() >= 0) && (server.arg("p").toInt() <= 255)) {
|
|
||||||
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
main_color.red = constrain(main_color.red, 0, 255);
|
|
||||||
main_color.green = constrain(main_color.green, 0, 255);
|
|
||||||
main_color.blue = constrain(main_color.blue, 0, 255);
|
|
||||||
main_color.white = constrain(main_color.white, 0, 255);
|
|
||||||
back_color.red = constrain(back_color.red, 0, 255);
|
|
||||||
back_color.green = constrain(back_color.green, 0, 255);
|
|
||||||
back_color.blue = constrain(back_color.blue, 0, 255);
|
|
||||||
back_color.white = constrain(back_color.white, 0, 255);
|
|
||||||
xtra_color.red = constrain(xtra_color.red, 0, 255);
|
|
||||||
xtra_color.green = constrain(xtra_color.green, 0, 255);
|
|
||||||
xtra_color.blue = constrain(xtra_color.blue, 0, 255);
|
|
||||||
xtra_color.white = constrain(xtra_color.white, 0, 255);
|
|
||||||
convertColors();
|
|
||||||
DBG_OUTPUT_PORT.print("Get Args: ");
|
|
||||||
DBG_OUTPUT_PORT.println(listStatusJSON());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint16_t convertSpeed(uint8_t mcl_speed) {
|
uint16_t convertSpeed(uint8_t mcl_speed) {
|
||||||
//long ws2812_speed = mcl_speed * 256;
|
//long ws2812_speed = mcl_speed * 256;
|
||||||
uint16_t ws2812_speed = 61760 * (exp(0.0002336 * mcl_speed) - exp(-0.03181 * mcl_speed));
|
uint16_t ws2812_speed = 61760 * (exp(0.0002336 * mcl_speed) - exp(-0.03181 * mcl_speed));
|
||||||
@@ -279,11 +284,12 @@ void handleRangeDifferentColors(uint8_t * mypayload) {
|
|||||||
colorval[8] = 0x00;
|
colorval[8] = 0x00;
|
||||||
uint8_t rangebegin = atoi(startled);
|
uint8_t rangebegin = atoi(startled);
|
||||||
uint8_t rangeend = atoi(endled);
|
uint8_t rangeend = atoi(endled);
|
||||||
DBG_OUTPUT_PORT.printf("Setting RANGE from [%i] to [%i] as color [%s] \r\n", rangebegin, rangeend, colorval);
|
DBG_OUTPUT_PORT.printf("Setting RANGE from [%i] to [%i] as color [%s]\r\n", rangebegin, rangeend, colorval);
|
||||||
|
|
||||||
while ( rangebegin <= rangeend ) {
|
while ( rangebegin <= rangeend ) {
|
||||||
char rangeData[11];
|
char rangeData[11];
|
||||||
snprintf(rangeData, sizeof(rangeData), "%02d%s", rangebegin, colorval);
|
snprintf(rangeData, sizeof(rangeData), "%02d%s", rangebegin, colorval);
|
||||||
|
rangeData[sizeof(rangeData) - 1] = 0x00;
|
||||||
// Set one LED
|
// Set one LED
|
||||||
handleSetSingleLED((uint8_t*) rangeData, 0);
|
handleSetSingleLED((uint8_t*) rangeData, 0);
|
||||||
rangebegin++;
|
rangebegin++;
|
||||||
@@ -663,10 +669,7 @@ void getModesJSON() {
|
|||||||
// HTTP request handlers
|
// HTTP request handlers
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void handleMinimalUpload() {
|
void handleMinimalUpload() {
|
||||||
char temp[1500];
|
char message[] = "<!DOCTYPE html>\
|
||||||
|
|
||||||
snprintf ( temp, 1500,
|
|
||||||
"<!DOCTYPE html>\
|
|
||||||
<html>\
|
<html>\
|
||||||
<head>\
|
<head>\
|
||||||
<title>ESP8266 Upload</title>\
|
<title>ESP8266 Upload</title>\
|
||||||
@@ -681,10 +684,9 @@ void handleMinimalUpload() {
|
|||||||
<button>Upload</button>\
|
<button>Upload</button>\
|
||||||
</form>\
|
</form>\
|
||||||
</body>\
|
</body>\
|
||||||
</html>"
|
</html>";
|
||||||
);
|
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send ( 200, "text/html", temp );
|
server.send ( 200, "text/html", message );
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNotFound() {
|
void handleNotFound() {
|
||||||
@@ -872,8 +874,8 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
#if !defined(USE_WS2812FX_DMA)
|
#if !defined(USE_WS2812FX_DMA)
|
||||||
if (payload[2] == 'p') {
|
if (payload[2] == 'p') {
|
||||||
char tmp_pin[3];
|
char tmp_pin[3];
|
||||||
tmp_pin[2] = 0x00;
|
|
||||||
snprintf(tmp_pin, sizeof(tmp_pin), "%s", &payload[3]);
|
snprintf(tmp_pin, sizeof(tmp_pin), "%s", &payload[3]);
|
||||||
|
tmp_pin[2] = 0x00;
|
||||||
checkPin(atoi(tmp_pin));
|
checkPin(atoi(tmp_pin));
|
||||||
updateStrip = true;
|
updateStrip = true;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
@@ -892,26 +894,31 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
}
|
}
|
||||||
if (payload[1] == 'h') {
|
if (payload[1] == 'h') {
|
||||||
snprintf(HOSTNAME, sizeof(HOSTNAME), "%s", &payload[2]);
|
snprintf(HOSTNAME, sizeof(HOSTNAME), "%s", &payload[2]);
|
||||||
|
HOSTNAME[sizeof(HOSTNAME) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
if (payload[1] == 'm') {
|
if (payload[1] == 'm') {
|
||||||
if (payload[2] == 'h') {
|
if (payload[2] == 'h') {
|
||||||
snprintf(mqtt_host, sizeof(mqtt_host), "%s", &payload[3]);
|
snprintf(mqtt_host, sizeof(mqtt_host), "%s", &payload[3]);
|
||||||
|
mqtt_host[sizeof(mqtt_host) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
if (payload[2] == 'p') {
|
if (payload[2] == 'p') {
|
||||||
char tmp_port[6];
|
char tmp_port[6];
|
||||||
snprintf(tmp_port, sizeof(tmp_port), "%s", &payload[3]);
|
snprintf(tmp_port, sizeof(tmp_port), "%s", &payload[3]);
|
||||||
|
tmp_port[sizeof(tmp_port) - 1] = 0x00;
|
||||||
mqtt_port = constrain(atoi(tmp_port), 0, 65535);
|
mqtt_port = constrain(atoi(tmp_port), 0, 65535);
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
if (payload[2] == 'u') {
|
if (payload[2] == 'u') {
|
||||||
snprintf(mqtt_user, sizeof(mqtt_user), "%s", &payload[3]);
|
snprintf(mqtt_user, sizeof(mqtt_user), "%s", &payload[3]);
|
||||||
|
mqtt_user[sizeof(mqtt_user) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
if (payload[2] == 'w') {
|
if (payload[2] == 'w') {
|
||||||
snprintf(mqtt_pass, sizeof(mqtt_pass), "%s", &payload[3]);
|
snprintf(mqtt_pass, sizeof(mqtt_pass), "%s", &payload[3]);
|
||||||
|
mqtt_pass[sizeof(mqtt_pass) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1254,24 +1261,18 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_MQTT == 0
|
||||||
|
void onMqttMessage(char* topic, byte* payload_in, uint16_t length) {
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLE_MQTT == 1
|
#if ENABLE_MQTT == 1
|
||||||
void onMqttMessage(char* topic, char* payload_in, AsyncMqttClientMessageProperties properties, size_t length, size_t index, size_t total) {
|
void onMqttMessage(char* topic, char* payload_in, AsyncMqttClientMessageProperties properties, size_t length, size_t index, size_t total) {
|
||||||
DBG_OUTPUT_PORT.print("MQTT: Recieved ["); DBG_OUTPUT_PORT.print(topic);
|
#endif
|
||||||
// DBG_OUTPUT_PORT.print("]: "); DBG_OUTPUT_PORT.println(payload_in);
|
|
||||||
uint8_t * payload = (uint8_t *) malloc(length + 1);
|
uint8_t * payload = (uint8_t *) malloc(length + 1);
|
||||||
memcpy(payload, payload_in, length);
|
memcpy(payload, payload_in, length);
|
||||||
payload[length] = 0;
|
payload[length] = 0;
|
||||||
DBG_OUTPUT_PORT.printf("]: %s\r\n", payload);
|
DBG_OUTPUT_PORT.printf("MQTT: Recieved [%s]: %s\r\n", topic, payload);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLE_MQTT == 0
|
|
||||||
void mqtt_callback(char* topic, byte* payload_in, uint16_t length) {
|
|
||||||
uint8_t * payload = (uint8_t *)malloc(length + 1);
|
|
||||||
memcpy(payload, payload_in, length);
|
|
||||||
payload[length] = 0;
|
|
||||||
DBG_OUTPUT_PORT.printf("MQTT: Message arrived [%s]\r\n", payload);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_HOMEASSISTANT)
|
#if defined(ENABLE_HOMEASSISTANT)
|
||||||
if (strcmp(topic, mqtt_ha_state_in) == 0) {
|
if (strcmp(topic, mqtt_ha_state_in) == 0) {
|
||||||
if (!processJson((char*)payload)) {
|
if (!processJson((char*)payload)) {
|
||||||
@@ -1503,6 +1504,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
DBG_OUTPUT_PORT.printf("Short button press\r\n");
|
DBG_OUTPUT_PORT.printf("Short button press\r\n");
|
||||||
if (mode == OFF) {
|
if (mode == OFF) {
|
||||||
setModeByStateString(BTN_MODE_SHORT);
|
setModeByStateString(BTN_MODE_SHORT);
|
||||||
|
prevmode = mode;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
} else {
|
} else {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
@@ -1513,6 +1515,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
void mediumKeyPress() {
|
void mediumKeyPress() {
|
||||||
DBG_OUTPUT_PORT.printf("Medium button press\r\n");
|
DBG_OUTPUT_PORT.printf("Medium button press\r\n");
|
||||||
setModeByStateString(BTN_MODE_MEDIUM);
|
setModeByStateString(BTN_MODE_MEDIUM);
|
||||||
|
prevmode = mode;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1520,6 +1523,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
void longKeyPress() {
|
void longKeyPress() {
|
||||||
DBG_OUTPUT_PORT.printf("Long button press\r\n");
|
DBG_OUTPUT_PORT.printf("Long button press\r\n");
|
||||||
setModeByStateString(BTN_MODE_LONG);
|
setModeByStateString(BTN_MODE_LONG);
|
||||||
|
prevmode = mode;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1557,8 +1561,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
#if defined(ENABLE_BUTTON_GY33)
|
#if defined(ENABLE_BUTTON_GY33)
|
||||||
void shortKeyPress_gy33() {
|
void shortKeyPress_gy33() {
|
||||||
DBG_OUTPUT_PORT.printf("Short GY-33 button press\r\n");
|
DBG_OUTPUT_PORT.printf("Short GY-33 button press\r\n");
|
||||||
// tcs.setConfig(MCU_LED_04, MCU_WHITE_OFF);
|
|
||||||
// delay(500);
|
|
||||||
uint16_t red, green, blue, cl, ct, lux;
|
uint16_t red, green, blue, cl, ct, lux;
|
||||||
tcs.getRawData(&red, &green, &blue, &cl, &lux, &ct);
|
tcs.getRawData(&red, &green, &blue, &cl, &lux, &ct);
|
||||||
DBG_OUTPUT_PORT.printf("Raw Colors: R: [%d] G: [%d] B: [%d] Clear: [%d] Lux: [%d] Colortemp: [%d]\r\n", (int)red, (int)green, (int)blue, (int)cl, (int)lux, (int)ct);
|
DBG_OUTPUT_PORT.printf("Raw Colors: R: [%d] G: [%d] B: [%d] Clear: [%d] Lux: [%d] Colortemp: [%d]\r\n", (int)red, (int)green, (int)blue, (int)cl, (int)lux, (int)ct);
|
||||||
@@ -1566,14 +1568,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
tcs.getData(&r, &g, &b, &col, &conf);
|
tcs.getData(&r, &g, &b, &col, &conf);
|
||||||
DBG_OUTPUT_PORT.printf("Colors: R: [%d] G: [%d] B: [%d] Color: [%d] Conf: [%d]\r\n", (int)r, (int)g, (int)b, (int)col, (int)conf);
|
DBG_OUTPUT_PORT.printf("Colors: R: [%d] G: [%d] B: [%d] Color: [%d] Conf: [%d]\r\n", (int)r, (int)g, (int)b, (int)col, (int)conf);
|
||||||
main_color.red = (pow((r/255.0), 2.5)*255); main_color.green = (pow((g/255.0), 2.5)*255); main_color.blue = (pow((b/255.0), 2.5)*255);main_color.white = 0;
|
main_color.red = (pow((r/255.0), 2.5)*255); main_color.green = (pow((g/255.0), 2.5)*255); main_color.blue = (pow((b/255.0), 2.5)*255);main_color.white = 0;
|
||||||
ws2812fx_mode = 0;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
|
prevmode = HOLD;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
// tcs.setConfig(MCU_LED_OFF, MCU_WHITE_OFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when button is kept pressed for less than 2 seconds
|
// called when button is kept pressed for less than 2 seconds
|
||||||
void mediumKeyPress_gy33() {
|
void mediumKeyPress_gy33() {
|
||||||
tcs.setConfig(MCU_LED_06, MCU_WHITE_OFF);
|
tcs.setConfig(MCU_LED_03, MCU_WHITE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when button is kept pressed for 2 seconds or more
|
// called when button is kept pressed for 2 seconds or more
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Setup: Webserver handler
|
// Setup: Webserver handler
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
//list directory
|
//list directory
|
||||||
@@ -193,28 +193,30 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/set_brightness", []() {
|
server.on("/set_brightness", []() {
|
||||||
getArgs();
|
mode = SET_BRIGHTNESS;
|
||||||
mode = SET_BRIGHTNESS;
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/get_brightness", []() {
|
server.on("/get_brightness", []() {
|
||||||
char str_brightness[4];
|
char str_brightness[4];
|
||||||
snprintf(str_brightness, sizeof(str_brightness), "%i", (int) (brightness / 2.55));
|
snprintf(str_brightness, sizeof(str_brightness), "%i", (int) (brightness / 2.55));
|
||||||
|
str_brightness[sizeof(str_brightness) - 1] = 0x00;
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send(200, "text/plain", str_brightness );
|
server.send(200, "text/plain", str_brightness );
|
||||||
DBG_OUTPUT_PORT.printf("/get_brightness: %i\r\n", (int) (brightness / 2.55));
|
DBG_OUTPUT_PORT.printf("/get_brightness: %i\r\n", (int) (brightness / 2.55));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/set_speed", []() {
|
server.on("/set_speed", []() {
|
||||||
getArgs();
|
|
||||||
mode = SET_SPEED;
|
mode = SET_SPEED;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/get_speed", []() {
|
server.on("/get_speed", []() {
|
||||||
char str_speed[4];
|
char str_speed[4];
|
||||||
snprintf(str_speed, sizeof(str_speed), "%i", ws2812fx_speed);
|
snprintf(str_speed, sizeof(str_speed), "%i", ws2812fx_speed);
|
||||||
|
str_speed[sizeof(str_speed) - 1] = 0x00;
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send(200, "text/plain", str_speed );
|
server.send(200, "text/plain", str_speed );
|
||||||
DBG_OUTPUT_PORT.printf("/get_speed: %i\r\n", ws2812fx_speed);
|
DBG_OUTPUT_PORT.printf("/get_speed: %i\r\n", ws2812fx_speed);
|
||||||
@@ -229,6 +231,7 @@
|
|||||||
server.on("/get_color", []() {
|
server.on("/get_color", []() {
|
||||||
char rgbcolor[10];
|
char rgbcolor[10];
|
||||||
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);
|
||||||
|
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send(200, "text/plain", rgbcolor );
|
server.send(200, "text/plain", rgbcolor );
|
||||||
DBG_OUTPUT_PORT.print("/get_color: ");
|
DBG_OUTPUT_PORT.print("/get_color: ");
|
||||||
@@ -238,6 +241,7 @@
|
|||||||
server.on("/get_color2", []() {
|
server.on("/get_color2", []() {
|
||||||
char rgbcolor[10];
|
char rgbcolor[10];
|
||||||
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", back_color.white, back_color.red, back_color.green, back_color.blue);
|
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", back_color.white, back_color.red, back_color.green, back_color.blue);
|
||||||
|
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send(200, "text/plain", rgbcolor );
|
server.send(200, "text/plain", rgbcolor );
|
||||||
DBG_OUTPUT_PORT.print("/get_color2: ");
|
DBG_OUTPUT_PORT.print("/get_color2: ");
|
||||||
@@ -247,6 +251,7 @@
|
|||||||
server.on("/get_color3", []() {
|
server.on("/get_color3", []() {
|
||||||
char rgbcolor[10];
|
char rgbcolor[10];
|
||||||
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", xtra_color.white, xtra_color.red, xtra_color.green, xtra_color.blue);
|
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", xtra_color.white, xtra_color.red, xtra_color.green, xtra_color.blue);
|
||||||
|
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send(200, "text/plain", rgbcolor );
|
server.send(200, "text/plain", rgbcolor );
|
||||||
DBG_OUTPUT_PORT.print("/get_color3: ");
|
DBG_OUTPUT_PORT.print("/get_color3: ");
|
||||||
@@ -285,6 +290,7 @@
|
|||||||
if(server.hasArg("ws_rgbo")){
|
if(server.hasArg("ws_rgbo")){
|
||||||
char tmp_rgbOrder[5];
|
char tmp_rgbOrder[5];
|
||||||
snprintf(tmp_rgbOrder, sizeof(tmp_rgbOrder), "%s", server.arg("ws_rgbo").c_str());
|
snprintf(tmp_rgbOrder, sizeof(tmp_rgbOrder), "%s", server.arg("ws_rgbo").c_str());
|
||||||
|
tmp_rgbOrder[sizeof(tmp_rgbOrder) - 1] = 0x00;
|
||||||
checkRGBOrder(tmp_rgbOrder);
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
updateStrip = true;
|
updateStrip = true;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
@@ -312,12 +318,14 @@
|
|||||||
|
|
||||||
if(server.hasArg("hostname")){
|
if(server.hasArg("hostname")){
|
||||||
snprintf(HOSTNAME, sizeof(HOSTNAME), "%s", server.arg("hostname").c_str());
|
snprintf(HOSTNAME, sizeof(HOSTNAME), "%s", server.arg("hostname").c_str());
|
||||||
|
HOSTNAME[sizeof(HOSTNAME) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
if(server.hasArg("mqtt_host")){
|
if(server.hasArg("mqtt_host")){
|
||||||
snprintf(mqtt_host, sizeof(mqtt_host), "%s", server.arg("mqtt_host").c_str());
|
snprintf(mqtt_host, sizeof(mqtt_host), "%s", server.arg("mqtt_host").c_str());
|
||||||
|
mqtt_host[sizeof(mqtt_host) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
if(server.hasArg("mqtt_port")){
|
if(server.hasArg("mqtt_port")){
|
||||||
@@ -328,10 +336,12 @@
|
|||||||
}
|
}
|
||||||
if(server.hasArg("mqtt_user")){
|
if(server.hasArg("mqtt_user")){
|
||||||
snprintf(mqtt_user, sizeof(mqtt_user), "%s", server.arg("mqtt_user").c_str());
|
snprintf(mqtt_user, sizeof(mqtt_user), "%s", server.arg("mqtt_user").c_str());
|
||||||
|
mqtt_user[sizeof(mqtt_user) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
if(server.hasArg("mqtt_pass")){
|
if(server.hasArg("mqtt_pass")){
|
||||||
snprintf(mqtt_pass, sizeof(mqtt_pass), "%s", server.arg("mqtt_pass").c_str());
|
snprintf(mqtt_pass, sizeof(mqtt_pass), "%s", server.arg("mqtt_pass").c_str());
|
||||||
|
mqtt_pass[sizeof(mqtt_pass) - 1] = 0x00;
|
||||||
updateConf = true;
|
updateConf = true;
|
||||||
}
|
}
|
||||||
if (updateConf) {
|
if (updateConf) {
|
||||||
@@ -347,7 +357,6 @@
|
|||||||
updateStrip = false;
|
updateStrip = false;
|
||||||
updateConf = false;
|
updateConf = false;
|
||||||
getConfigJSON();
|
getConfigJSON();
|
||||||
delay(500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/off", []() {
|
server.on("/off", []() {
|
||||||
@@ -357,56 +366,57 @@
|
|||||||
|
|
||||||
server.on("/auto", []() {
|
server.on("/auto", []() {
|
||||||
mode = AUTO;
|
mode = AUTO;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/all", []() {
|
server.on("/all", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_STATIC;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
#if defined(ENABLE_LEGACY_ANIMATIONS)
|
#if defined(ENABLE_LEGACY_ANIMATIONS)
|
||||||
server.on("/wipe", []() {
|
server.on("/wipe", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_COLOR_WIPE;
|
ws2812fx_mode = FX_MODE_COLOR_WIPE;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/rainbow", []() {
|
server.on("/rainbow", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_RAINBOW;
|
ws2812fx_mode = FX_MODE_RAINBOW;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/rainbowcycle", []() {
|
server.on("/rainbowcycle", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_RAINBOW_CYCLE;
|
ws2812fx_mode = FX_MODE_RAINBOW_CYCLE;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/theaterchase", []() {
|
server.on("/theaterchase", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_THEATER_CHASE;
|
ws2812fx_mode = FX_MODE_THEATER_CHASE;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/twinklerandom", []() {
|
server.on("/twinklerandom", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_TWINKLE_RANDOM;
|
ws2812fx_mode = FX_MODE_TWINKLE_RANDOM;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/theaterchaserainbow", []() {
|
server.on("/theaterchaserainbow", []() {
|
||||||
getArgs();
|
|
||||||
ws2812fx_mode = FX_MODE_THEATER_CHASE_RAINBOW;
|
ws2812fx_mode = FX_MODE_THEATER_CHASE_RAINBOW;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
@@ -414,6 +424,7 @@
|
|||||||
#if defined(ENABLE_E131)
|
#if defined(ENABLE_E131)
|
||||||
server.on("/e131", []() {
|
server.on("/e131", []() {
|
||||||
mode = E131;
|
mode = E131;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
@@ -421,6 +432,7 @@
|
|||||||
#if defined(ENABLE_TV)
|
#if defined(ENABLE_TV)
|
||||||
server.on("/tv", []() {
|
server.on("/tv", []() {
|
||||||
mode = TV;
|
mode = TV;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
@@ -430,7 +442,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/set_mode", []() {
|
server.on("/set_mode", []() {
|
||||||
getArgs();
|
|
||||||
mode = SET_MODE;
|
mode = SET_MODE;
|
||||||
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -146,4 +146,7 @@
|
|||||||
* added pointer for MQTT again
|
* added pointer for MQTT again
|
||||||
* Removed some String datatype and replaced with char array
|
* Removed some String datatype and replaced with char array
|
||||||
* better responsiveness in ui for sliders
|
* better responsiveness in ui for sliders
|
||||||
*/
|
*
|
||||||
|
* 26 Mar 2019
|
||||||
|
* Bugfixes
|
||||||
|
*/
|
||||||
|
|||||||
+4
-3
@@ -35,8 +35,8 @@ arduino_core_2_5_0 = espressif8266@2.0.4
|
|||||||
arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
||||||
|
|
||||||
framework = arduino
|
framework = arduino
|
||||||
platform = ${common.arduino_core_2_4_2}
|
;platform = ${common.arduino_core_2_4_2}
|
||||||
; platform = ${common.arduino_core_2_5_0}
|
platform = ${common.arduino_core_2_5_0}
|
||||||
build_flags =
|
build_flags =
|
||||||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
||||||
-DMQTT_MAX_PACKET_SIZE=512 ; PubSubClient Specific flags
|
-DMQTT_MAX_PACKET_SIZE=512 ; PubSubClient Specific flags
|
||||||
@@ -74,9 +74,10 @@ lib_deps = ${common.lib_deps}
|
|||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
framework = ${common.framework}
|
framework = ${common.framework}
|
||||||
platform = ${common.platform}
|
platform = ${common.platform}
|
||||||
|
board_build.f_cpu = 160000000L
|
||||||
build_flags =
|
build_flags =
|
||||||
${common.build_flags}
|
${common.build_flags}
|
||||||
; -Wl,-Teagle.flash.4m3m.ld ;;;; Required for core > v2.5.0 or staging version
|
-Wl,-Teagle.flash.4m3m.ld ; Required for core > v2.5.0 or staging version
|
||||||
monitor_speed = ${common.monitor_speed}
|
monitor_speed = ${common.monitor_speed}
|
||||||
upload_speed = ${common.upload_speed}
|
upload_speed = ${common.upload_speed}
|
||||||
upload_resetmethod = ${common.upload_resetmethod}
|
upload_resetmethod = ${common.upload_resetmethod}
|
||||||
|
|||||||
Reference in New Issue
Block a user