Merge pull request #35 from FabLab-Luenen/development

Update to 2.2.6
This commit is contained in:
bpohvoodoo
2019-09-10 17:24:55 +02:00
committed by GitHub
6 changed files with 49 additions and 33 deletions
+18 -18
View File
@@ -149,16 +149,16 @@ WS2812FX * strip = NULL;
#endif
#if USE_WS2812FX_DMA == 1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
dma = new NeoEsp8266Uart1800KbpsMethod(stripSize, ledcolors); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
dma = new NeoEsp8266Uart0800KbpsMethod(stripSize, ledcolors); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
dma = new NeoEsp8266Uart1400KbpsMethod(stripSize, ledcolors); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
dma = new NeoEsp8266Uart0400KbpsMethod(stripSize, ledcolors); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
#if USE_WS2812FX_DMA == 2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
dma = new NeoEsp8266Uart0800KbpsMethod(stripSize, ledcolors); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
dma = new NeoEsp8266Uart1800KbpsMethod(stripSize, ledcolors); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
dma = new NeoEsp8266Uart0400KbpsMethod(stripSize, ledcolors); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
dma = new NeoEsp8266Uart1400KbpsMethod(stripSize, ledcolors); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
dma->Initialize();
@@ -240,7 +240,7 @@ void configModeCallback (WiFiManager *myWiFiManager) {
//callback notifying us of the need to save config
void saveConfigCallback () {
DBG_OUTPUT_PORT.println("Should save config");
shouldSaveConfig = true;
updateConfig = true;
}
// ***************************************************************************
@@ -558,11 +558,11 @@ void setup() {
strcpy(tmp_rgbOrder, custom_rgbOrder.getValue());
checkRGBOrder(tmp_rgbOrder);
WS2812FXStripSettings.fxoptions = atoi(custom_fxoptions.getValue());
#if ENABLE_STATE_SAVE == 1
(writeConfigFS(shouldSaveConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
#endif
#if ENABLE_STATE_SAVE == 0
if (shouldSaveConfig) {
if (updateConfig) {
#if ENABLE_STATE_SAVE == 1
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
#endif
#if ENABLE_STATE_SAVE == 0
char last_conf[223];
DBG_OUTPUT_PORT.println("Saving WiFiManager config");
#if defined(ENABLE_MQTT)
@@ -573,9 +573,9 @@ void setup() {
last_conf[sizeof(last_conf)] = 0x00;
writeEEPROM(0, 222, last_conf);
EEPROM.commit();
shouldSaveConfig = false;
}
#endif
updateConfig = false;
#endif
}
#endif
//if you get here you have connected to the WiFi
@@ -869,7 +869,7 @@ void loop() {
}
if (prevmode != mode) {
if (prevmode != AUTO) { // do not save if AUTO Mode was set
if ((prevmode != AUTO) && (prevmode != INIT_STRIP)) { // do not save if AUTO Mode was set
#if defined(ENABLE_STATE_SAVE)
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
#endif
@@ -891,7 +891,7 @@ void loop() {
#if defined(ENABLE_STATE_SAVE)
if (updateState){
#if ENABLE_STATE_SAVE == 1
(writeStateFS(true)) ? DBG_OUTPUT_PORT.println(" Success!") : DBG_OUTPUT_PORT.println(" Failure!");
(writeStateFS(updateState)) ? DBG_OUTPUT_PORT.println(" State FS Save Success!") : DBG_OUTPUT_PORT.println("State FS Save failure!");
#endif
#if ENABLE_STATE_SAVE == 0
writeEEPROM(384, 66, last_state); // 384 --> last_state (reserved 66 bytes)
@@ -900,9 +900,9 @@ void loop() {
settings_save_state.detach();
#endif
}
if (shouldSaveConfig) {
if (updateConfig) {
#if ENABLE_STATE_SAVE == 1
(writeConfigFS(true)) ? DBG_OUTPUT_PORT.println("Config FS Save success!"): DBG_OUTPUT_PORT.println("Config FS Save failure!");
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("Config FS Save success!"): DBG_OUTPUT_PORT.println("Config FS Save failure!");
#endif
#if ENABLE_STATE_SAVE == 0
char last_conf[223];
@@ -914,7 +914,7 @@ void loop() {
last_conf[sizeof(last_conf) - 1] = 0x00;
writeEEPROM(0, 222, last_conf);
EEPROM.commit();
shouldSaveConfig = false;
updateConfig = false;
settings_save_conf.detach();
#endif
}
+3 -3
View File
@@ -1,4 +1,4 @@
#define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to D4/GPIO2; 2 = Uses PIN is ignored & set to TX/GPIO1; 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 = Uses PIN is ignored & set to D4/GPIO2; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
// or comment it out
#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.
@@ -62,7 +62,7 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif
#if defined(USE_WS2812FX_DMA) and USE_WS2812FX_DMA < 0 and 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!"
#endif
@@ -160,7 +160,7 @@ LEDState main_color = { 255, 0, 0, 0 }; // Store the "main color" of the strip
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
bool shouldSaveConfig = false; // For WiFiManger custom config and config
bool updateConfig = false; // For WiFiManger custom config and config
char last_state[67]; // Keeps the state representation before auto or off mode
bool updateState = false;
+17 -9
View File
@@ -301,15 +301,17 @@ void handleRangeDifferentColors(uint8_t * mypayload) {
}
bool checkPin(uint8_t pin) {
#if defined(USE_WS2812FX_DMA)
#if USE_WS2812FX_DMA == 0
pin = 3;
#endif
#if USE_WS2812FX_DMA == 1
pin = 2;
#endif
#if USE_WS2812FX_DMA == 2
pin = 1;
#endif
#if USE_WS2812FX_DMA == 2
pin = 2;
#endif
#endif
if (((pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 16)) && (pin != WS2812FXStripSettings.pin)) {
WS2812FXStripSettings.pin = pin;
return true;
@@ -878,7 +880,6 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
tmp_pin[2] = 0x00;
checkPin(atoi(tmp_pin));
updateStrip = true;
updateConf = true;
}
#endif
if (payload[2] == 'o') {
@@ -942,9 +943,10 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
DBG_OUTPUT_PORT.print("WS: ");
webSocket.sendTXT(num, "OK");
webSocket.sendTXT(num, buffer);
}
}
#if defined(ENABLE_STATE_SAVE)
if (updateStrip || updateConf) {
DBG_OUTPUT_PORT.println("Saving config.json!");
if(!settings_save_conf.active()) settings_save_conf.once(3, tickerSaveConfig);
}
#endif
@@ -1629,7 +1631,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
}
void tickerSaveConfig(){
shouldSaveConfig = true;
updateConfig = true;
}
#if ENABLE_STATE_SAVE == 0
@@ -1666,11 +1668,17 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
//FS save
DBG_OUTPUT_PORT.println("Saving config: ");
File configFile = SPIFFS.open("/config.json", "w");
if (!configFile) DBG_OUTPUT_PORT.println("failed to open config file for writing");
if (!configFile) {
DBG_OUTPUT_PORT.println("Failed!");
settings_save_conf.detach();
updateConfig = false;
return false;
}
DBG_OUTPUT_PORT.println(listConfigJSON());
configFile.print(listConfigJSON());
configFile.close();
shouldSaveConfig = false;
settings_save_conf.detach();
updateConfig = false;
return true;
//end save
} else {
@@ -1740,7 +1748,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
bool writeStateFS(bool saveConfig){
if (saveConfig) {
//save the strip state to FS JSON
DBG_OUTPUT_PORT.print("Saving cfg: ");
DBG_OUTPUT_PORT.print("Saving state: ");
//SPIFFS.remove("/stripstate.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
File configFile = SPIFFS.open("/stripstate.json", "w");
if (!configFile) {
+3 -2
View File
@@ -284,7 +284,7 @@
uint16_t pixelCt = server.arg("ws_cnt").toInt();
if (pixelCt > 0) {
WS2812FXStripSettings.stripSize = constrain(pixelCt, 1, MAXLEDS);
updateStrip = true;
updateStrip = true;
}
}
if(server.hasArg("ws_rgbo")){
@@ -293,13 +293,13 @@
tmp_rgbOrder[sizeof(tmp_rgbOrder) - 1] = 0x00;
checkRGBOrder(tmp_rgbOrder);
updateStrip = true;
updateConf = true;
}
#if !defined(USE_WS2812FX_DMA)
if(server.hasArg("ws_pin")){
if (checkPin(server.arg("ws_pin").toInt())) {
updateStrip = true;
DBG_OUTPUT_PORT.print("Pin was set to: ");
DBG_OUTPUT_PORT.println(WS2812FXStripSettings.pin);
} else {
DBG_OUTPUT_PORT.println("invalid input!");
@@ -371,6 +371,7 @@
});
server.on("/all", []() {
prevmode = HOLD;
ws2812fx_mode = FX_MODE_STATIC;
mode = SET_ALL;
getArgs();
+1 -1
View File
@@ -1 +1 @@
#define SKETCH_VERSION "2.2.5.RU1.rgbw.3c"
#define SKETCH_VERSION "2.2.6.RU1.rgbw.3c"
+7
View File
@@ -158,4 +158,11 @@
* adressed issue: #27
* adressed issue: #28 (see new REST-API documentation)
*
* 10 September 2019
* Version Bump to 2.2.6 rgbw 3colors
* adressed issue: #28 (see new REST-API documentation) again
* adressed issue: #26
* adressed issue: #31
* adressed issue: #32
*
*/