3 Commits

Author SHA1 Message Date
bpohvoodoo 9e4a52b0d1 Merge pull request #71 from FabLab-Luenen/development
Version Bump to 3.1.0
2020-02-26 12:29:19 +01:00
bpohvoodoo 2a24f3567d Merge pull request #68 from FabLab-Luenen/development
Update to 3.1.0.BETA7
2020-02-02 16:09:29 +01:00
bpohvoodoo f01a340e25 Merge pull request #64 from FabLab-Luenen/development
Development
2020-01-19 11:16:45 +01:00
8 changed files with 286 additions and 377 deletions
+28 -8
View File
@@ -271,11 +271,9 @@ void initMqtt() {
mqtt_intopic[sizeof(mqtt_intopic) - 1] = 0x00; mqtt_intopic[sizeof(mqtt_intopic) - 1] = 0x00;
snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", mqtt_clientid); snprintf(mqtt_outtopic, sizeof(mqtt_outtopic), "%s/out", mqtt_clientid);
mqtt_outtopic[sizeof(mqtt_outtopic) - 1] = 0x00; mqtt_outtopic[sizeof(mqtt_outtopic) - 1] = 0x00;
#if defined(ENABLE_HOMEASSISTANT) #if defined(MQTT_HOME_ASSISTANT_SUPPORT)
#if defined(MQTT_HOMEASSISTANT_SUPPORT) snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", mqtt_clientid);
snprintf(mqtt_ha_config, sizeof(mqtt_ha_config), "homeassistant/light/%s/config", mqtt_clientid); mqtt_ha_config[sizeof(mqtt_ha_config) - 1] = 0x00;
mqtt_ha_config[sizeof(mqtt_ha_config) - 1] = 0x00;
#endif
snprintf(mqtt_ha_state_in, sizeof(mqtt_ha_state_in), "home/%s_ha/state/in", mqtt_clientid); snprintf(mqtt_ha_state_in, sizeof(mqtt_ha_state_in), "home/%s_ha/state/in", mqtt_clientid);
mqtt_ha_state_in[sizeof(mqtt_ha_state_in) - 1] = 0x00; 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", mqtt_clientid); snprintf(mqtt_ha_state_out, sizeof(mqtt_ha_state_out), "home/%s_ha/state/out", mqtt_clientid);
@@ -657,6 +655,9 @@ void loop() {
if (State.mode == OFF) { if (State.mode == OFF) {
if (prevmode != State.mode) { if (prevmode != State.mode) {
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =off", "");
#endif
#if defined(POWER_SUPPLY) #if defined(POWER_SUPPLY)
digitalWrite(POWER_SUPPLY, !POWER_ON); // power off -> external power supply digitalWrite(POWER_SUPPLY, !POWER_ON); // power off -> external power supply
#endif #endif
@@ -673,9 +674,19 @@ void loop() {
if (State.mode == SET) { if (State.mode == SET) {
State.mode = HOLD; State.mode = HOLD;
// Segment
if (prevsegment != State.segment) {
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK Ss%i", State.segment);
#endif
//prevsegment = State.segment;
}
// Mode // Mode
if ((segState.mode[State.segment] != fx_mode) || prevmode == OFF) { if (segState.mode[State.segment] != fx_mode) {
segState.mode[State.segment] = fx_mode; segState.mode[State.segment] = fx_mode;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", segState.mode[State.segment]);
#endif
strip->strip_off(); strip->strip_off();
autoCount[State.segment] = 0; autoCount[State.segment] = 0;
autoDelay[State.segment] = 0; autoDelay[State.segment] = 0;
@@ -690,10 +701,13 @@ void loop() {
}*/ }*/
// Brightness // Brightness
if (strip->getBrightness() != State.brightness) { if (strip->getBrightness() != State.brightness) {
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", State.brightness);
#endif
brightness_trans = State.brightness; brightness_trans = State.brightness;
} }
// Speed // Speed
if (fx_speed != segState.speed[prevsegment]) { if (fx_speed != segState.speed[State.segment]) {
#if defined(ENABLE_MQTT) #if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK ?%i", segState.speed[prevsegment]); snprintf(mqtt_buf, sizeof(mqtt_buf), "OK ?%i", segState.speed[prevsegment]);
#endif #endif
@@ -725,9 +739,15 @@ void loop() {
} }
//strip->setBrightness(brightness_actual); //strip->setBrightness(brightness_actual);
#if defined(ENABLE_MQTT) #if defined(ENABLE_MQTT)
#if ENABLE_MQTT == 0
mqtt_client->publish(mqtt_outtopic, mqtt_buf);
#endif
#if ENABLE_MQTT == 1
mqtt_client->publish(mqtt_outtopic, qospub, false, mqtt_buf);
#endif
#if defined(ENABLE_HOMEASSISTANT) #if defined(ENABLE_HOMEASSISTANT)
if(ha_send_data.active()) ha_send_data.detach(); if(ha_send_data.active()) ha_send_data.detach();
ha_send_data.once(DELAY_MQTT_HA_MESSAGE, tickerSendState); ha_send_data.once(5, tickerSendState);
#endif #endif
#endif #endif
} }
+1 -1
View File
@@ -2693,4 +2693,4 @@ document.addEventListener("DOMContentLoaded", function(event) {
}); });
</script> </script>
</body> </body>
</html> </html>
+236 -236
View File
@@ -1,236 +1,236 @@
#define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to TX/GPIO1; 2 = Used PIN is ignored & set to D4/GPIO2; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX #define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to TX/GPIO1; 2 = Used PIN is ignored & set to D4/GPIO2; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
// or comment it out // or comment it out
#if defined(USE_WS2812FX_DMA) #if defined(USE_WS2812FX_DMA)
#define MAXLEDS 384 // due to memory limit of esp8266 at the moment only 384 leds are supported in DMA Mode. More can crash if mqtt is used. #define MAXLEDS 384 // due to memory limit of esp8266 at the moment only 384 leds are supported in DMA Mode. More can crash if mqtt is used.
#else #else
#define MAXLEDS 4096 #define MAXLEDS 4096
#endif #endif
// Neopixel // Neopixel
#define LED_PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached; is configurable, if USE_WS2812FX_DMA is not defined. Just for the start #define LED_PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached; is configurable, if USE_WS2812FX_DMA is not defined. Just for the start
#define NUMLEDS 50 // Number of leds in the; is configurable just for the start #define NUMLEDS 50 // Number of leds in the; is configurable just for the start
#define RGBORDER "GRBW" // RGBOrder; is configurable just for the start #define RGBORDER "GRBW" // RGBOrder; is configurable just for the start
#define FX_OPTIONS 48 // ws2812fx Options 48 = SIZE_SMALL + FADE_MEDIUM is configurable just for the start; for WS2812FX setSegment OPTIONS, see: https://github.com/kitesurfer1404/WS2812FX/blob/master/extras/WS2812FX%20Users%20Guide.md #define FX_OPTIONS 48 // ws2812fx Options 48 = SIZE_SMALL + FADE_MEDIUM is configurable just for the start; for WS2812FX setSegment OPTIONS, see: https://github.com/kitesurfer1404/WS2812FX/blob/master/extras/WS2812FX%20Users%20Guide.md
//#define LED_TYPE_WS2811 // Uncomment, if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) //#define LED_TYPE_WS2811 // Uncomment, if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192 #define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just for the start. Hostname should not contain spaces as this can break Home Assistant discovery if used. char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just for the start. Hostname should not contain spaces as this can break Home Assistant discovery if used.
#define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code. #define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code.
#define ENABLE_MQTT 1 // If defined use MQTT OR AMQTT, if set to 0 enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API, if set to 1, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client #define ENABLE_MQTT 1 // If defined use MQTT OR AMQTT, if set to 0 enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API, if set to 1, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname //#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
//#define ENABLE_MQTT_INCLUDE_IP // uncomment/comment to add the IP-adress to the MQTT message //#define ENABLE_MQTT_INCLUDE_IP // uncomment/comment to add the IP-adress to the MQTT message
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active #define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
#define MQTT_HOMEASSISTANT_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 DELAY_MQTT_HA_MESSAGE 5 // HA Status is send after DELAY_MQTT_HA_MESSAGE seconds, to save bandwith //#define DISABLE_MQTT_OUT_ON_MQTT_IN // If defined, McLighting will not send back MQTT-out on MQTT-in regarding issue #67, does not change anything at the moment
//#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button. //#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
//#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button. //#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
//#define POWER_SUPPLY 12 // PIN (12 / D6) If defined, enable output to control external power supply //#define POWER_SUPPLY 12 // PIN (12 / D6) If defined, enable output to control external power supply
#if defined(POWER_SUPPLY) #if defined(POWER_SUPPLY)
#define POWER_ON HIGH // Define the output state to turn on the power supply, either HIGH or LOW. Opposite will be uses for power off. #define POWER_ON HIGH // Define the output state to turn on the power supply, either HIGH or LOW. Opposite will be uses for power off.
#endif #endif
//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out #define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
#if defined(ENABLE_BUTTON_GY33) #if defined(ENABLE_BUTTON_GY33)
#define GAMMA 2.5 // Gamma correction for GY-33 sensor #define GAMMA 2.5 // Gamma correction for GY-33 sensor
#endif #endif
#define ENABLE_STATE_SAVE // If defined, load saved state on reboot and save state on SPIFFS #define ENABLE_STATE_SAVE // If defined, load saved state on reboot and save state on SPIFFS
#define CUSTOM_WS2812FX_ANIMATIONS // uncomment and put animations in "custom_ws2812fx_animations.h" #define CUSTOM_WS2812FX_ANIMATIONS // uncomment and put animations in "custom_ws2812fx_animations.h"
#define USE_HTML_MIN_GZ // uncomment for using index.htm & edit.htm from PROGMEM instead of SPIFFS #define USE_HTML_MIN_GZ // uncomment for using index.htm & edit.htm from PROGMEM instead of SPIFFS
#define TRANS_COLOR_DELAY 5 // Delay for color transition #define TRANS_COLOR_DELAY 5 // Delay for color transition
#define TRANS_DELAY 10 // Delay for brightness and speed transition #define TRANS_DELAY 10 // Delay for brightness and speed transition
// Experimental: Enable transitions of color, brightness and speed. It does not work properly for all effects. // Experimental: Enable transitions of color, brightness and speed. It does not work properly for all effects.
bool transEffectOverride = false; bool transEffectOverride = false;
uint8_t trans_cnt = 0; uint8_t trans_cnt = 0;
int trans_cnt_max = 0; int trans_cnt_max = 0;
unsigned long colorFadeDelay = 0; unsigned long colorFadeDelay = 0;
unsigned long brightnessFadeDelay = 0; unsigned long brightnessFadeDelay = 0;
unsigned long speedFadeDelay = 0; unsigned long speedFadeDelay = 0;
#if defined(CUSTOM_WS2812FX_ANIMATIONS) #if defined(CUSTOM_WS2812FX_ANIMATIONS)
#define MULTICAST false #define MULTICAST false
#define START_UNIVERSE 1 // First DMX Universe to listen for #define START_UNIVERSE 1 // First DMX Universe to listen for
uint8_t END_UNIVERSE = START_UNIVERSE; // Total number of Universes to listen for, starting at UNIVERSE uint8_t END_UNIVERSE = START_UNIVERSE; // Total number of Universes to listen for, starting at UNIVERSE
#endif #endif
uint8_t prevsegment = 0; uint8_t prevsegment = 0;
#if defined(ENABLE_REMOTE) #if defined(ENABLE_REMOTE)
uint8_t selected_color = 1; uint8_t selected_color = 1;
uint64_t last_remote_cmd; uint64_t last_remote_cmd;
enum RMT_BTN {ON_OFF, MODE_UP, MODE_DOWN, RED_UP, RED_DOWN, GREEN_UP, GREEN_DOWN, BLUE_UP, BLUE_DOWN, WHITE_UP, WHITE_DOWN, BRIGHTNESS_UP, BRIGHTNESS_DOWN, SPEED_UP, SPEED_DOWN, COL_M, COL_B, COL_X, AUTOMODE, CUST_1, CUST_2, CUST_3, SEG_UP, SEG_DOWN, REPEATCMD, BTN_CNT}; enum RMT_BTN {ON_OFF, MODE_UP, MODE_DOWN, RED_UP, RED_DOWN, GREEN_UP, GREEN_DOWN, BLUE_UP, BLUE_DOWN, WHITE_UP, WHITE_DOWN, BRIGHTNESS_UP, BRIGHTNESS_DOWN, SPEED_UP, SPEED_DOWN, COL_M, COL_B, COL_X, AUTOMODE, CUST_1, CUST_2, CUST_3, SEG_UP, SEG_DOWN, REPEATCMD, BTN_CNT};
// Change your IR Commands here. You can see them in console, after you pressed a button on the remote // Change your IR Commands here. You can see them in console, after you pressed a button on the remote
uint64_t rmt_commands[BTN_CNT] = {0xF7C03F, 0xF7708F, 0xF7F00F, 0xF720DF, 0xF710EF, 0xF7A05F, 0xF7906F, 0xF7609F, 0xF750AF, 0xF7E01F, 0xF7D02F, 0xF730CF, 0xF7B04F, 0xF748B7, 0xF7C837, 0xF700FF, 0xF7807F, 0xF740BF, 0xF708F7, 0xF78877, 0xF728D7, 0xF7A857, 0xF76897, 0xF7E817, 0xFFFFFFFFFFFFFFFF}; uint64_t rmt_commands[BTN_CNT] = {0xF7C03F, 0xF7708F, 0xF7F00F, 0xF720DF, 0xF710EF, 0xF7A05F, 0xF7906F, 0xF7609F, 0xF750AF, 0xF7E01F, 0xF7D02F, 0xF730CF, 0xF7B04F, 0xF748B7, 0xF7C837, 0xF700FF, 0xF7807F, 0xF740BF, 0xF708F7, 0xF78877, 0xF728D7, 0xF7A857, 0xF76897, 0xF7E817, 0xFFFFFFFFFFFFFFFF};
#endif #endif
#define WIFIMGR_PORTAL_TIMEOUT 180 #define WIFIMGR_PORTAL_TIMEOUT 180
//#define WIFIMGR_SET_MANUAL_IP //#define WIFIMGR_SET_MANUAL_IP
#if defined(WIFIMGR_SET_MANUAL_IP) #if defined(WIFIMGR_SET_MANUAL_IP)
uint8_t _ip[4] = {192,168,0,128}; uint8_t _ip[4] = {192,168,0,128};
uint8_t _gw[4] = {192,168,0,1}; uint8_t _gw[4] = {192,168,0,1};
uint8_t _sn[4] = {255,255,255,0}; uint8_t _sn[4] = {255,255,255,0};
#endif #endif
#if defined(MQTT_HOMEASSISTANT_SUPPORT) #if defined(MQTT_HOME_ASSISTANT_SUPPORT)
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87 #define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif #endif
#if defined(USE_WS2812FX_DMA) && (USE_WS2812FX_DMA < 0 || USE_WS2812FX_DMA > 2) #if defined(USE_WS2812FX_DMA) && (USE_WS2812FX_DMA < 0 || USE_WS2812FX_DMA > 2)
#error "Definition of USE_WS2812FX_DMA is wrong!" #error "Definition of USE_WS2812FX_DMA is wrong!"
#endif #endif
#if defined(ENABLE_MQTT) and ENABLE_MQTT < 0 and ENABLE_MQTT > 1 #if defined(ENABLE_MQTT) and ENABLE_MQTT < 0 and ENABLE_MQTT > 1
#error "Definition of ENABLE_MQTT is wrong!" #error "Definition of ENABLE_MQTT is wrong!"
#endif #endif
#if defined(ENABLE_MQTT) and ENABLE_MQTT < 0 and ENABLE_MQTT > 1 #if defined(ENABLE_MQTT) and ENABLE_MQTT < 0 and ENABLE_MQTT > 1
#error "Definition of ENABLE_MQTT is wrong!" #error "Definition of ENABLE_MQTT is wrong!"
#endif #endif
#if defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT) #if defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT)
#error "To use HA, you have to either enable PubCubClient or AsyncMQTT" #error "To use HA, you have to either enable PubCubClient or AsyncMQTT"
#endif #endif
#if !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOMEASSISTANT_SUPPORT) #if !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOME_ASSISTANT_SUPPORT)
#error "To use HA support, you have to either enable Homeassistant component" #error "To use HA support, you have to either enable Homeassistant component"
#endif #endif
// parameters for automatically cycling favorite patterns // parameters for automatically cycling favorite patterns
uint32_t autoParams[][6] = { // main_color, back_color, xtra_color, speed, mode, duration (milliseconds) uint32_t autoParams[][6] = { // main_color, back_color, xtra_color, speed, mode, duration (milliseconds)
{0x00ff0000, 0x0000ff00, 0x00000000, 200, 1, 5000}, // blink red/geen for 5 seconds {0x00ff0000, 0x0000ff00, 0x00000000, 200, 1, 5000}, // blink red/geen for 5 seconds
{0x0000ff00, 0x000000ff, 0x00000000, 180, 3, 10000}, // wipe green/blue for 10 seconds {0x0000ff00, 0x000000ff, 0x00000000, 180, 3, 10000}, // wipe green/blue for 10 seconds
{0x000000ff, 0x00ff0000, 0x00000000, 100, 14, 10000}, // dual scan blue on red for 10 seconds {0x000000ff, 0x00ff0000, 0x00000000, 100, 14, 10000}, // dual scan blue on red for 10 seconds
{0x000000ff, 0x00ff0000, 0x00000000, 100, 45, 15000}, // fireworks blue/red for 15 seconds {0x000000ff, 0x00ff0000, 0x00000000, 100, 45, 15000}, // fireworks blue/red for 15 seconds
{0x00ff0000, 0x0000ff00, 0x000000ff, 40, 54, 15000} // tricolor chase red/green/blue for 15 seconds {0x00ff0000, 0x0000ff00, 0x000000ff, 40, 54, 15000} // tricolor chase red/green/blue for 15 seconds
}; };
#if defined(ENABLE_MQTT) #if defined(ENABLE_MQTT)
char mqtt_buf[80]; char mqtt_buf[80];
char mqtt_will_topic[sizeof(HOSTNAME) + 7]; // Topic 'will' will be:HOSTNAME "/status"; char mqtt_will_topic[sizeof(HOSTNAME) + 7]; // Topic 'will' will be:HOSTNAME "/status";
const char mqtt_will_payload[] = "OFFLINE"; const char mqtt_will_payload[] = "OFFLINE";
char mqtt_intopic[sizeof(HOSTNAME) + 3]; // Topic 'in' will be: <HOSTNAME>/in char mqtt_intopic[sizeof(HOSTNAME) + 3]; // Topic 'in' will be: <HOSTNAME>/in
char mqtt_outtopic[sizeof(HOSTNAME) + 4]; // Topic 'out' will be: <HOSTNAME>/out char mqtt_outtopic[sizeof(HOSTNAME) + 4]; // Topic 'out' will be: <HOSTNAME>/out
bool mqtt_lwt_boot_flag = true; bool mqtt_lwt_boot_flag = true;
#if ENABLE_MQTT == 0 #if ENABLE_MQTT == 0
#define MQTT_MAX_PACKET_SIZE 512 #define MQTT_MAX_PACKET_SIZE 512
#define MQTT_MAX_RECONNECT_TRIES 4 #define MQTT_MAX_RECONNECT_TRIES 4
uint8_t mqtt_reconnect_retries = 0; uint8_t mqtt_reconnect_retries = 0;
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1 uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
#endif #endif
#if ENABLE_MQTT == 1 #if ENABLE_MQTT == 1
uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2 uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2 uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
#endif #endif
#if defined(ENABLE_HOMEASSISTANT) #if defined(ENABLE_HOMEASSISTANT)
char mqtt_ha_config[20 + sizeof(HOSTNAME) + 7]; // Topic config will be: "homeassistant/light/<HOSTNAME>/config" char mqtt_ha_config[20 + sizeof(HOSTNAME) + 7]; // Topic config will be: "homeassistant/light/<HOSTNAME>/config"
char mqtt_ha_state_in[5 + sizeof(HOSTNAME) + 12]; // Topic in will be: "home/<HOSTNAME>_ha/state/in" char mqtt_ha_state_in[5 + sizeof(HOSTNAME) + 12]; // Topic in will be: "home/<HOSTNAME>_ha/state/in"
char mqtt_ha_state_out[5 + sizeof(HOSTNAME) + 13]; // Topic in will be: "home/<HOSTNAME>_ha/state/out" char mqtt_ha_state_out[5 + sizeof(HOSTNAME) + 13]; // Topic in will be: "home/<HOSTNAME>_ha/state/out"
const char* on_cmd = "ON"; const char* on_cmd = "ON";
const char* off_cmd = "OFF"; const char* off_cmd = "OFF";
bool new_ha_mqtt_msg = false; bool new_ha_mqtt_msg = false;
uint16_t color_temp = 327; // min is 154 and max is 500 uint16_t color_temp = 327; // min is 154 and max is 500
#endif #endif
char mqtt_clientid[sizeof(HOSTNAME) + 9]; char mqtt_clientid[sizeof(HOSTNAME) + 9];
char mqtt_host[65] = ""; //is configurable just for the start char mqtt_host[65] = ""; //is configurable just for the start
uint16_t mqtt_port = 1883; //is configurable just for the start uint16_t mqtt_port = 1883; //is configurable just for the start
char mqtt_user[33] = ""; //is configurable just for the start char mqtt_user[33] = ""; //is configurable just for the start
char mqtt_pass[33] = ""; //is configurable just for the start char mqtt_pass[33] = ""; //is configurable just for the start
#endif #endif
// *************************************************************************** // ***************************************************************************
// Global variables / definitions // Global variables / definitions
// *************************************************************************** // ***************************************************************************
#define DBG_OUTPUT_PORT Serial // Set debug output port #define DBG_OUTPUT_PORT Serial // Set debug output port
uint8_t autoCount[10] = {}; // Global variable for storing the counter for automated playback for each segment uint8_t autoCount[10] = {}; // Global variable for storing the counter for automated playback for each segment
unsigned long autoDelay[10] = {}; // Global variable for storing the time to next auto effect for each segment unsigned long autoDelay[10] = {}; // Global variable for storing the time to next auto effect for each segment
struct { struct {
uint16_t start = 0; uint16_t start = 0;
uint16_t stop = NUMLEDS - 1; uint16_t stop = NUMLEDS - 1;
uint8_t mode[10] = {}; // Global variable for storing the WS2812FX mode to set for each segment uint8_t mode[10] = {}; // Global variable for storing the WS2812FX mode to set for each segment
uint8_t speed[10] = {}; // Global variable for storing the speed for effects --> smaller == slower uint8_t speed[10] = {}; // Global variable for storing the speed for effects --> smaller == slower
uint32_t colors[10][3] = {}; // 2 dim. Color array for setting colors of WS2812FX uint32_t colors[10][3] = {}; // 2 dim. Color array for setting colors of WS2812FX
uint8_t options = FX_OPTIONS; uint8_t options = FX_OPTIONS;
} segState; } segState;
// List of all color modes // List of all color modes
enum MODE {OFF, HOLD, SET}; enum MODE {OFF, HOLD, SET};
MODE prevmode = HOLD; // Do not change MODE prevmode = HOLD; // Do not change
struct { struct {
uint8_t segment = 0; // Actual selected segment uint8_t segment = 0; // Actual selected segment
MODE mode = SET; // Standard mode that is active when software starts MODE mode = SET; // Standard mode that is active when software starts
uint8_t brightness = 196; // Global variable for storing the brightness (255 == 100%) uint8_t brightness = 196; // Global variable for storing the brightness (255 == 100%)
} State; } State;
struct { struct {
uint8_t segments = 1; uint8_t segments = 1;
uint16_t stripSize = NUMLEDS; uint16_t stripSize = NUMLEDS;
char RGBOrder[5] = RGBORDER; char RGBOrder[5] = RGBORDER;
#if defined(USE_WS2812FX_DMA) #if defined(USE_WS2812FX_DMA)
#if USE_WS2812FX_DMA == 0 #if USE_WS2812FX_DMA == 0
uint8_t pin = 3; uint8_t pin = 3;
#endif #endif
#if USE_WS2812FX_DMA == 1 #if USE_WS2812FX_DMA == 1
uint8_t pin = 1; uint8_t pin = 2;
#endif #endif
#if USE_WS2812FX_DMA == 2 #if USE_WS2812FX_DMA == 2
uint8_t pin = 2; uint8_t pin = 1;
#endif #endif
#else #else
uint8_t pin = LED_PIN; uint8_t pin = LED_PIN;
#endif #endif
bool transEffect = false; bool transEffect = false;
} Config; } Config;
uint8_t fx_speed = 196; // Global variable for storing the speed for effects while fading --> smaller == slower uint8_t fx_speed = 196; // Global variable for storing the speed for effects while fading --> smaller == slower
uint8_t fx_mode = 0; uint8_t fx_mode = 0;
uint8_t brightness_trans = 0; // Global variable for storing the brightness before change uint8_t brightness_trans = 0; // Global variable for storing the brightness before change
uint32_t hexcolors_trans[3] = {}; // Color array of colors of WS2812FX before fading uint32_t hexcolors_trans[3] = {}; // Color array of colors of WS2812FX before fading
struct ledstate // Data structure to store a state of a single led struct ledstate // Data structure to store a state of a single led
{ {
uint8_t red; uint8_t red;
uint8_t green; uint8_t green;
uint8_t blue; uint8_t blue;
uint8_t white; uint8_t white;
}; };
typedef struct ledstate LEDState; // Define the datatype LEDState typedef struct ledstate LEDState; // Define the datatype LEDState
uint8_t* ledstates; // Set a pointer to get an array of led states to store the state of the whole strip uint8_t* ledstates; // Set a pointer to get an array of led states to store the state of the whole strip
LEDState main_color = { 255, 0, 0, 0 }; // Store the "main color" of the strip used in single color modes LEDState main_color = { 255, 0, 0, 0 }; // Store the "main color" of the strip used in single color modes
LEDState back_color = { 0, 0, 0, 0 }; // Store the "2nd color" of the strip used in single color modes LEDState back_color = { 0, 0, 0, 0 }; // Store the "2nd color" of the strip used in single color modes
LEDState xtra_color = { 0, 0, 0, 0 }; // Store the "3rd color" of the strip used in single color modes LEDState xtra_color = { 0, 0, 0, 0 }; // Store the "3rd color" of the strip used in single color modes
bool updateConfig = false; // For WiFiManger custom config and config bool updateConfig = false; // For WiFiManger custom config and config
// Button handling // Button handling
#if defined(ENABLE_BUTTON) || defined(ENABLE_BUTTON_GY33) #if defined(ENABLE_BUTTON) || defined(ENABLE_BUTTON_GY33)
const unsigned long keySampleIntervalMs = 25; const unsigned long keySampleIntervalMs = 25;
#endif #endif
#if defined(ENABLE_BUTTON) #if defined(ENABLE_BUTTON)
//#define BTN_MODE_SHORT "STA|mo|fxm| s| b| r1| g1| b1| w1| r2| g2| b2| w2| r3| g3| b3| w3" // Example //#define BTN_MODE_SHORT "STA|mo|fxm| s| b| r1| g1| b1| w1| r2| g2| b2| w2| r3| g3| b3| w3" // Example
#define BTN_MODE_SHORT "STA| 5| 0|196|255| 0| 0| 0|255| 0| 0| 0| 0| 0| 0| 0| 0" // Static white #define BTN_MODE_SHORT "STA| 5| 0|196|255| 0| 0| 0|255| 0| 0| 0| 0| 0| 0| 0| 0" // Static white
#define BTN_MODE_MEDIUM "STA| 5| 48|196|200|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fire flicker #define BTN_MODE_MEDIUM "STA| 5| 48|196|200|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fire flicker
#define BTN_MODE_LONG "STA| 5| 46|196|200|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fireworks random #define BTN_MODE_LONG "STA| 5| 46|196|200|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fireworks random
unsigned long keyPrevMillis = 0; unsigned long keyPrevMillis = 0;
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms
byte KeyPressCount = 0; byte KeyPressCount = 0;
byte prevKeyState = HIGH; // button is active low byte prevKeyState = HIGH; // button is active low
#endif #endif
#if defined(ENABLE_BUTTON_GY33) #if defined(ENABLE_BUTTON_GY33)
unsigned long keyPrevMillis_gy33 = 0; unsigned long keyPrevMillis_gy33 = 0;
byte longKeyPressCountMax_gy33 = 80; // 80 * 25 = 2000 ms byte longKeyPressCountMax_gy33 = 80; // 80 * 25 = 2000 ms
byte mediumKeyPressCountMin_gy33 = 20; // 20 * 25 = 500 ms byte mediumKeyPressCountMin_gy33 = 20; // 20 * 25 = 500 ms
byte KeyPressCount_gy33 = 0; byte KeyPressCount_gy33 = 0;
byte prevKeyState_gy33 = HIGH; // button is active low byte prevKeyState_gy33 = HIGH; // button is active low
#endif #endif
-12
View File
@@ -321,15 +321,3 @@ uint32_t trans(uint32_t _newcolor, uint32_t _oldcolor, uint8_t _level, uint8_t _
_oldcolor = scale_wrgb(_oldcolor, 255-_level); _oldcolor = scale_wrgb(_oldcolor, 255-_level);
return _newcolor + _oldcolor; return _newcolor + _oldcolor;
} }
#if defined(ENABLE_MQTT)
void sendmqtt() {
#if ENABLE_MQTT == 0
mqtt_client->publish(mqtt_outtopic, mqtt_buf);
#endif
#if ENABLE_MQTT == 1
mqtt_client->publish(mqtt_outtopic, qospub, false, mqtt_buf);
#endif
memset(mqtt_buf,0,sizeof(mqtt_buf));
}
#endif
+18 -62
View File
@@ -199,25 +199,9 @@ void handleSetWS2812FXMode(uint8_t * mypayload) {
fx_mode = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10); fx_mode = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
fx_mode = constrain(fx_mode, 0, strip->getModeCount() - 1); fx_mode = constrain(fx_mode, 0, strip->getModeCount() - 1);
State.mode = SET; State.mode = SET;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", fx_mode);
sendmqtt();
#endif
} else { } else {
if (strcmp((char *) &mypayload[1], "off") == 0) { if (strcmp((char *) &mypayload[1], "off") == 0) {
if (State.mode == OFF) { if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; };
State.mode = SET;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", segState.mode[State.segment]);
sendmqtt();
#endif
} else {
State.mode = OFF;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /off", "");
sendmqtt();
#endif
}
} }
if (strcmp((char *) &mypayload[1], "on") == 0) { if (strcmp((char *) &mypayload[1], "on") == 0) {
State.mode = SET; State.mode = SET;
@@ -292,11 +276,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
//memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans)); //memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans));
_updateState = true; _updateState = true;
Dbg_Prefix(mqtt, num); Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set segment to: [%u]\r\n", _seg); DBG_OUTPUT_PORT.printf("Set segment to: [%u]\r\n", State.segment);
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK Ss%i", _seg);
sendmqtt();
#endif
} }
} }
// / ==> Set segment first LED // / ==> Set segment first LED
@@ -309,10 +289,6 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
setSegmentSize(); setSegmentSize();
Dbg_Prefix(mqtt, num); Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set segment start to: [%u]\r\n", _seg_start); DBG_OUTPUT_PORT.printf("Set segment start to: [%u]\r\n", _seg_start);
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK S[%i", _seg_start);
sendmqtt();
#endif
} }
} }
// / ==> Set segment last LED // / ==> Set segment last LED
@@ -325,25 +301,18 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
setSegmentSize(); setSegmentSize();
Dbg_Prefix(mqtt, num); Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set segment stop to: [%u]\r\n", _seg_stop); DBG_OUTPUT_PORT.printf("Set segment stop to: [%u]\r\n", _seg_stop);
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK S]%i", _seg_stop);
sendmqtt();
#endif
} }
} }
if (_payload[1] == 'o') { if (_payload[1] == 'o') {
uint8_t _fx_options = (uint8_t) strtol((const char *) &_payload[2], NULL, 10); char _fx_options[4];
_fx_options = ((constrain(server.arg("fxopt").toInt(), 0, 255)>>1)<<1); snprintf(_fx_options, sizeof(_fx_options), "%s", &_payload[2]);
if (_fx_options != segState.options) { _fx_options[3] = 0x00;
segState.options= _fx_options; if (((constrain(atoi(_fx_options), 0, 255)>>1)<<1) != segState.options) {
segState.options= ((constrain(atoi(_fx_options), 0, 255)>>1)<<1);
_updateSegState = true; _updateSegState = true;
strip->setOptions(State.segment, segState.options); strip->setOptions(State.segment, segState.options);
Dbg_Prefix(mqtt, num); Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set segment options to: [%u]\r\n", _fx_options); DBG_OUTPUT_PORT.printf("Set segment options to: [%u]\r\n", segState.options);
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK So%i", _fx_options);
sendmqtt();
#endif
} }
} }
char * buffer = listSegmentStateJSON(State.segment); char * buffer = listSegmentStateJSON(State.segment);
@@ -404,16 +373,11 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
// ? ==> Set speed // ? ==> Set speed
if (_payload[0] == '?') { if (_payload[0] == '?') {
uint16_t _fx_speed = (uint16_t) strtol((const char *) &_payload[1], NULL, 10); uint16_t _fx_speed = (uint16_t) strtol((const char *) &_payload[1], NULL, 10);
_fx_speed = constrain(_fx_speed, SPEED_MIN, SPEED_MAX ); segState.speed[State.segment] = constrain(_fx_speed, SPEED_MIN, SPEED_MAX );
//if (segState.speed[State.segment] != _fx_speed) {} State.mode = SET;
segState.speed[State.segment] = _fx_speed;
_updateSegState = true; _updateSegState = true;
Dbg_Prefix(mqtt, num); Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set speed to: [%u]\r\n", _fx_speed); DBG_OUTPUT_PORT.printf("Set speed to: [%u]\r\n", segState.speed[State.segment]);
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK ?%i", _fx_speed);
sendmqtt();
#endif
} }
// % ==> Set brightness // % ==> Set brightness
@@ -421,13 +385,10 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
uint8_t b = (uint8_t) strtol((const char *) &_payload[1], NULL, 10); uint8_t b = (uint8_t) strtol((const char *) &_payload[1], NULL, 10);
State.brightness = constrain(b, 0, 255); State.brightness = constrain(b, 0, 255);
if (strip->getBrightness() != State.brightness) { if (strip->getBrightness() != State.brightness) {
State.mode = SET;
Dbg_Prefix(mqtt, num); Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set brightness to: [%u]\r\n", State.brightness); DBG_OUTPUT_PORT.printf("Set brightness to: [%u]\r\n", State.brightness);
_updateState = true; _updateState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", State.brightness);
sendmqtt();
#endif
} }
} }
@@ -471,7 +432,6 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
} }
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if (_updateState) { if (_updateState) {
State.mode = SET;
if(save_state.active()) save_state.detach(); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState); save_state.once(3, tickerSaveState);
} }
@@ -783,15 +743,11 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
root["effect"] = strip->getModeName(strip->getMode()); root["effect"] = strip->getModeName(strip->getMode());
} }
#endif #endif
uint16_t msg_len = measureJson(root) + 1; char buffer[measureJson(root) + 1];
char buffer[msg_len];
serializeJson(root, buffer, sizeof(buffer)); serializeJson(root, buffer, sizeof(buffer));
jsonBuffer.clear(); jsonBuffer.clear();
#if ENABLE_MQTT == 0 #if ENABLE_MQTT == 0
//mqtt_client->publish(mqtt_ha_state_out, buffer, true); mqtt_client->publish(mqtt_ha_state_out, buffer, true);
mqtt_client->beginPublish(mqtt_ha_state_out, msg_len-1, true);
mqtt_client->write((const uint8_t*)buffer, msg_len-1);
mqtt_client->endPublish();
DBG_OUTPUT_PORT.printf("MQTT: Send [%s]: %s\r\n", mqtt_ha_state_out, buffer); DBG_OUTPUT_PORT.printf("MQTT: Send [%s]: %s\r\n", mqtt_ha_state_out, buffer);
#endif #endif
#if ENABLE_MQTT == 1 #if ENABLE_MQTT == 1
@@ -945,7 +901,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
return; return;
} }
if(ha_send_data.active()) ha_send_data.detach(); if(ha_send_data.active()) ha_send_data.detach();
ha_send_data.once(DELAY_MQTT_HA_MESSAGE, tickerSendState); ha_send_data.once(5, tickerSendState);
} else if (strcmp(topic, mqtt_intopic) == 0) { } else if (strcmp(topic, mqtt_intopic) == 0) {
#endif #endif
@@ -980,8 +936,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
#if defined(ENABLE_HOMEASSISTANT) #if defined(ENABLE_HOMEASSISTANT)
ha_send_data.detach(); ha_send_data.detach();
mqtt_client->subscribe(mqtt_ha_state_in, qossub); mqtt_client->subscribe(mqtt_ha_state_in, qossub);
ha_send_data.once(DELAY_MQTT_HA_MESSAGE, tickerSendState); ha_send_data.once(5, tickerSendState);
#if defined(MQTT_HOMEASSISTANT_SUPPORT) #if defined(MQTT_HOME_ASSISTANT_SUPPORT)
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500; const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
DynamicJsonDocument jsonBuffer(bufferSize); DynamicJsonDocument jsonBuffer(bufferSize);
JsonObject root = jsonBuffer.to<JsonObject>(); JsonObject root = jsonBuffer.to<JsonObject>();
@@ -1087,7 +1043,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
ha_send_data.detach(); ha_send_data.detach();
uint16_t packetIdSub2 = mqtt_client->subscribe((char *)mqtt_ha_state_in, qossub); uint16_t packetIdSub2 = mqtt_client->subscribe((char *)mqtt_ha_state_in, qossub);
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2); DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
#if defined(MQTT_HOMEASSISTANT_SUPPORT) #if defined(MQTT_HOME_ASSISTANT_SUPPORT)
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500; const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+ 4) + JSON_OBJECT_SIZE(11) + 1500;
DynamicJsonDocument jsonBuffer(bufferSize); DynamicJsonDocument jsonBuffer(bufferSize);
JsonObject root = jsonBuffer.to<JsonObject>(); JsonObject root = jsonBuffer.to<JsonObject>();
+2 -48
View File
@@ -319,19 +319,7 @@ server.on("/config", []() {
}); });
server.on("/off", []() { server.on("/off", []() {
if (State.mode == OFF) { if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; };
State.mode = SET;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", segState.mode[State.segment]);
sendmqtt();
#endif
} else {
State.mode = OFF;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /off", "");
sendmqtt();
#endif
}
getACK("OK"); getACK("OK");
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if(save_state.active()) save_state.detach(); if(save_state.active()) save_state.detach();
@@ -342,10 +330,6 @@ server.on("/off", []() {
server.on("/on", []() { server.on("/on", []() {
if (prevmode == OFF) { if (prevmode == OFF) {
State.mode = SET; State.mode = SET;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", segState.mode[State.segment]);
sendmqtt();
#endif
getACK("OK"); getACK("OK");
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if(save_state.active()) save_state.detach(); if(save_state.active()) save_state.detach();
@@ -370,10 +354,6 @@ server.on("/set", []() {
//memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans)); //memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans));
State.mode = SET; State.mode = SET;
_updateState = true; _updateState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK Ss%i", _seg);
sendmqtt();
#endif
} }
} }
if ((server.arg("start") != "") && (server.arg("start").toInt() >= 0) && (server.arg("start").toInt() <= segState.stop)) { if ((server.arg("start") != "") && (server.arg("start").toInt() >= 0) && (server.arg("start").toInt() <= segState.stop)) {
@@ -383,10 +363,6 @@ server.on("/set", []() {
segState.start = _seg_start; segState.start = _seg_start;
setSegmentSize(); setSegmentSize();
_updateSegState = true; _updateSegState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK S[%i", _seg_start);
sendmqtt();
#endif
} }
} }
if ((server.arg("stop") != "") && (server.arg("stop").toInt() >= segState.start) && (server.arg("stop").toInt() <= Config.stripSize)) { if ((server.arg("stop") != "") && (server.arg("stop").toInt() >= segState.start) && (server.arg("stop").toInt() <= Config.stripSize)) {
@@ -396,10 +372,6 @@ server.on("/set", []() {
segState.stop = _seg_stop; segState.stop = _seg_stop;
setSegmentSize(); setSegmentSize();
_updateSegState = true; _updateSegState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK S]%i", _seg_stop);
sendmqtt();
#endif
} }
} }
@@ -409,10 +381,6 @@ server.on("/set", []() {
segState.options = _fx_options; segState.options = _fx_options;
strip->setOptions(State.segment, segState.options); strip->setOptions(State.segment, segState.options);
_updateSegState = true; _updateSegState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK So%i", _fx_options);
sendmqtt();
#endif
} }
} }
//color wrgb //color wrgb
@@ -507,24 +475,14 @@ server.on("/set", []() {
// Speed // Speed
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) { if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
uint8_t _fx_speed = constrain(server.arg("s").toInt(), 0, 255); segState.speed[State.segment] = constrain(server.arg("s").toInt(), 0, 255);
segState.speed[State.segment] = _fx_speed;
_updateSegState = true; _updateSegState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK ?%i", _fx_speed);
sendmqtt();
#endif
} }
//Mode //Mode
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) { if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) {
fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1); fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
if (fx_mode != segState.mode[State.segment]) { if (fx_mode != segState.mode[State.segment]) {
_updateSegState = true; _updateSegState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", fx_mode);
sendmqtt();
#endif
} }
} }
@@ -537,10 +495,6 @@ server.on("/set", []() {
if (strip->getBrightness() != State.brightness) { if (strip->getBrightness() != State.brightness) {
State.mode = SET; State.mode = SET;
_updateState = true; _updateState = true;
#if defined(ENABLE_MQTT)
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", State.brightness);
sendmqtt();
#endif
} }
//DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull()); //possibly causing heap problems //DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull()); //possibly causing heap problems
getACK("OK"); getACK("OK");
+1 -1
View File
@@ -1 +1 @@
#define SKETCH_VERSION "3.1.2" #define SKETCH_VERSION "3.1.0"
-9
View File
@@ -257,13 +257,4 @@
* Version Bump to 3.1.0 * Version Bump to 3.1.0
* bugfixes * bugfixes
* E1.31 is now working for multi segments * E1.31 is now working for multi segments
*
* 18 April 2020
* Version Bump to 3.1.1
* bugfixes regarding issue #80
*
* 19 April 2020
* Version Bump to 3.1.2
* Almost finished: bugfixes regarding issue #80
* ToDo: bugfixes regarding issue #70
*/ */