Skip to content

Commit

Permalink
Merge pull request #7 from arendst/development
Browse files Browse the repository at this point in the history
update fork
  • Loading branch information
ascillato committed Mar 17, 2018
2 parents e8c90d1 + bdb6525 commit ef37aab
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Basic Functionality Available. Work in progress.

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

Expand Down
5 changes: 4 additions & 1 deletion sonoff/_releasenotes.ino
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions sonoff/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions sonoff/sonoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
\*********************************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion sonoff/sonoff_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
28 changes: 14 additions & 14 deletions sonoff/xdrv_00_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -100,7 +100,7 @@ void MqttLoop()
MqttClient.loop();
}

#elif (2 == MQTT_LIBRARY_TYPE) /*****************************************************************/
#elif (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) /**********************************************/

#include <TasmotaMqtt.h>
TasmotaMqtt MqttClient;
Expand Down Expand Up @@ -134,7 +134,7 @@ void MqttLoop()
{
}

#elif (3 == MQTT_LIBRARY_TYPE) /***************************************************************/
#elif (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) /*******************************************/

#include <MQTT.h>
MQTT *MqttClient = NULL;
Expand Down Expand Up @@ -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);
Expand All @@ -468,17 +468,17 @@ 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)) {
MqttConnected();
} 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
}
Expand Down
2 changes: 1 addition & 1 deletion sonoff/xdrv_01_light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
54 changes: 35 additions & 19 deletions sonoff/xplg_ws2812.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ef37aab

Please sign in to comment.