5.2.4 20170703
* Removed flash mode update after selecting different module solving
esp8285 related problems
* Add device type flag to sonoff_template.ino
* Change Sonoff Led Wakeup and add support for Sonoff BN-SZ01 Led
This commit is contained in:
arendst 2017-07-03 11:45:15 +02:00
parent c768f7d610
commit 39a65e230b
8 changed files with 117 additions and 52 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.2.3** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
Current version is **5.2.4** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
### **** ATTENTION Version 5.x.x specific information ****
@ -39,6 +39,7 @@ The following devices are supported:
- [iTead Sonoff Touch](http://sonoff.itead.cc/en/products/residential/sonoff-touch)
- [iTead Sonoff SC](http://sonoff.itead.cc/en/products/residential/sonoff-sc)
- [iTead Sonoff Led](http://sonoff.itead.cc/en/products/appliances/sonoff-led)
- [iTead Sonoff BN-SZ01 Led](http://sonoff.itead.cc/en/products/appliances/bn-sz01)
- [iTead Sonoff Dev](https://www.itead.cc/sonoff-dev.html)
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)

View File

@ -1,4 +1,9 @@
/* 5.2.3 20170630
/* 5.2.4 20170703
* Removed flash mode update after selecting different module solving esp8285 related problems
* Add device type flag to sonoff_template.ino
* Change Sonoff Led Wakeup and add support for Sonoff BN-SZ01 Led
*
* 5.2.3 20170630
* Change Sonoff Led color conversion code
* Fix SetOption12 handling
* Simplify auto configuration upgrade

View File

@ -174,7 +174,8 @@ void setFlashMode(byte option, byte mode)
void setModuleFlashMode(byte option)
{
uint8_t mode = 0; // QIO - ESP8266
if ((SONOFF_TOUCH == sysCfg.module) || (SONOFF_4CH == sysCfg.module)) {
// if ((SONOFF_TOUCH == sysCfg.module) || (SONOFF_4CH == sysCfg.module)) {
if (sysCfg.my_module.flag &1) {
mode = 3; // DOUT - ESP8285
}
setFlashMode(option, mode);

View File

@ -24,7 +24,7 @@
- Select IDE Tools - Flash size: "1M (no SPIFFS)"
====================================================*/
#define VERSION 0x05020300 // 5.2.3
#define VERSION 0x05020400 // 5.2.4
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
enum week_t {Last, First, Second, Third, Fourth};
@ -122,7 +122,8 @@ enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
#define PWM_RANGE 1023 // 255..1023 needs to be devisible by 256
//#define PWM_FREQ 1000 // 100..1000 Hz led refresh
#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
//#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
#define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value)
#define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power (Pow)
#define MAX_POWER_WINDOW 30 // Time in SECONDS to disable allow max agreed power (Pow)
@ -294,6 +295,7 @@ uint8_t hlw_flg = 0; // Power monitor configured
uint8_t i2c_flg = 0; // I2C configured
uint8_t spi_flg = 0; // SPI configured
uint8_t pwm_flg = 0; // PWM configured
uint8_t sfl_flg = 0; // Sonoff Led flag (0 = No led, 1 = BN-SZ01, 2 = Sonoff Led)
uint8_t pwm_idxoffset = 0; // Allowed PWM command offset (change for Sonoff Led)
boolean mDNSbegun = false;
@ -400,7 +402,7 @@ void setRelay(uint8_t rpower)
Serial.write('\n');
Serial.flush();
}
else if (SONOFF_LED == sysCfg.module) {
else if (sfl_flg) {
sl_setPower(rpower &1);
}
else if (EXS_RELAY == sysCfg.module) {
@ -1006,7 +1008,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
}
snprintf_P(svalue, sizeof(svalue), PSTR("{\"BlinkCount\":%d}"), sysCfg.blinkcount);
}
else if ((SONOFF_LED == sysCfg.module) && sl_command(type, index, dataBufUc, data_len, payload, svalue, sizeof(svalue))) {
else if (sfl_flg && sl_command(type, index, dataBufUc, data_len, payload, svalue, sizeof(svalue))) {
// Serviced
}
else if (!strcmp_P(type,PSTR("SAVEDATA"))) {
@ -1146,7 +1148,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
sysCfg.my_module.gp.io[i] = 0;
}
setModuleFlashMode(0);
// setModuleFlashMode(0); // Fails on esp8285 based devices
}
restartflag = 2;
}
@ -2074,7 +2076,7 @@ void stateloop()
}
}
if (SONOFF_LED == sysCfg.module) {
if (sfl_flg) { // Sonoff BN-SZ01 or Sonoff Led
sl_animate();
}
@ -2302,7 +2304,7 @@ void stateloop()
if (90 == otaflag) { // Allow MQTT to reconnect
otaflag = 0;
if (otaok) {
setModuleFlashMode(1); // QIO - ESP8266, DOUT - ESP8285 (Sonoff 4CH and Touch)
setModuleFlashMode(1); // QIO - ESP8266, DOUT - ESP8285 (Sonoff 4CH, Touch and BN-SZ01)
snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting"));
} else {
snprintf_P(svalue, sizeof(svalue), PSTR("Failed %s"), ESPhttpUpdate.getLastErrorString().c_str());
@ -2457,6 +2459,7 @@ void GPIO_init()
}
memcpy_P(&def_module, &modules[sysCfg.module], sizeof(def_module));
sysCfg.my_module.flag = def_module.flag;
strlcpy(my_module.name, def_module.name, sizeof(my_module.name));
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
if (sysCfg.my_module.gp.io[i] > GPIO_NONE) {
@ -2521,22 +2524,11 @@ void GPIO_init()
Maxdevice = 0;
Baudrate = 19200;
}
else if (SONOFF_BN == sysCfg.module) {
sfl_flg = 1;
}
else if (SONOFF_LED == sysCfg.module) {
pwm_idxoffset = 2;
pin[GPIO_WS2812] = 99; // I do not allow both Sonoff Led AND WS2812 led
if (!my_module.gp.io[4]) {
pinMode(4, OUTPUT); // Stop floating outputs
digitalWrite(4, LOW);
}
if (!my_module.gp.io[5]) {
pinMode(5, OUTPUT); // Stop floating outputs
digitalWrite(5, LOW);
}
if (!my_module.gp.io[14]) {
pinMode(14, OUTPUT); // Stop floating outputs
digitalWrite(14, LOW);
}
sl_init();
sfl_flg = 2;
}
else {
Maxdevice = 0;
@ -2561,6 +2553,24 @@ void GPIO_init()
lastwallswitch[i] = digitalRead(pin[GPIO_SWT1 +i]); // set global now so doesn't change the saved power state on first switch check
}
}
if (sfl_flg) { // Sonoff Led or BN-SZ01
pwm_idxoffset = sfl_flg; // 1 for BN-SZ01, 2 for Sonoff Led
pin[GPIO_WS2812] = 99; // I do not allow both Sonoff Led AND WS2812 led
if (!my_module.gp.io[4]) {
pinMode(4, OUTPUT); // Stop floating outputs
digitalWrite(4, LOW);
}
if (!my_module.gp.io[5]) {
pinMode(5, OUTPUT); // Stop floating outputs
digitalWrite(5, LOW);
}
if (!my_module.gp.io[14]) {
pinMode(14, OUTPUT); // Stop floating outputs
digitalWrite(14, LOW);
}
sl_init();
}
for (byte i = pwm_idxoffset; i < 5; i++) {
if (pin[GPIO_PWM1 +i] < 99) {
pwm_flg = 1;

View File

@ -145,6 +145,7 @@ enum module_t {
SONOFF_DEV,
H801,
SONOFF_SC,
SONOFF_BN,
MAXMODULE };
/********************************************************************************************/
@ -156,13 +157,15 @@ typedef struct MYIO {
} myio;
typedef struct MYTMPLT {
char name[15];
char name[14];
uint8_t flag; // bit 0 = flashmode (0 = esp8266, 1 = esp8285)
myio gp;
} mytmplt;
// Default module settings
const mytmplt modules[MAXMODULE] PROGMEM = {
{ "Sonoff Basic", // Sonoff Basic (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0, // GPIO02
@ -183,6 +186,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0 // ADC0 Analog input
},
{ "Sonoff RF", // Sonoff RF (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0,
@ -196,6 +200,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0
},
{ "Sonoff SV", // Sonoff SV (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0,
@ -210,6 +215,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
GPIO_ADC0 // ADC0 Analog input
},
{ "Sonoff TH", // Sonoff TH10/16 (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0,
@ -223,6 +229,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0
},
{ "Sonoff Dual", // Sonoff Dual (ESP8266)
0, // esp8266
0,
GPIO_TXD, // GPIO01 Relay control
0,
@ -235,6 +242,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0, 0
},
{ "Sonoff Pow", // Sonoff Pow (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
0, 0, 0, 0,
GPIO_HLW_SEL, // GPIO05 HLW8012 Sel output
@ -246,6 +254,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0
},
{ "Sonoff 4CH", // Sonoff 4CH (ESP8285)
1, // esp8285
GPIO_KEY1, // GPIO00 Button 1
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
GPIO_USER, // GPIO02 Optional sensor
@ -263,6 +272,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0
},
{ "S20 Socket", // S20 Smart Socket (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0,
@ -274,6 +284,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0, 0
},
{ "Slampher", // Slampher (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0,
@ -285,6 +296,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0, 0
},
{ "Sonoff Touch", // Sonoff Touch (ESP8285)
1, // esp8285
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0,
@ -297,6 +309,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0, 0
},
{ "Sonoff LED", // Sonoff LED (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
0, 0, 0,
GPIO_USER, // GPIO04 Optional sensor (PWM3 Green)
@ -309,6 +322,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0
},
{ "1 Channel", // 1 Channel Inching/Latching Relay using (PSA-B01 - ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, // Flash connection
@ -316,7 +330,8 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
0, 0, 0, 0
},
{ "4 Channel", // 4 Channel Inching/Latching Relays
{ "4 Channel", // 4 Channel Inching/Latching Relays (ESP8266)
0, // esp8266
0,
GPIO_TXD, // GPIO01 Relay control
0,
@ -328,6 +343,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0, 0
},
{ "Motor C/AC", // Motor Clockwise / Anti clockwise (PSA-B01 - ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, // Flash connection
@ -336,6 +352,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0, 0, 0
},
{ "ElectroDragon", // ElectroDragon IoT Relay Board (ESP8266)
0, // esp8266
GPIO_KEY2, // GPIO00 Button 2
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
GPIO_KEY1, // GPIO02 Button 1
@ -352,6 +369,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
},
{ "EXS Relay", // Latching relay https://ex-store.de/ESP8266-WiFi-Relay-V31 (ESP8266)
// Module Pin 1 VCC 3V3, Module Pin 6 GND
0, // esp8266
GPIO_KEY1, // GPIO00 Module Pin 8 - Button (firmware flash)
GPIO_USER, // GPIO01 Module Pin 2 = UART0_TXD
GPIO_USER, // GPIO02 Module Pin 7
@ -367,6 +385,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0
},
{ "WiOn", // Indoor Tap https://www.amazon.com/gp/product/B00ZYLUBJU/ref=s9_acsd_al_bw_c_x_3_w (ESP8266)
0, // esp8266
GPIO_USER, // GPIO00 Optional sensor (pm clock)
0,
GPIO_LED1, // GPIO02 Green Led (1 = On, 0 = Off)
@ -379,6 +398,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0
},
{ "WeMos D1 mini", // WeMos and NodeMCU hardware (ESP8266)
0, // esp8266
GPIO_USER, // GPIO00 D3 Wemos Button Shield
GPIO_USER, // GPIO01 TX Serial RXD
GPIO_USER, // GPIO02 D4 Wemos DHT Shield
@ -394,6 +414,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
GPIO_ADC0 // ADC0 A0 Analog input
},
{ "Sonoff Dev", // Sonoff Dev (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 E-FW Button
GPIO_USER, // GPIO01 TX Serial RXD and Optional sensor
0, // GPIO02
@ -409,6 +430,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
GPIO_ADC0 // ADC0 A0 Analog input
},
{ "H801", // Lixada H801 Wifi (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 E-FW Button
GPIO_LED1, // GPIO01 Green LED
GPIO_TXD, // GPIO02 RX - Pin next to TX on the PCB
@ -423,6 +445,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0, 0
},
{ "Sonoff SC", // Sonoff SC (ESP8266)
0, // esp8266
GPIO_KEY1, // GPIO00 Button
GPIO_TXD, // GPIO01 RXD to ATMEGA328P
GPIO_USER, // GPIO02 Optional sensor
@ -432,6 +455,16 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
0,
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
0, 0, 0, 0
},
{ "Sonoff BN-SZ", // Sonoff BN-SZ01 LED (ESP8285)
1, // esp8285
0, 0, 0, 0, 0, 0,
0, 0, 0, // Flash connection
0, 0, 0,
GPIO_PWM1, // GPIO12 Light
GPIO_LED1_INV, // GPIO13 Red Led (0 = On, 1 = Off)
0, 0,
0, 0
}
};

View File

@ -415,7 +415,7 @@ void handleRoot()
page += F("<div id='l1' name='l1'></div>");
if (Maxdevice) {
if (SONOFF_LED == sysCfg.module) {
if (sfl_flg) {
snprintf_P(line, sizeof(line), PSTR("<input type='range' min='1' max='100' value='%d' onchange='lb(value)'>"),
sysCfg.led_dimmer[0]);
page += line;
@ -509,7 +509,7 @@ void handleAjax2()
}
/*
* Will interrupt user action when selected
if (SONOFF_LED == sysCfg.module) {
if (sfl_flg) {
snprintf_P(line, sizeof(line), PSTR("<input type='range' min='1' max='100' value='%d' onchange='lb(value)'>"),
sysCfg.led_dimmer[0]);
page += line;
@ -995,7 +995,7 @@ void handleSave()
gpios += F(", GPIO"); gpios += String(i); gpios += F(" "); gpios += String(sysCfg.my_module.gp.io[i]);
}
}
setModuleFlashMode(0);
// setModuleFlashMode(0); // Fails on esp8285 based devices
snprintf_P(stemp, sizeof(stemp), modules[sysCfg.module].name);
snprintf_P(log, sizeof(log), PSTR("HTTP: %s Module%s"), stemp, gpios.c_str());
addLog(LOG_LEVEL_INFO, log);
@ -1218,7 +1218,8 @@ void handleUploadLoop()
_uploaderror = 4;
return;
}
if ((SONOFF_TOUCH == sysCfg.module) || (SONOFF_4CH == sysCfg.module)) {
// if ((SONOFF_TOUCH == sysCfg.module) || (SONOFF_4CH == sysCfg.module)) {
if (sysCfg.my_module.flag &1) {
upload.buf[2] = 3; // DOUT - ESP8285
addLog_P(LOG_LEVEL_DEBUG, PSTR("FLSH: Set Flash Mode to 3"));
}

View File

@ -56,7 +56,7 @@ void mqtt_publishDomoticzPowerState(byte device)
device = 1;
}
if (SONOFF_LED == sysCfg.module) {
if (sfl_flg) {
snprintf_P(svalue, sizeof(svalue), PSTR("{\"idx\":%d,\"nvalue\":2,\"svalue\":\"%d\"}"),
sysCfg.domoticz_relay_idx[device -1], sysCfg.led_dimmer[device -1]);
mqtt_publish(domoticz_in_topic, svalue);
@ -172,7 +172,7 @@ boolean domoticz_mqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uin
if ((pin[GPIO_WS2812] < 99) && (sysCfg.ws_dimmer == nvalue)) {
return 1;
}
if ((SONOFF_LED == sysCfg.module) && (sysCfg.led_dimmer[i] == nvalue)) {
if (sfl_flg && (sysCfg.led_dimmer[i] == nvalue)) {
return 1;
}
snprintf_P(topicBuf, stopicBuf, PSTR("/DIMMER%s"), (Maxdevice > 1) ? stemp1 : "");

View File

@ -18,7 +18,7 @@
*/
/*********************************************************************************************\
* Sonoff Led
* Sonoff Led and BN-SZ01
\*********************************************************************************************/
uint8_t ledTable[] = {
@ -51,10 +51,13 @@ uint16_t sl_wakeupCntr = 0;
void sl_setDim(uint8_t myDimmer)
{
if ((1 == sfl_flg) && (100 == myDimmer)) {
myDimmer = 99; // BN-SZ01 starts flickering at dimmer = 100
}
float newDim = 100 / (float)myDimmer;
float fmyCld = (float)sysCfg.led_color[0] / newDim;
float fmyWrm = (float)sysCfg.led_color[1] / newDim;
sl_dcolor[0] = (uint8_t)fmyCld;
float fmyWrm = (float)sysCfg.led_color[1] / newDim;
sl_dcolor[1] = (uint8_t)fmyWrm;
}
@ -62,8 +65,10 @@ void sl_setDim(uint8_t myDimmer)
void sl_init(void)
{
sysCfg.pwmvalue[0] = 0; // We use led_color
sysCfg.pwmvalue[0] = 0; // We use dimmer / led_color
if (2 == sfl_flg) {
sysCfg.pwmvalue[1] = 0; // We use led_color
}
sl_power = 0;
sl_any = 0;
sl_wakeupActive = 0;
@ -72,7 +77,9 @@ void sl_init(void)
void sl_setPower(uint8_t power)
{
sl_power = power &1;
sl_wakeupActive = 0;
if (sl_wakeupActive) {
sl_wakeupActive--;
}
sl_animate();
}
@ -93,24 +100,26 @@ void sl_animate()
sl_tcolor[0] = sl_dcolor[0];
sl_tcolor[1] = sl_dcolor[1];
} else {
if ((sl_tcolor[0] != sl_dcolor[0]) || (sl_tcolor[1] != sl_dcolor[1])) {
if (sl_tcolor[0] != sl_dcolor[0]) {
if (sl_tcolor[0] < sl_dcolor[0]) {
sl_tcolor[0] += ((sl_dcolor[0] - sl_tcolor[0]) >> sysCfg.led_speed) +1;
}
if (sl_tcolor[1] < sl_dcolor[1]) {
sl_tcolor[1] += ((sl_dcolor[1] - sl_tcolor[1]) >> sysCfg.led_speed) +1;
}
if (sl_tcolor[0] > sl_dcolor[0]) {
sl_tcolor[0] -= ((sl_tcolor[0] - sl_dcolor[0]) >> sysCfg.led_speed) +1;
}
}
if ((2 == sfl_flg) && (sl_tcolor[1] != sl_dcolor[1])) {
if (sl_tcolor[1] < sl_dcolor[1]) {
sl_tcolor[1] += ((sl_dcolor[1] - sl_tcolor[1]) >> sysCfg.led_speed) +1;
}
if (sl_tcolor[1] > sl_dcolor[1]) {
sl_tcolor[1] -= ((sl_tcolor[1] - sl_dcolor[1]) >> sysCfg.led_speed) +1;
}
}
}
} else { // Power On using wake up duration
if (1 == sl_wakeupActive) {
sl_wakeupActive = 2;
if (2 == sl_wakeupActive) {
sl_wakeupActive = 1;
sl_tcolor[0] = 0;
sl_tcolor[1] = 0;
sl_wakeupCntr = 0;
@ -136,7 +145,7 @@ void sl_animate()
sl_any = 0;
sl_lcolor[0] = sl_tcolor[0];
sl_lcolor[1] = sl_tcolor[1];
for (byte i = 0; i < 2; i++) {
for (byte i = 0; i < sfl_flg; i++) {
if (pin[GPIO_PWM1 +i] < 99) {
analogWrite(pin[GPIO_PWM1 +i], ((sysCfg.led_table) ? ledTable[sl_lcolor[i]] : sl_lcolor[i]) * (PWM_RANGE / 255));
}
@ -153,7 +162,7 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
boolean serviced = true;
boolean coldim = false;
if (!strcmp_P(type,PSTR("COLOR"))) {
if ((2 == sfl_flg) && !strcmp_P(type,PSTR("COLOR"))) {
uint8_t my_color[2];
char *p;
if (4 == data_len) {
@ -228,8 +237,8 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
snprintf_P(svalue, ssvalue, PSTR("{\"WakeUpDuration\":%d}"), sysCfg.led_wakeup);
}
else if (!strcmp_P(type,PSTR("WAKEUP"))) {
do_cmnd_power(index, 1);
sl_wakeupActive = 1;
sl_wakeupActive = 3;
do_cmnd_power(1, 1);
snprintf_P(svalue, ssvalue, PSTR("{\"Wakeup\":\"Started\"}"));
}
else {
@ -247,10 +256,15 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
mqtt_publishDomoticzPowerState(1);
#endif // USE_DOMOTICZ
sl_setDim(sysCfg.led_dimmer[0]);
if (2 == sfl_flg) {
uint16_t color = (uint16_t)sl_dcolor[0] << 8;
color += (uint16_t)sl_dcolor[1];
snprintf_P(svalue, ssvalue, PSTR("{\"POWER\":\"%s\", \"Dimmer\":%d, \"Color\":\"%04X\"}"),
getStateText(power &1), sysCfg.led_dimmer[0], color);
} else {
snprintf_P(svalue, ssvalue, PSTR("{\"POWER\":\"%s\", \"Dimmer\":%d}"),
getStateText(power &1), sysCfg.led_dimmer[0]);
}
}
return serviced;
}