diff --git a/README.md b/README.md index 1c1b625dc..6b30d05d0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## Sonoff-Tasmota Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE. -Current version is **5.12.0e** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. +Current version is **5.12.0f** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. ### ATTENTION All versions diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index d7ebcf426..97fb87e7f 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,7 @@ -/* 5.12.0e +/* 5.12.0f + * Add compile time support for WS2812 BRG and RBG led configurations to be defined in user_config.h (#1690) + * + * 5.12.0e * Add Domoticz dust (custom) sensors to PMS5003 and NovaFitness SDS drivers as PM1, PM2.5 and PM10 * Add a second TLS fingerprint to allow switching keys in TLS mode (#2033, #2102) * Add display of remaining pulse time to command PulseTime (#2085) diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 503ebfb86..cc2d1c955 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -509,7 +509,7 @@ void SettingsDefaultSet2() // Settings.domoticz_switch_idx[i] = 0; } - Settings.energy_power_delta = 80; + Settings.energy_power_delta = DEFAULT_POWER_DELTA; Settings.energy_power_calibration = HLW_PREF_PULSE; Settings.energy_voltage_calibration = HLW_UREF_PULSE; Settings.energy_current_calibration = HLW_IREF_PULSE; @@ -890,7 +890,7 @@ void SettingsDelta() } if (Settings.version < 0x050C0005) { Settings.light_rotation = 0; - Settings.energy_power_delta = 80; + Settings.energy_power_delta = DEFAULT_POWER_DELTA; char fingerprint[60]; memcpy(fingerprint, Settings.mqtt_fingerprint, sizeof(fingerprint)); char *p = fingerprint; diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index c90b31550..fa3649ad1 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -107,6 +107,19 @@ typedef unsigned long power_t; // Power (Relay) type #define max(a,b) ((a)>(b)?(a):(b)) */ +//enum ws2812NeopixelbusFeature { NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_3LED, NEO_RGBW, NEO_GRBW }; // Doesn't work +#define NEO_RGB 0 // Neopixel RGB leds +#define NEO_GRB 1 // Neopixel GRB leds +#define NEO_BRG 2 // Neopixel BRG leds +#define NEO_RBG 3 // Neopixel RBG leds +#define NEO_3LED 4 // Placeholder to test for 4 led types +#define NEO_RGBW 5 // Neopixel RGBW leds +#define NEO_GRBW 6 // Neopixel GRBW leds + +#define MQTT_PUBSUBCLIENT 1 // Mqtt PubSubClient library +#define MQTT_TASMOTAMQTT 2 // Mqtt TasmotaMqtt library based on esp-mqtt-arduino +#define MQTT_ESPMQTTARDUINO 3 // Mqtt esp-mqtt-arduino library by Ingo Randolf + /*********************************************************************************************\ * Enumeration \*********************************************************************************************/ diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 3edbeac23..e4a8c0b2a 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -25,7 +25,7 @@ - Select IDE Tools - Flash Size: "1M (no SPIFFS)" ====================================================*/ -#define VERSION 0x050C0005 // 5.12.0e +#define VERSION 0x050C0006 // 5.12.0f // Location specific includes #include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) diff --git a/sonoff/sonoff_post.h b/sonoff/sonoff_post.h index b6ab9e999..026cc9465 100644 --- a/sonoff/sonoff_post.h +++ b/sonoff/sonoff_post.h @@ -68,7 +68,7 @@ void WifiWpsStatusCallback(wps_cb_status status); #define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram) #define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by // #ifndef USE_WS2812_CTYPE - #define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB, 2 - RGBW, 3 - GRBW) + #define USE_WS2812_CTYPE NEO_GRB // WS2812 Color type (NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_RGBW, NEO_GRBW) #endif // #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial RXD) (+1k mem). When USE_WS2812_DMA is enabled expect Exceptions on Pow #define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0)) diff --git a/sonoff/user_config.h b/sonoff/user_config.h index 92a8c160f..caf686d6b 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -78,11 +78,11 @@ * Select ONE of possible MQTT library types below \*********************************************************************************************/ // Default MQTT driver for both non-TLS and TLS connections. Blocks network if MQTT server is unavailable. -#define MQTT_LIBRARY_TYPE 1 // Use PubSubClient library +#define MQTT_LIBRARY_TYPE MQTT_PUBSUBCLIENT // Use PubSubClient library // Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support -//#define MQTT_LIBRARY_TYPE 2 // Use TasmotaMqtt library (+4k4 code, +4k mem) - non-TLS only +//#define MQTT_LIBRARY_TYPE MQTT_TASMOTAMQTT // Use TasmotaMqtt library (+4k4 code, +4k mem) - non-TLS only // Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support -//#define MQTT_LIBRARY_TYPE 3 // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only +//#define MQTT_LIBRARY_TYPE MQTT_ESPMQTTARDUINO // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only // -- MQTT ---------------------------------------- #define MQTT_USE 1 // [SetOption3] Select default MQTT use (0 = Off, 1 = On) @@ -227,7 +227,7 @@ #define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram) #define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by // - #define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB, 2 - RGBW, 3 - GRBW) + #define USE_WS2812_CTYPE NEO_GRB // WS2812 Color type (NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_RGBW, NEO_GRBW) // #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial RXD) (+1k mem). When USE_WS2812_DMA is enabled expect Exceptions on Pow #define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0)) diff --git a/sonoff/xdrv_00_mqtt.ino b/sonoff/xdrv_00_mqtt.ino index 9f89eb259..6a87f1f25 100644 --- a/sonoff/xdrv_00_mqtt.ino +++ b/sonoff/xdrv_00_mqtt.ino @@ -18,23 +18,23 @@ */ /*********************************************************************************************\ - * Select ONE of possible MQTT libraries below + * Select ONE of possible MQTT library types below \*********************************************************************************************/ // Default MQTT driver for both non-TLS and TLS connections. Blocks network if MQTT server is unavailable. -//#define MQTT_LIBRARY_TYPE 1 // Use PubSubClient library +//#define MQTT_LIBRARY_TYPE MQTT_PUBSUBCLIENT // Use PubSubClient library // Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support -//#define MQTT_LIBRARY_TYPE 2 // Use TasmotaMqtt library (+4k4 code, +4k mem) - non-TLS only +//#define MQTT_LIBRARY_TYPE MQTT_TASMOTAMQTT // Use TasmotaMqtt library (+4k4 code, +4k mem) - non-TLS only // Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support -//#define MQTT_LIBRARY_TYPE 3 // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only +//#define MQTT_LIBRARY_TYPE MQTT_ESPMQTTARDUINO // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only #ifdef USE_MQTT_TLS #ifdef MQTT_LIBRARY_TYPE #undef MQTT_LIBRARY_TYPE #endif -#define MQTT_LIBRARY_TYPE 1 // Use PubSubClient library as it only supports TLS +#define MQTT_LIBRARY_TYPE MQTT_PUBSUBCLIENT // Use PubSubClient library as it only supports TLS #else #ifndef MQTT_LIBRARY_TYPE -#define MQTT_LIBRARY_TYPE 1 // Use PubSubClient library as default +#define MQTT_LIBRARY_TYPE MQTT_PUBSUBCLIENT // Use PubSubClient library as default #endif #endif @@ -63,7 +63,7 @@ bool mqtt_connected = false; // MQTT virtual connection status * void MqttLoop() \*********************************************************************************************/ -#if (1 == MQTT_LIBRARY_TYPE) /*****************************************************************/ +#if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT) /***********************************************/ #include @@ -100,7 +100,7 @@ void MqttLoop() MqttClient.loop(); } -#elif (2 == MQTT_LIBRARY_TYPE) /*****************************************************************/ +#elif (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) /**********************************************/ #include TasmotaMqtt MqttClient; @@ -134,7 +134,7 @@ void MqttLoop() { } -#elif (3 == MQTT_LIBRARY_TYPE) /***************************************************************/ +#elif (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) /*******************************************/ #include MQTT *MqttClient = NULL; @@ -450,14 +450,14 @@ void MqttReconnect() if (!MqttCheckTls()) return; #endif // USE_MQTT_TLS -#if (2 == MQTT_LIBRARY_TYPE) +#if (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) MqttClient.InitConnection(Settings.mqtt_host, Settings.mqtt_port); MqttClient.InitClient(mqtt_client, mqtt_user, mqtt_pwd, MQTT_KEEPALIVE); MqttClient.InitLWT(stopic, mqtt_data, 1, true); MqttClient.OnConnected(MqttConnected); MqttClient.OnDisconnected(MqttDisconnectedCb); MqttClient.OnData(MqttDataHandler); -#elif (3 == MQTT_LIBRARY_TYPE) +#elif (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) MqttClient = new MQTT(mqtt_client, Settings.mqtt_host, Settings.mqtt_port, stopic, 1, true, mqtt_data); MqttClient->setUserPwd(mqtt_user, mqtt_pwd); MqttClient->onConnected(MqttConnected); @@ -468,7 +468,7 @@ void MqttReconnect() mqtt_initial_connection_state = 1; } -#if (1 == MQTT_LIBRARY_TYPE) +#if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT) MqttClient.setCallback(MqttDataHandler); MqttClient.setServer(Settings.mqtt_host, Settings.mqtt_port); if (MqttClient.connect(mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, true, mqtt_data)) { @@ -476,9 +476,9 @@ void MqttReconnect() } else { MqttDisconnected(MqttClient.state()); // status codes are documented here http://pubsubclient.knolleary.net/api.html#state } -#elif (2 == MQTT_LIBRARY_TYPE) +#elif (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) MqttClient.Connect(); -#elif (3 == MQTT_LIBRARY_TYPE) +#elif (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) MqttClient->connect(); #endif // MQTT_LIBRARY_TYPE } diff --git a/sonoff/xdrv_01_light.ino b/sonoff/xdrv_01_light.ino index 6bcf20bea..f5f6184c7 100644 --- a/sonoff/xdrv_01_light.ino +++ b/sonoff/xdrv_01_light.ino @@ -376,7 +376,7 @@ void LightInit() } #ifdef USE_WS2812 // ************************************************************************ else if (LT_WS2812 == light_type) { -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) light_subtype++; // from RGB to RGBW #endif Ws2812Init(); diff --git a/sonoff/xplg_ws2812.ino b/sonoff/xplg_ws2812.ino index 42aafb8f3..4d6410f90 100644 --- a/sonoff/xplg_ws2812.ino +++ b/sonoff/xplg_ws2812.ino @@ -25,21 +25,29 @@ #include #ifdef USE_WS2812_DMA -#if (USE_WS2812_CTYPE == 1) +#if (USE_WS2812_CTYPE == NEO_GRB) NeoPixelBus *strip = NULL; -#elif (USE_WS2812_CTYPE == 2) +#elif (USE_WS2812_CTYPE == NEO_BRG) + NeoPixelBus *strip = NULL; +#elif (USE_WS2812_CTYPE == NEO_RBG) + NeoPixelBus *strip = NULL; +#elif (USE_WS2812_CTYPE == NEO_RGBW) NeoPixelBus *strip = NULL; -#elif (USE_WS2812_CTYPE == 3) +#elif (USE_WS2812_CTYPE == NEO_GRBW) NeoPixelBus *strip = NULL; #else // USE_WS2812_CTYPE NeoPixelBus *strip = NULL; #endif // USE_WS2812_CTYPE #else // USE_WS2812_DMA -#if (USE_WS2812_CTYPE == 1) +#if (USE_WS2812_CTYPE == NEO_GRB) NeoPixelBus *strip = NULL; -#elif (USE_WS2812_CTYPE == 2) +#elif (USE_WS2812_CTYPE == NEO_BRG) + NeoPixelBus *strip = NULL; +#elif (USE_WS2812_CTYPE == NEO_RBG) + NeoPixelBus *strip = NULL; +#elif (USE_WS2812_CTYPE == NEO_RGBW) NeoPixelBus *strip = NULL; -#elif (USE_WS2812_CTYPE == 3) +#elif (USE_WS2812_CTYPE == NEO_GRBW) NeoPixelBus *strip = NULL; #else // USE_WS2812_CTYPE NeoPixelBus *strip = NULL; @@ -90,7 +98,7 @@ uint8_t ws_show_next = 1; void Ws2812StripShow() { -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) RgbwColor c; #else RgbColor c; @@ -102,7 +110,7 @@ void Ws2812StripShow() c.R = ledTable[c.R]; c.G = ledTable[c.G]; c.B = ledTable[c.B]; -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) c.W = ledTable[c.W]; #endif strip->SetPixelColor(i, c); @@ -122,7 +130,7 @@ int mod(int a, int b) void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, float offset) { -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) RgbwColor color; #else RgbColor color; @@ -205,7 +213,7 @@ void Ws2812Gradient(uint8_t schemenr) * Display a gradient of colors for the current color scheme. * Repeat is the number of repetitions of the gradient (pick a multiple of 2 for smooth looping of the gradient). */ -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) RgbwColor c; c.W = 0; #else @@ -253,7 +261,7 @@ void Ws2812Bars(uint8_t schemenr) * Display solid bars of color for the current color scheme. * Width is the width of each bar in pixels/lights. */ -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) RgbwColor c; c.W = 0; #else @@ -298,21 +306,29 @@ void Ws2812Bars(uint8_t schemenr) void Ws2812Init() { #ifdef USE_WS2812_DMA -#if (USE_WS2812_CTYPE == 1) +#if (USE_WS2812_CTYPE == NEO_GRB) strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. -#elif (USE_WS2812_CTYPE == 2) +#elif (USE_WS2812_CTYPE == NEO_BRG) + strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. +#elif (USE_WS2812_CTYPE == NEO_RBG) + strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. +#elif (USE_WS2812_CTYPE == NEO_RGBW) strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. -#elif (USE_WS2812_CTYPE == 3) +#elif (USE_WS2812_CTYPE == NEO_GRBW) strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. #else // USE_WS2812_CTYPE strip = new NeoPixelBus(WS2812_MAX_LEDS); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. #endif // USE_WS2812_CTYPE #else // USE_WS2812_DMA -#if (USE_WS2812_CTYPE == 1) +#if (USE_WS2812_CTYPE == NEO_GRB) strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); -#elif (USE_WS2812_CTYPE == 2) +#elif (USE_WS2812_CTYPE == NEO_BRG) + strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); +#elif (USE_WS2812_CTYPE == NEO_RBG) + strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); +#elif (USE_WS2812_CTYPE == NEO_RGBW) strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); -#elif (USE_WS2812_CTYPE == 3) +#elif (USE_WS2812_CTYPE == NEO_GRBW) strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); #else // USE_WS2812_CTYPE strip = new NeoPixelBus(WS2812_MAX_LEDS, pin[GPIO_WS2812]); @@ -331,7 +347,7 @@ void Ws2812Clear() void Ws2812SetColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { -#if (USE_WS2812_CTYPE > 1) +#if (USE_WS2812_CTYPE > NEO_3LED) RgbwColor lcolor; lcolor.W = white; #else @@ -357,7 +373,7 @@ char* Ws2812GetColor(uint16_t led, char* scolor) { uint8_t sl_ledcolor[4]; - #if (USE_WS2812_CTYPE > 1) + #if (USE_WS2812_CTYPE > NEO_3LED) RgbwColor lcolor = strip->GetPixelColor(led -1); sl_ledcolor[3] = lcolor.W; #else