v5.12.0f - Add BRG and RBG support

5.12.0f
 * Add compile time support for WS2812 BRG and RBG led
configurations to be defined in user_config.h (#1690)
This commit is contained in:
Theo Arends 2018-03-17 15:22:29 +01:00
parent 42ad9e1a66
commit bdb652547e
10 changed files with 76 additions and 44 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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
\*********************************************************************************************/

View File

@ -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 <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)

View File

@ -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))

View File

@ -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))

View File

@ -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 <PubSubClient.h>
@ -100,7 +100,7 @@ void MqttLoop()
MqttClient.loop();
}
#elif (2 == MQTT_LIBRARY_TYPE) /*****************************************************************/
#elif (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) /**********************************************/
#include <TasmotaMqtt.h>
TasmotaMqtt MqttClient;
@ -134,7 +134,7 @@ void MqttLoop()
{
}
#elif (3 == MQTT_LIBRARY_TYPE) /***************************************************************/
#elif (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) /*******************************************/
#include <MQTT.h>
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
}

View File

@ -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();

View File

@ -25,21 +25,29 @@
#include <NeoPixelBus.h>
#ifdef USE_WS2812_DMA
#if (USE_WS2812_CTYPE == 1)
#if (USE_WS2812_CTYPE == NEO_GRB)
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == 2)
#elif (USE_WS2812_CTYPE == NEO_BRG)
NeoPixelBus<NeoBrgFeature, Neo800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == NEO_RBG)
NeoPixelBus<NeoRbgFeature, Neo800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == NEO_RGBW)
NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == 3)
#elif (USE_WS2812_CTYPE == NEO_GRBW)
NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> *strip = NULL;
#else // USE_WS2812_CTYPE
NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> *strip = NULL;
#endif // USE_WS2812_CTYPE
#else // USE_WS2812_DMA
#if (USE_WS2812_CTYPE == 1)
#if (USE_WS2812_CTYPE == NEO_GRB)
NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == 2)
#elif (USE_WS2812_CTYPE == NEO_BRG)
NeoPixelBus<NeoBrgFeature, NeoEsp8266BitBang800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == NEO_RBG)
NeoPixelBus<NeoRbgFeature, NeoEsp8266BitBang800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == NEO_RGBW)
NeoPixelBus<NeoRgbwFeature, NeoEsp8266BitBang800KbpsMethod> *strip = NULL;
#elif (USE_WS2812_CTYPE == 3)
#elif (USE_WS2812_CTYPE == NEO_GRBW)
NeoPixelBus<NeoGrbwFeature, NeoEsp8266BitBang800KbpsMethod> *strip = NULL;
#else // USE_WS2812_CTYPE
NeoPixelBus<NeoRgbFeature, NeoEsp8266BitBang800KbpsMethod> *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<NeoGrbFeature, Neo800KbpsMethod>(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<NeoBrgFeature, Neo800KbpsMethod>(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<NeoRbgFeature, Neo800KbpsMethod>(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<NeoRgbwFeature, Neo800KbpsMethod>(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<NeoGrbwFeature, Neo800KbpsMethod>(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<NeoRgbFeature, Neo800KbpsMethod>(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<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod>(WS2812_MAX_LEDS, pin[GPIO_WS2812]);
#elif (USE_WS2812_CTYPE == 2)
#elif (USE_WS2812_CTYPE == NEO_BRG)
strip = new NeoPixelBus<NeoBrgFeature, NeoEsp8266BitBang800KbpsMethod>(WS2812_MAX_LEDS, pin[GPIO_WS2812]);
#elif (USE_WS2812_CTYPE == NEO_RBG)
strip = new NeoPixelBus<NeoRbgFeature, NeoEsp8266BitBang800KbpsMethod>(WS2812_MAX_LEDS, pin[GPIO_WS2812]);
#elif (USE_WS2812_CTYPE == NEO_RGBW)
strip = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266BitBang800KbpsMethod>(WS2812_MAX_LEDS, pin[GPIO_WS2812]);
#elif (USE_WS2812_CTYPE == 3)
#elif (USE_WS2812_CTYPE == NEO_GRBW)
strip = new NeoPixelBus<NeoGrbwFeature, NeoEsp8266BitBang800KbpsMethod>(WS2812_MAX_LEDS, pin[GPIO_WS2812]);
#else // USE_WS2812_CTYPE
strip = new NeoPixelBus<NeoRgbFeature, NeoEsp8266BitBang800KbpsMethod>(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