@@ -149,16 +149,16 @@ WS2812FX * strip = NULL;
|
|||||||
#endif
|
#endif
|
||||||
#if USE_WS2812FX_DMA == 1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
#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)
|
#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
|
#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
|
||||||
#endif
|
#endif
|
||||||
#if USE_WS2812FX_DMA == 2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
#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)
|
#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
|
#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
|
||||||
#endif
|
#endif
|
||||||
dma->Initialize();
|
dma->Initialize();
|
||||||
@@ -240,7 +240,7 @@ void configModeCallback (WiFiManager *myWiFiManager) {
|
|||||||
//callback notifying us of the need to save config
|
//callback notifying us of the need to save config
|
||||||
void saveConfigCallback () {
|
void saveConfigCallback () {
|
||||||
DBG_OUTPUT_PORT.println("Should save config");
|
DBG_OUTPUT_PORT.println("Should save config");
|
||||||
shouldSaveConfig = true;
|
updateConfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -558,11 +558,11 @@ void setup() {
|
|||||||
strcpy(tmp_rgbOrder, custom_rgbOrder.getValue());
|
strcpy(tmp_rgbOrder, custom_rgbOrder.getValue());
|
||||||
checkRGBOrder(tmp_rgbOrder);
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
WS2812FXStripSettings.fxoptions = atoi(custom_fxoptions.getValue());
|
WS2812FXStripSettings.fxoptions = atoi(custom_fxoptions.getValue());
|
||||||
|
if (updateConfig) {
|
||||||
#if ENABLE_STATE_SAVE == 1
|
#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!");
|
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#if ENABLE_STATE_SAVE == 0
|
||||||
if (shouldSaveConfig) {
|
|
||||||
char last_conf[223];
|
char last_conf[223];
|
||||||
DBG_OUTPUT_PORT.println("Saving WiFiManager config");
|
DBG_OUTPUT_PORT.println("Saving WiFiManager config");
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
@@ -573,9 +573,9 @@ void setup() {
|
|||||||
last_conf[sizeof(last_conf)] = 0x00;
|
last_conf[sizeof(last_conf)] = 0x00;
|
||||||
writeEEPROM(0, 222, last_conf);
|
writeEEPROM(0, 222, last_conf);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
shouldSaveConfig = false;
|
updateConfig = false;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//if you get here you have connected to the WiFi
|
//if you get here you have connected to the WiFi
|
||||||
@@ -869,7 +869,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prevmode != mode) {
|
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 defined(ENABLE_STATE_SAVE)
|
||||||
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
|
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
|
||||||
#endif
|
#endif
|
||||||
@@ -891,7 +891,7 @@ void loop() {
|
|||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
if (updateState){
|
if (updateState){
|
||||||
#if ENABLE_STATE_SAVE == 1
|
#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
|
#endif
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#if ENABLE_STATE_SAVE == 0
|
||||||
writeEEPROM(384, 66, last_state); // 384 --> last_state (reserved 66 bytes)
|
writeEEPROM(384, 66, last_state); // 384 --> last_state (reserved 66 bytes)
|
||||||
@@ -900,9 +900,9 @@ void loop() {
|
|||||||
settings_save_state.detach();
|
settings_save_state.detach();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (shouldSaveConfig) {
|
if (updateConfig) {
|
||||||
#if ENABLE_STATE_SAVE == 1
|
#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
|
#endif
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#if ENABLE_STATE_SAVE == 0
|
||||||
char last_conf[223];
|
char last_conf[223];
|
||||||
@@ -914,7 +914,7 @@ void loop() {
|
|||||||
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;
|
updateConfig = false;
|
||||||
settings_save_conf.detach();
|
settings_save_conf.detach();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
// 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.
|
||||||
@@ -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
|
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
|
||||||
#endif
|
#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!"
|
#error "Definition of USE_WS2812FX_DMA is wrong!"
|
||||||
#endif
|
#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 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 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
|
char last_state[67]; // Keeps the state representation before auto or off mode
|
||||||
bool updateState = false;
|
bool updateState = false;
|
||||||
|
|
||||||
|
|||||||
@@ -301,14 +301,16 @@ void handleRangeDifferentColors(uint8_t * mypayload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool checkPin(uint8_t pin) {
|
bool checkPin(uint8_t pin) {
|
||||||
|
#if defined(USE_WS2812FX_DMA)
|
||||||
#if USE_WS2812FX_DMA == 0
|
#if USE_WS2812FX_DMA == 0
|
||||||
pin = 3;
|
pin = 3;
|
||||||
#endif
|
#endif
|
||||||
#if USE_WS2812FX_DMA == 1
|
#if USE_WS2812FX_DMA == 1
|
||||||
pin = 2;
|
pin = 1;
|
||||||
#endif
|
#endif
|
||||||
#if USE_WS2812FX_DMA == 2
|
#if USE_WS2812FX_DMA == 2
|
||||||
pin = 1;
|
pin = 2;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (((pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 16)) && (pin != WS2812FXStripSettings.pin)) {
|
if (((pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 16)) && (pin != WS2812FXStripSettings.pin)) {
|
||||||
WS2812FXStripSettings.pin = pin;
|
WS2812FXStripSettings.pin = pin;
|
||||||
@@ -878,7 +880,6 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
tmp_pin[2] = 0x00;
|
tmp_pin[2] = 0x00;
|
||||||
checkPin(atoi(tmp_pin));
|
checkPin(atoi(tmp_pin));
|
||||||
updateStrip = true;
|
updateStrip = true;
|
||||||
updateConf = true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (payload[2] == 'o') {
|
if (payload[2] == 'o') {
|
||||||
@@ -945,6 +946,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
}
|
}
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
if (updateStrip || updateConf) {
|
if (updateStrip || updateConf) {
|
||||||
|
DBG_OUTPUT_PORT.println("Saving config.json!");
|
||||||
if(!settings_save_conf.active()) settings_save_conf.once(3, tickerSaveConfig);
|
if(!settings_save_conf.active()) settings_save_conf.once(3, tickerSaveConfig);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1629,7 +1631,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tickerSaveConfig(){
|
void tickerSaveConfig(){
|
||||||
shouldSaveConfig = true;
|
updateConfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#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
|
//FS save
|
||||||
DBG_OUTPUT_PORT.println("Saving config: ");
|
DBG_OUTPUT_PORT.println("Saving config: ");
|
||||||
File configFile = SPIFFS.open("/config.json", "w");
|
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());
|
DBG_OUTPUT_PORT.println(listConfigJSON());
|
||||||
configFile.print(listConfigJSON());
|
configFile.print(listConfigJSON());
|
||||||
configFile.close();
|
configFile.close();
|
||||||
shouldSaveConfig = false;
|
settings_save_conf.detach();
|
||||||
|
updateConfig = false;
|
||||||
return true;
|
return true;
|
||||||
//end save
|
//end save
|
||||||
} else {
|
} else {
|
||||||
@@ -1740,7 +1748,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
bool writeStateFS(bool saveConfig){
|
bool writeStateFS(bool saveConfig){
|
||||||
if (saveConfig) {
|
if (saveConfig) {
|
||||||
//save the strip state to FS JSON
|
//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");
|
//SPIFFS.remove("/stripstate.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
|
||||||
File configFile = SPIFFS.open("/stripstate.json", "w");
|
File configFile = SPIFFS.open("/stripstate.json", "w");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
|
|||||||
@@ -293,13 +293,13 @@
|
|||||||
tmp_rgbOrder[sizeof(tmp_rgbOrder) - 1] = 0x00;
|
tmp_rgbOrder[sizeof(tmp_rgbOrder) - 1] = 0x00;
|
||||||
checkRGBOrder(tmp_rgbOrder);
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
updateStrip = true;
|
updateStrip = true;
|
||||||
updateConf = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(USE_WS2812FX_DMA)
|
#if !defined(USE_WS2812FX_DMA)
|
||||||
if(server.hasArg("ws_pin")){
|
if(server.hasArg("ws_pin")){
|
||||||
if (checkPin(server.arg("ws_pin").toInt())) {
|
if (checkPin(server.arg("ws_pin").toInt())) {
|
||||||
updateStrip = true;
|
updateStrip = true;
|
||||||
|
DBG_OUTPUT_PORT.print("Pin was set to: ");
|
||||||
DBG_OUTPUT_PORT.println(WS2812FXStripSettings.pin);
|
DBG_OUTPUT_PORT.println(WS2812FXStripSettings.pin);
|
||||||
} else {
|
} else {
|
||||||
DBG_OUTPUT_PORT.println("invalid input!");
|
DBG_OUTPUT_PORT.println("invalid input!");
|
||||||
@@ -371,6 +371,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/all", []() {
|
server.on("/all", []() {
|
||||||
|
prevmode = HOLD;
|
||||||
ws2812fx_mode = FX_MODE_STATIC;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
mode = SET_ALL;
|
mode = SET_ALL;
|
||||||
getArgs();
|
getArgs();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define SKETCH_VERSION "2.2.5.RU1.rgbw.3c"
|
#define SKETCH_VERSION "2.2.6.RU1.rgbw.3c"
|
||||||
|
|||||||
@@ -158,4 +158,11 @@
|
|||||||
* adressed issue: #27
|
* adressed issue: #27
|
||||||
* adressed issue: #28 (see new REST-API documentation)
|
* 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
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user