Merge pull request #68 from FabLab-Luenen/development

Update to 3.1.0.BETA7
This commit is contained in:
bpohvoodoo
2020-02-02 16:09:29 +01:00
committed by GitHub
15 changed files with 1927 additions and 1869 deletions
+2 -1
View File
@@ -748,7 +748,8 @@ void loop() {
mqtt_client->publish(mqtt_outtopic, qospub, false, mqtt_buf); mqtt_client->publish(mqtt_outtopic, qospub, false, mqtt_buf);
#endif #endif
#if defined(ENABLE_HOMEASSISTANT) #if defined(ENABLE_HOMEASSISTANT)
if(!ha_send_data.active()) ha_send_data.once(3, tickerSendState); if(ha_send_data.active()) ha_send_data.detach();
ha_send_data.once(5, tickerSendState);
#endif #endif
#endif #endif
} }
+9 -9
View File
@@ -1038,23 +1038,23 @@ uint16_t WS2812FX::mode_sparkle(void) {
/* /*
* Lights all LEDs in the color. Flashes single white pixels randomly. * Lights all LEDs in the color. Flashes white pixels randomly.
* Inspired by www.tweaking4all.com/hardware/arduino/arduino-led-strip-effects/ * Inspired by www.tweaking4all.com/hardware/arduino/arduino-led-strip-effects/
*/ */
uint16_t WS2812FX::mode_flash_sparkle(void) { uint16_t WS2812FX::mode_flash_sparkle(void) {
if(SEGMENT_RUNTIME.counter_mode_call == 0) { for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) { setPixelColor(i, SEGMENT.colors[0]);
setPixelColor(i, SEGMENT.colors[0]);
}
} }
setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param3, SEGMENT.colors[0]);
if(random8(5) == 0) { if(random8(5) == 0) {
SEGMENT_RUNTIME.aux_param3 = random16(SEGMENT_LENGTH); // aux_param3 stores the random led index uint8_t size = 1 << SIZE_OPTION;
setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param3, WHITE); uint16_t index = SEGMENT.start + random16(SEGMENT_LENGTH - size);
for(uint8_t j=0; j<size; j++) {
setPixelColor(index + j, WHITE);
}
return 20; return 20;
} }
return SEGMENT.speed; return SEGMENT.speed;
} }
+5
View File
@@ -5,6 +5,11 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Wed, 01 Jan 2020 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" href="/apple-touch-icon.png">
<style> <style>
Binary file not shown.
+3 -2
View File
@@ -20,14 +20,15 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
//#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_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth #define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
//#define 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
+5
View File
@@ -2,6 +2,11 @@
bool readSegmentStateFS(uint8_t _seg); bool readSegmentStateFS(uint8_t _seg);
// End Prototypes // End Prototypes
void getACK(char *buffer) {
server.sendHeader("Access-Control-Allow-Origin", "*");
server.send(200, "text/plain", buffer );
}
// Call convertColors whenever main_color, back_color or xtra_color changes. // Call convertColors whenever main_color, back_color or xtra_color changes.
void convertColors() { void convertColors() {
hexcolors_trans[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue; hexcolors_trans[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue;
File diff suppressed because it is too large Load Diff
+19 -10
View File
@@ -432,11 +432,13 @@ 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) {
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
} }
if (_updateSegState) { if (_updateSegState) {
State.mode = SET; State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState); if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
} }
_updateState = false; _updateState = false;
@@ -547,10 +549,12 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
} }
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if (_updateStrip || _updateConfig) { if (_updateStrip || _updateConfig) {
if(!save_conf.active()) save_conf.once(3, tickerSaveConfig); if(save_conf.active()) save_conf.detach();
save_conf.once(3, tickerSaveConfig);
} }
if (_updateState) { if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
} }
#endif #endif
_updateStrip = false; _updateStrip = false;
@@ -863,11 +867,13 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
} }
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if (_updateState) { if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
} }
if (_updateSegState) { if (_updateSegState) {
State.mode = SET; State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState); if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
} }
#endif #endif
_updateState = false; _updateState = false;
@@ -894,8 +900,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
if (!processJson((char*)payload)) { if (!processJson((char*)payload)) {
return; return;
} }
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); if(ha_send_data.active()) ha_send_data.detach();
} else if (strcmp(topic, mqtt_intopic) == 0) { ha_send_data.once(5, tickerSendState);
} else if (strcmp(topic, mqtt_intopic) == 0) {
#endif #endif
checkpayload(payload, true); checkpayload(payload, true);
@@ -1514,11 +1521,13 @@ void handleRemote() {
} }
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if (_updateState) { if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
} }
if (_updateSegState) { if (_updateSegState) {
State.mode = SET; State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState); if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
} }
#endif #endif
_updateState = false; _updateState = false;
+32 -16
View File
@@ -136,17 +136,27 @@ server.on("/get_switch", []() {
}); });
server.on("/get_color", []() { server.on("/get_color", []() {
char rgbcolor[10]; char rgbcolor[7];
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", main_color.red, main_color.green, main_color.blue);
rgbcolor[sizeof(rgbcolor) - 1] = 0x00; 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: ");
DBG_OUTPUT_PORT.println(rgbcolor); DBG_OUTPUT_PORT.println(rgbcolor);
}); });
server.on("/get_color1", []() {
char rgbcolor[9];
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.send(200, "text/plain", rgbcolor );
DBG_OUTPUT_PORT.print("/get_color1: ");
DBG_OUTPUT_PORT.println(rgbcolor);
});
server.on("/get_color2", []() { server.on("/get_color2", []() {
char rgbcolor[10]; char rgbcolor[9];
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; rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
server.sendHeader("Access-Control-Allow-Origin", "*"); server.sendHeader("Access-Control-Allow-Origin", "*");
@@ -156,7 +166,7 @@ server.on("/get_color2", []() {
}); });
server.on("/get_color3", []() { server.on("/get_color3", []() {
char rgbcolor[10]; char rgbcolor[9];
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; rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
server.sendHeader("Access-Control-Allow-Origin", "*"); server.sendHeader("Access-Control-Allow-Origin", "*");
@@ -294,10 +304,12 @@ server.on("/config", []() {
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if (_updateStrip || _updateConfig) { if (_updateStrip || _updateConfig) {
if(!save_conf.active()) save_conf.once(3, tickerSaveConfig); if(save_conf.active()) save_conf.detach();
save_conf.once(3, tickerSaveConfig);
} }
if (_updateState) { if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
} }
#endif #endif
_updateStrip = false; _updateStrip = false;
@@ -308,21 +320,23 @@ server.on("/config", []() {
server.on("/off", []() { server.on("/off", []() {
if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; }; if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; };
getStateJSON(); getACK("OK");
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
#endif #endif
}); });
server.on("/on", []() { server.on("/on", []() {
if (prevmode == OFF) { if (prevmode == OFF) {
State.mode = SET; State.mode = SET;
getStateJSON(); getACK("OK");
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
#endif #endif
} else { } else {
getStateJSON(); getACK("NOK");
} }
}); });
@@ -482,16 +496,18 @@ server.on("/set", []() {
State.mode = SET; State.mode = SET;
_updateState = true; _updateState = true;
} }
DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull()); //DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull()); //possibly causing heap problems
getStateJSON(); getACK("OK");
#if defined(ENABLE_STATE_SAVE) #if defined(ENABLE_STATE_SAVE)
if (_updateState) { if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState); if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
} }
if (_updateSegState) { if (_updateSegState) {
State.mode = SET; State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState); if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
} }
#endif #endif
_updateState = false; _updateState = false;
+3
View File
@@ -70,6 +70,9 @@ bool handleFileRead(String path) {
path += ".gz"; path += ".gz";
File file = SPIFFS.open(path, "r"); File file = SPIFFS.open(path, "r");
server.sendHeader("Access-Control-Allow-Origin", "*"); server.sendHeader("Access-Control-Allow-Origin", "*");
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
server.sendHeader("Expires", "-1");
size_t sent = server.streamFile(file, contentType); size_t sent = server.streamFile(file, contentType);
file.close(); file.close();
return true; return true;
+1 -1
View File
@@ -1 +1 @@
#define SKETCH_VERSION "3.1.0.BETA6" #define SKETCH_VERSION "3.1.0.BETA7"
+5
View File
@@ -247,4 +247,9 @@
* known problems: * known problems:
* Homeassistant will allways use active segment * Homeassistant will allways use active segment
* E1.31 is only working for one segment at the moment * E1.31 is only working for one segment at the moment
*
* 27 January
* Version Bump to 3.1.0.BETA7
* small API changes
* work to solve heap problems
*/ */
+2 -2
View File
@@ -16,7 +16,7 @@
"switch": { "switch": {
"status": "http://<ESP_HOST>/get_switch", "status": "http://<ESP_HOST>/get_switch",
"powerOn": "http://<ESP_HOST>/all?r=255&g=255&b=255", "powerOn": "http://<ESP_HOST>/on",
"powerOff": "http://<ESP_HOST>/off" "powerOff": "http://<ESP_HOST>/off"
}, },
@@ -27,7 +27,7 @@
"color": { "color": {
"status": "http://<ESP_HOST>/get_color", "status": "http://<ESP_HOST>/get_color",
"url": "http://<ESP_HOST>/set?m=0?rgb=%s", "url": "http://<ESP_HOST>/set?m=0?rgb=00%s",
"brightness": true "brightness": true
} }
} }
+5
View File
@@ -5,6 +5,11 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Wed, 01 Jan 2020 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" href="/apple-touch-icon.png">
<style> <style>
Binary file not shown.