v5.8.0p - Prep for release

5.8.0p
 * Fix initial PwmFrequency and PwmRange
 * Add support for
Arilux AL-LC01 RGB Led controller (#370)
 * Add light turn Off Fade
(#925)
 * Change IrSend Panasonic command to IrSend
{"Protocol":"Panasonic", "Bits":16388, "Data":<Panasonic data>}
 *
where 16388 is 0x4004 hexadecimal (#1014)
This commit is contained in:
arendst 2017-10-26 16:33:33 +02:00
parent cf350dc584
commit ae12b958cd
12 changed files with 182 additions and 200 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.8.0o** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
Current version is **5.8.0p** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions

View File

@ -51,17 +51,6 @@ lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
; *** Serial Monitor options
monitor_baud = 115200
; *** Upload Serial reset method for Wemos and NodeMCU
;upload_resetmethod = nodemcu
; *** Upload file to OTA server using SCP
;upload_port = user@host:/path
;extra_scripts = pio/sftp-uploader.py
; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/http-uploader.py
[env:sonoff-DE]
platform = espressif8266
framework = arduino
@ -73,17 +62,6 @@ lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
; *** Serial Monitor options
monitor_baud = 115200
; *** Upload Serial reset method for Wemos and NodeMCU
;upload_resetmethod = nodemcu
; *** Upload file to OTA server using SCP
;upload_port = user@host:/path
;extra_scripts = pio/sftp-uploader.py
; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/http-uploader.py
[env:sonoff-PL]
platform = espressif8266
framework = arduino
@ -95,17 +73,6 @@ lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
; *** Serial Monitor options
monitor_baud = 115200
; *** Upload Serial reset method for Wemos and NodeMCU
;upload_resetmethod = nodemcu
; *** Upload file to OTA server using SCP
;upload_port = user@host:/path
;extra_scripts = pio/sftp-uploader.py
; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/http-uploader.py
; Sonoff minimal
[env:sonoff-minimal] ; Placeholder to be configured
platform = espressif8266
@ -118,17 +85,6 @@ lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
; Serial Monitor options
monitor_baud = 115200
; *** Upload Serial reset method for Wemos and NodeMCU
;upload_resetmethod = nodemcu
; *** Upload file to OTA server using SCP
;upload_port = user@host:/path
;extra_scripts = pio/sftp-uploader.py
; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/http-uploader.py
; Sonoff multiple DS18x20
[env:sonoff-ds18x20]
platform = espressif8266
@ -140,14 +96,3 @@ lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON, OneWire
; Serial Monitor options
monitor_baud = 115200
; *** Upload Serial reset method for Wemos and NodeMCU
;upload_resetmethod = nodemcu
; *** Upload file to OTA server using SCP
;upload_port = user@host:/path
;extra_scripts = pio/sftp-uploader.py
; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/http-uploader.py

View File

@ -1,4 +1,11 @@
/* 5.8.0o
/* 5.8.0p
* Fix initial PwmFrequency and PwmRange
* Add support for Arilux AL-LC01 RGB Led controller (#370)
* Add light turn Off Fade (#925)
* Change IrSend Panasonic command to IrSend {"Protocol":"Panasonic", "Bits":16388, "Data":<Panasonic data>}
* where 16388 is 0x4004 hexadecimal (#1014)
*
* 5.8.0o
* Remove max string length of 14 for Domoticz sensor descriptions
* Add light scheme options (Color cycle Up, Down, Random) and moving WS2812 schemes up by 3
* Add support for VEML6070 I2C Ultra Violet level sensor (#1053)
@ -92,7 +99,7 @@
* Fix compile error when DOMOTICZ_UPDATE_TIMER is not defined (#930)
* Fix alignment of web page items in some browsers (#935)
* Add smoother movement of hour hand in WS2812 led clock (#936)
* Add support for Magic Home and Arilux RGBW Led controller (#940)
* Add support for Magic Home RGBW Led controller (#940)
*
* 5.8.0b
* Fix command FullTopic entry when using serial or console interface

View File

@ -111,9 +111,9 @@ struct SYSCFG {
unsigned long domoticz_relay_idx[MAX_DOMOTICZ_IDX]; // 344
unsigned long domoticz_key_idx[MAX_DOMOTICZ_IDX]; // 354
unsigned long hlw_power_calibration; // 364
unsigned long hlw_voltage_calibration; // 368
unsigned long hlw_current_calibration; // 36C
unsigned long hlw_power_calibration; // 364
unsigned long hlw_voltage_calibration; // 368
unsigned long hlw_current_calibration; // 36C
unsigned long hlw_kWhtoday; // 370
unsigned long hlw_kWhyesterday; // 374
uint16_t hlw_kWhdoy; // 378
@ -166,21 +166,21 @@ struct SYSCFG {
uint8_t ws_width[3]; // 481
myio my_gp; // 484
uint16_t led_pixels; // 496
uint8_t led_color[5]; // 498
uint8_t led_table; // 49D
uint8_t led_dimmer; // 49E
uint16_t light_pixels; // 496
uint8_t light_color[5]; // 498
uint8_t light_correction; // 49D
uint8_t light_dimmer; // 49E
byte free_49F[2]; // 49F
uint8_t led_fade; // 4A1
uint8_t led_speed; // 4A2
uint8_t led_scheme; // 4A3
uint8_t led_width; // 4A4
uint8_t light_fade; // 4A1
uint8_t light_speed; // 4A2
uint8_t light_scheme; // 4A3
uint8_t light_width; // 4A4
byte free_4A5[1]; // 4A5
uint16_t led_wakeup; // 4A6
uint16_t light_wakeup; // 4A6
byte free_4A8[1]; // 4A8

View File

@ -508,9 +508,12 @@ void SettingsDefaultSet2()
memcpy_P(Settings.rf_code[0], kDefaultRfCode, 9);
// 5.8.0
Settings.led_pixels = WS2812_LEDS;
Settings.light_pixels = WS2812_LEDS;
// 5.8.1
// Settings.altitude = 0;
Settings.pwm_frequency = PWM_FREQ;
Settings.pwm_range = PWM_RANGE;
SettingsDefaultSet_5_8_1();
}
@ -545,17 +548,17 @@ void SettingsDefaultSet_3_9_3()
Settings.my_gp.io[i] = 0;
}
Settings.led_pixels = WS2812_LEDS;
Settings.light_pixels = WS2812_LEDS;
for (byte i = 0; i < MAX_PWMS; i++) {
Settings.led_color[i] = 255;
Settings.light_color[i] = 255;
}
Settings.led_table = 0;
Settings.led_dimmer = 10;
Settings.led_fade = 0;
Settings.led_speed = 1;
Settings.led_scheme = 0;
Settings.led_width = 1;
Settings.led_wakeup = 0;
Settings.light_correction = 0;
Settings.light_dimmer = 10;
Settings.light_fade = 0;
Settings.light_speed = 1;
Settings.light_scheme = 0;
Settings.light_width = 1;
Settings.light_wakeup = 0;
}
void SettingsDefaultSet_4_0_4()
@ -733,21 +736,21 @@ void SettingsDelta()
cfg_wsflg = 1;
}
}
if (!Settings.led_pixels && cfg_wsflg) {
Settings.led_pixels = Settings.ws_pixels;
Settings.led_color[0] = Settings.ws_red;
Settings.led_color[1] = Settings.ws_green;
Settings.led_color[2] = Settings.ws_blue;
Settings.led_dimmer = Settings.ws_dimmer;
Settings.led_table = Settings.ws_ledtable;
Settings.led_fade = Settings.ws_fade;
Settings.led_speed = Settings.ws_speed;
Settings.led_scheme = Settings.ws_scheme;
Settings.led_width = Settings.ex_ws_width;
Settings.led_wakeup = Settings.ws_wakeup;
if (!Settings.light_pixels && cfg_wsflg) {
Settings.light_pixels = Settings.ws_pixels;
Settings.light_color[0] = Settings.ws_red;
Settings.light_color[1] = Settings.ws_green;
Settings.light_color[2] = Settings.ws_blue;
Settings.light_dimmer = Settings.ws_dimmer;
Settings.light_correction = Settings.ws_ledtable;
Settings.light_fade = Settings.ws_fade;
Settings.light_speed = Settings.ws_speed;
Settings.light_scheme = Settings.ws_scheme;
Settings.light_width = Settings.ex_ws_width;
Settings.light_wakeup = Settings.ws_wakeup;
} else {
Settings.led_pixels = WS2812_LEDS;
Settings.led_width = 1;
Settings.light_pixels = WS2812_LEDS;
Settings.light_width = 1;
}
}
if (Settings.version < 0x0508000A) {

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/
#define VERSION 0x0508000F // 5.8.0o
#define VERSION 0x05080010 // 5.8.0p
// Location specific includes
#include "sonoff.h" // Enumaration used in user_config.h
@ -2560,7 +2560,7 @@ void GpioInit()
devices_present = 0;
baudrate = 19200;
}
else if ((H801 == Settings.module) || (MAGICHOME == Settings.module)) { // PWM RGBCW led
else if ((H801 == Settings.module) || (MAGICHOME == Settings.module) || (ARILUX == Settings.module)) { // PWM RGBCW led
if (!Settings.flag.pwm_control) {
light_type = LT_BASIC; // Use basic PWM control if SetOption15 = 0
}

View File

@ -193,6 +193,7 @@ enum SupportedModules {
MAGICHOME,
LUANIHVIO,
KMC_70011,
ARILUX,
MAXMODULE };
/********************************************************************************************/
@ -242,6 +243,7 @@ const uint8_t kNiceList[MAXMODULE] PROGMEM = {
WION,
H801,
MAGICHOME,
ARILUX,
HUAFAN_SS,
KMC_70011,
AILIGHT,
@ -727,6 +729,16 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_LED1_INV, // GPIO13 Green Led
GPIO_REL1, // GPIO14 Relay
0, 0, 0
},
{ "Arilux", // Arilux AL-LC01 (ESP8285) - https://www.banggood.com/nl/ARILUX-AL-LC01-Super-Mini-LED-WIFI-Smart-RGB-Controller-For-RGB-LED-Strip-Light-DC-9-12V-p-1058603.html
0, 0, 0, 0, // (PwmFrequency 1111Hz)
GPIO_USER, // GPIO04 IR or RF receiver (optional)
GPIO_PWM1, // GPIO05 RGB LED Red
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_PWM2, // GPIO12 RGB LED Green
GPIO_PWM3, // GPIO13 RGB LED Blue
GPIO_USER, // GPIO14 RGBW LED White (optional - set to PWM4 for Cold White or Warm White)
0, 0, 0
}
};

View File

@ -461,7 +461,7 @@ void HandleRoot()
snprintf_P(line, sizeof(line), HTTP_MSG_SLIDER1, LightGetColorTemp());
page += line;
}
snprintf_P(line, sizeof(line), HTTP_MSG_SLIDER2, Settings.led_dimmer);
snprintf_P(line, sizeof(line), HTTP_MSG_SLIDER2, Settings.light_dimmer);
page += line;
}
page += FPSTR(HTTP_TABLE100);
@ -591,7 +591,7 @@ void HandleAjaxStatusRefresh()
* Will interrupt user action when selected
if (light_type) {
snprintf_P(line, sizeof(line), PSTR("<input type='range' min='1' max='100' value='%d' onchange='lb(value)'>"),
Settings.led_dimmer);
Settings.light_dimmer);
page += line;
}
*/

View File

@ -55,7 +55,7 @@ void MqttPublishDomoticzPowerState(byte device)
device = 1;
}
if (Settings.flag.mqtt_enabled && Settings.domoticz_relay_idx[device -1]) {
snprintf_P(sdimmer, sizeof(sdimmer), PSTR("%d"), Settings.led_dimmer);
snprintf_P(sdimmer, sizeof(sdimmer), PSTR("%d"), Settings.light_dimmer);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"idx\":%d,\"nvalue\":%d,\"svalue\":\"%s\"}"),
Settings.domoticz_relay_idx[device -1], (power & (1 << (device -1))) ? 1 : 0, (light_type) ? sdimmer : "");
MqttPublish(domoticz_in_topic);
@ -154,7 +154,7 @@ boolean DomoticzMqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uint
snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), i +1);
if (2 == nvalue) {
nvalue = domoticz["svalue1"];
if (light_type && (Settings.led_dimmer == nvalue) && ((power >> i) &1)) {
if (light_type && (Settings.light_dimmer == nvalue) && ((power >> i) &1)) {
return 1;
}
snprintf_P(topicBuf, stopicBuf, PSTR("/" D_CMND_DIMMER));

View File

@ -276,7 +276,7 @@ boolean IrSendCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_l
boolean error = false;
char dataBufUc[data_len];
const char *protocol;
uint8_t bits = 0;
uint32_t bits = 0;
uint32_t data = 0;
const char *HVAC_Mode;
@ -316,7 +316,7 @@ boolean IrSendCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_l
else if (!strcasecmp_P(protocol, PSTR("SAMSUNG")))
irsend->sendSAMSUNG(data, bits);
else if (!strcasecmp_P(protocol, PSTR("PANASONIC")))
irsend->sendPanasonic(data, bits);
irsend->sendPanasonic(bits, data);
else {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_PROTOCOL_NOT_SUPPORTED "\"}"));
}

View File

@ -32,7 +32,7 @@
* 12 AiLight RGBW no
* 13 Sonoff B1 RGBCW yes
*
* led_scheme WS2812 Others Effect
* light_scheme WS2812 Others Effect
* 0 yes yes Color On/Off
* 1 yes yes Wakeup light
* 2 yes no Clock
@ -167,7 +167,7 @@ void LightInit(void)
Settings.pwm_value[i] = 0; // Disable direct PWM control
}
if (LT_PWM1 == light_type) {
Settings.led_color[0] = 255; // One PWM channel only supports Dimmer but needs max color
Settings.light_color[0] = 255; // One PWM channel only supports Dimmer but needs max color
}
if (SONOFF_LED == Settings.module) { // Fix Sonoff Led instabilities
if (!my_module.gp.io[4]) {
@ -187,7 +187,7 @@ void LightInit(void)
#ifdef USE_WS2812 // ************************************************************************
else if (LT_WS2812 == light_type) {
Ws2812Init();
max_scheme += 8;
max_scheme = LS_MAX +7;
}
#endif // USE_WS2812 ************************************************************************
else {
@ -202,11 +202,13 @@ void LightInit(void)
LightMy92x1Init();
}
if ((LS_WAKEUP == Settings.led_scheme) || (Settings.led_scheme > max_scheme)) {
Settings.led_scheme = LS_POWER;
}
light_subtype = light_type &7;
if (light_subtype < LST_RGB) {
max_scheme = LS_POWER;
}
if ((LS_WAKEUP == Settings.light_scheme) || (Settings.light_scheme > max_scheme)) {
Settings.light_scheme = LS_POWER;
}
light_power = 0;
light_update = 1;
light_wakeup_active = 0;
@ -226,14 +228,14 @@ void LightSetColorTemp(uint16_t ct)
uint16_t icold = (100 * (347 - my_ct)) / 136;
uint16_t iwarm = (100 * my_ct) / 136;
if (LST_RGBWC == light_subtype) {
Settings.led_color[0] = 0;
Settings.led_color[1] = 0;
Settings.led_color[2] = 0;
Settings.led_color[3] = (uint8_t)icold;
Settings.led_color[4] = (uint8_t)iwarm;
Settings.light_color[0] = 0;
Settings.light_color[1] = 0;
Settings.light_color[2] = 0;
Settings.light_color[3] = (uint8_t)icold;
Settings.light_color[4] = (uint8_t)iwarm;
} else {
Settings.led_color[0] = (uint8_t)icold;
Settings.led_color[1] = (uint8_t)iwarm;
Settings.light_color[0] = (uint8_t)icold;
Settings.light_color[1] = (uint8_t)iwarm;
}
}
@ -243,11 +245,11 @@ uint16_t LightGetColorTemp()
if (LST_RGBWC == light_subtype) {
ct_idx = 3;
}
uint16_t my_ct = Settings.led_color[ct_idx +1];
uint16_t my_ct = Settings.light_color[ct_idx +1];
if (my_ct > 0) {
return ((my_ct * 136) / 100) + 154;
} else {
my_ct = Settings.led_color[ct_idx];
my_ct = Settings.light_color[ct_idx];
return 499 - ((my_ct * 136) / 100);
}
}
@ -261,7 +263,7 @@ void LightSetDimmer(uint8_t myDimmer)
}
float dimmer = 100 / (float)myDimmer;
for (byte i = 0; i < light_subtype; i++) {
temp = (float)Settings.led_color[i] / dimmer;
temp = (float)Settings.light_color[i] / dimmer;
light_current_color[i] = (uint8_t)temp;
}
}
@ -276,17 +278,17 @@ void LightSetColor()
}
}
float mDim = (float)highest / 2.55;
Settings.led_dimmer = (uint8_t)mDim;
Settings.light_dimmer = (uint8_t)mDim;
float dimmer = 100 / mDim;
for (byte i = 0; i < light_subtype; i++) {
float temp = (float)light_current_color[i] * dimmer;
Settings.led_color[i] = (uint8_t)temp;
Settings.light_color[i] = (uint8_t)temp;
}
}
char* LightGetColor(uint8_t type, char* scolor)
{
LightSetDimmer(Settings.led_dimmer);
LightSetDimmer(Settings.light_dimmer);
scolor[0] = '\0';
for (byte i = 0; i < light_subtype; i++) {
if (!type && Settings.flag.decimal_text) {
@ -300,7 +302,7 @@ char* LightGetColor(uint8_t type, char* scolor)
void LightPowerOn()
{
if (Settings.led_dimmer && !(light_power)) {
if (Settings.light_dimmer && !(light_power)) {
ExecuteCommandPower(devices_present, 1);
}
}
@ -310,10 +312,10 @@ void LightPreparePower()
char scolor[25];
char scommand[16];
if (Settings.led_dimmer && !(light_power)) {
if (Settings.light_dimmer && !(light_power)) {
ExecuteCommandPower(devices_present, 7); // No publishPowerState
}
else if (!Settings.led_dimmer && light_power) {
else if (!Settings.light_dimmer && light_power) {
ExecuteCommandPower(devices_present, 6); // No publishPowerState
}
#ifdef USE_DOMOTICZ
@ -324,23 +326,23 @@ void LightPreparePower()
GetPowerDevice(scommand, devices_present, sizeof(scommand));
if (light_subtype > LST_SINGLE) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"%s\", \"" D_CMND_DIMMER "\":%d, \"" D_CMND_COLOR "\":\"%s\"}"),
scommand, GetStateText(light_power), Settings.led_dimmer, LightGetColor(0, scolor));
scommand, GetStateText(light_power), Settings.light_dimmer, LightGetColor(0, scolor));
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"%s\", \"" D_CMND_DIMMER "\":%d}"),
scommand, GetStateText(light_power), Settings.led_dimmer);
scommand, GetStateText(light_power), Settings.light_dimmer);
}
}
void LightFade()
{
if (0 == Settings.led_fade) {
if (0 == Settings.light_fade) {
for (byte i = 0; i < light_subtype; i++) {
light_new_color[i] = light_current_color[i];
}
} else {
uint8_t shift = Settings.led_speed;
if (Settings.led_speed > 6) {
shift = (strip_timer_counter % (Settings.led_speed -6)) ? 0 : 8;
uint8_t shift = Settings.light_speed;
if (Settings.light_speed > 6) {
shift = (strip_timer_counter % (Settings.light_speed -6)) ? 0 : 8;
}
if (shift) {
for (byte i = 0; i < light_subtype; i++) {
@ -377,7 +379,7 @@ void LightWheel(uint8_t wheel_pos)
}
light_entry_color[3] = 0;
light_entry_color[4] = 0;
float dimmer = 100 / (float)Settings.led_dimmer;
float dimmer = 100 / (float)Settings.light_dimmer;
for (byte i = 0; i < LST_RGB; i++) {
float temp = (float)light_entry_color[i] / dimmer;
light_entry_color[i] = (uint8_t)temp;
@ -386,7 +388,7 @@ void LightWheel(uint8_t wheel_pos)
void LightCycleColor(int8_t direction)
{
if (strip_timer_counter % (Settings.led_speed * 2)) {
if (strip_timer_counter % (Settings.light_speed * 2)) {
return;
}
light_wheel += direction;
@ -425,20 +427,36 @@ void LightSetPower(uint8_t mpower)
void LightAnimate()
{
uint8_t cur_col[5];
uint16_t light_still_on;
strip_timer_counter++;
if (!light_power) { // Power Off
sleep = Settings.sleep;
strip_timer_counter = 0;
for (byte i = 0; i < light_subtype; i++) {
light_new_color[i] = 0;
light_still_on += light_new_color[i];
}
if (light_still_on && Settings.light_fade) {
uint8_t speed = Settings.light_speed;
if (speed > 6) {
speed = 6;
}
for (byte i = 0; i < light_subtype; i++) {
if (light_new_color[i] > 0) {
light_new_color[i] -= (light_new_color[i] >> speed) +1;
}
}
} else {
for (byte i = 0; i < light_subtype; i++) {
light_new_color[i] = 0;
}
}
}
else {
sleep = 0;
switch (Settings.led_scheme) {
switch (Settings.light_scheme) {
case LS_POWER:
LightSetDimmer(Settings.led_dimmer);
LightSetDimmer(Settings.light_dimmer);
LightFade();
break;
case LS_WAKEUP:
@ -451,10 +469,10 @@ void LightAnimate()
light_wakeup_dimmer = 0;
}
light_wakeup_counter++;
if (light_wakeup_counter > ((Settings.led_wakeup * STATES) / Settings.led_dimmer)) {
if (light_wakeup_counter > ((Settings.light_wakeup * STATES) / Settings.light_dimmer)) {
light_wakeup_counter = 0;
light_wakeup_dimmer++;
if (light_wakeup_dimmer <= Settings.led_dimmer) {
if (light_wakeup_dimmer <= Settings.light_dimmer) {
LightSetDimmer(light_wakeup_dimmer);
for (byte i = 0; i < light_subtype; i++) {
light_new_color[i] = light_current_color[i];
@ -463,7 +481,7 @@ void LightAnimate()
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WAKEUP "\":\"" D_DONE "\"}"));
MqttPublishPrefixTopic_P(2, PSTR(D_CMND_WAKEUP));
light_wakeup_active = 0;
Settings.led_scheme = LS_POWER;
Settings.light_scheme = LS_POWER;
}
}
break;
@ -479,13 +497,13 @@ void LightAnimate()
#ifdef USE_WS2812 // ************************************************************************
default:
if (LT_WS2812 == light_type) {
Ws2812ShowScheme(Settings.led_scheme -LS_MAX);
Ws2812ShowScheme(Settings.light_scheme -LS_MAX);
}
#endif // USE_WS2812 ************************************************************************
}
}
if ((Settings.led_scheme < LS_MAX) || !light_power) {
if ((Settings.light_scheme < LS_MAX) || !light_power) {
for (byte i = 0; i < light_subtype; i++) {
if (light_last_color[i] != light_new_color[i]) {
light_update = 1;
@ -495,7 +513,7 @@ void LightAnimate()
light_update = 0;
for (byte i = 0; i < light_subtype; i++) {
light_last_color[i] = light_new_color[i];
cur_col[i] = (Settings.led_table) ? ledTable[light_last_color[i]] : light_last_color[i];
cur_col[i] = (Settings.light_correction) ? ledTable[light_last_color[i]] : light_last_color[i];
if (light_type < LT_PWM6) {
if (pin[GPIO_PWM1 +i] < 99) {
uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255);
@ -527,7 +545,7 @@ float light_brightness = 0.0;
void LightRgbToHsb()
{
LightSetDimmer(Settings.led_dimmer);
LightSetDimmer(Settings.light_dimmer);
// convert colors to float between (0.0 - 1.0)
float r = light_current_color[0] / 255.0f;
@ -632,8 +650,8 @@ void LightReplaceHsb(String *response)
} else {
response->replace("{h}", "0");
response->replace("{s}", "0");
// response->replace("{b}", String((uint8_t)(2.54f * (float)Settings.led_dimmer)));
response->replace("{b}", String((uint8_t)(0.01f * (float)Settings.led_dimmer)));
// response->replace("{b}", String((uint8_t)(2.54f * (float)Settings.light_dimmer)));
response->replace("{b}", String((uint8_t)(0.01f * (float)Settings.light_dimmer)));
}
}
@ -647,8 +665,8 @@ void LightGetHsb(float *hue, float *sat, float *bri)
} else {
*hue = 0;
*sat = 0;
// *bri = (2.54f * (float)Settings.led_dimmer);
*bri = (0.01f * (float)Settings.led_dimmer);
// *bri = (2.54f * (float)Settings.light_dimmer);
*bri = (0.01f * (float)Settings.light_dimmer);
}
}
@ -668,7 +686,7 @@ void LightSetHsb(float hue, float sat, float bri, uint16_t ct)
MqttPublishPrefixTopic_P(5, PSTR(D_CMND_COLOR));
} else {
uint8_t tmp = (uint8_t)(bri * 100);
Settings.led_dimmer = tmp;
Settings.light_dimmer = tmp;
if (LST_COLDWARM == light_subtype) {
if (ct > 0) {
LightSetColorTemp(ct);
@ -719,6 +737,8 @@ boolean LightColorEntry(char *buffer, uint8_t buffer_length)
return (entry_type);
}
/********************************************************************************************/
boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len, int16_t payload)
{
boolean serviced = true;
@ -736,6 +756,7 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
// }
memcpy(light_current_color, light_entry_color, sizeof(light_current_color));
LightSetColor();
Settings.light_scheme = 0;
coldim = true;
} else { // Color2, 3 and 4
for (byte i = 0; i < LST_RGB; i++) {
@ -760,7 +781,7 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
}
}
#ifdef USE_WS2812 // ***********************************************************************
else if ((LT_WS2812 == light_type) && !strcasecmp_P(type, PSTR(D_CMND_LED)) && (index > 0) && (index <= Settings.led_pixels)) {
else if ((LT_WS2812 == light_type) && !strcasecmp_P(type, PSTR(D_CMND_LED)) && (index > 0) && (index <= Settings.light_pixels)) {
if (data_len > 0) {
if (LightColorEntry(dataBuf, data_len)) {
Ws2812SetColor(index, light_entry_color[0], light_entry_color[1], light_entry_color[2]);
@ -770,18 +791,18 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
}
else if ((LT_WS2812 == light_type) && !strcasecmp_P(type, PSTR(D_CMND_PIXELS))) {
if ((payload > 0) && (payload <= WS2812_MAX_LEDS)) {
Settings.led_pixels = payload;
Settings.light_pixels = payload;
Ws2812Clear();
light_update = 1;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_PIXELS "\":%d}"), Settings.led_pixels);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_PIXELS "\":%d}"), Settings.light_pixels);
}
else if ((LT_WS2812 == light_type) && !strcasecmp_P(type, PSTR(D_CMND_WIDTH)) && (index > 0) && (index <= 4)) {
if (1 == index) {
if ((payload >= 0) && (payload <= 4)) {
Settings.led_width = payload;
Settings.light_width = payload;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WIDTH "\":%d}"), Settings.led_width);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WIDTH "\":%d}"), Settings.light_width);
} else {
if ((payload > 0) && (payload < 32)) {
Settings.ws_width[index -2] = payload;
@ -790,30 +811,24 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
}
}
#endif // USE_WS2812 ************************************************************************
else if (!strcasecmp_P(type, PSTR(D_CMND_SCHEME))) {
uint8_t max_scheme = LS_WAKEUP;
if (light_subtype >= LST_RGB) {
max_scheme = LS_MAX -1;
}
if (LT_WS2812 == light_type) {
max_scheme += 8;
}
else if ((light_subtype >= LST_RGB) && !strcasecmp_P(type, PSTR(D_CMND_SCHEME))) {
uint8_t max_scheme = (LT_WS2812 == light_type) ? LS_MAX +7 : LS_MAX -1;
if ((payload >= 0) && (payload <= max_scheme)) {
Settings.led_scheme = payload;
if (LS_WAKEUP == Settings.led_scheme) {
Settings.light_scheme = payload;
if (LS_WAKEUP == Settings.light_scheme) {
light_wakeup_active = 3;
}
LightPowerOn();
strip_timer_counter = 0;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_SCHEME "\":%d}"), Settings.led_scheme);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_SCHEME "\":%d}"), Settings.light_scheme);
}
else if (!strcasecmp_P(type, PSTR(D_CMND_WAKEUP))) {
if ((payload >= 0) && (payload <= 100)) {
Settings.led_dimmer = payload;
Settings.light_dimmer = payload;
}
light_wakeup_active = 3;
Settings.led_scheme = LS_WAKEUP;
Settings.light_scheme = LS_WAKEUP;
LightPowerOn();
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WAKEUP "\":\"" D_STARTED "\"}"));
}
@ -827,10 +842,10 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
}
else if (!strcasecmp_P(type, PSTR(D_CMND_DIMMER))) {
if ((payload >= 0) && (payload <= 100)) {
Settings.led_dimmer = payload;
Settings.light_dimmer = payload;
coldim = true;
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_DIMMER "\":%d}"), Settings.led_dimmer);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_DIMMER "\":%d}"), Settings.light_dimmer);
}
}
else if (!strcasecmp_P(type, PSTR(D_CMND_LEDTABLE))) {
@ -838,46 +853,46 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le
switch (payload) {
case 0: // Off
case 1: // On
Settings.led_table = payload;
Settings.light_correction = payload;
break;
case 2: // Toggle
Settings.led_table ^= 1;
Settings.light_correction ^= 1;
break;
}
light_update = 1;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_LEDTABLE "\":\"%s\"}"), GetStateText(Settings.led_table));
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_LEDTABLE "\":\"%s\"}"), GetStateText(Settings.light_correction));
}
else if (!strcasecmp_P(type, PSTR(D_CMND_FADE))) {
switch (payload) {
case 0: // Off
case 1: // On
Settings.led_fade = payload;
Settings.light_fade = payload;
break;
case 2: // Toggle
Settings.led_fade ^= 1;
Settings.light_fade ^= 1;
break;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_FADE "\":\"%s\"}"), GetStateText(Settings.led_fade));
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_FADE "\":\"%s\"}"), GetStateText(Settings.light_fade));
}
else if (!strcasecmp_P(type, PSTR(D_CMND_SPEED))) { // 1 - fast, 20 - very slow
if ((payload > 0) && (payload <= STATES)) {
Settings.led_speed = payload;
Settings.light_speed = payload;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_SPEED "\":%d}"), Settings.led_speed);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_SPEED "\":%d}"), Settings.light_speed);
}
else if (!strcasecmp_P(type, PSTR(D_CMND_WAKEUPDURATION))) {
if ((payload > 0) && (payload < 3001)) {
Settings.led_wakeup = payload;
Settings.light_wakeup = payload;
light_wakeup_active = 0;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WAKEUPDURATION "\":%d}"), Settings.led_wakeup);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WAKEUPDURATION "\":%d}"), Settings.light_wakeup);
}
else if (!strcasecmp_P(type, PSTR("UNDOCA"))) { // Theos legacy status
LightGetColor(1, scolor);
scolor[6] = '\0'; // RGB only
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, %d, %d, %d, %d, %d"),
scolor, Settings.led_fade, Settings.led_table, Settings.led_scheme, Settings.led_speed, Settings.led_width);
scolor, Settings.light_fade, Settings.light_correction, Settings.light_scheme, Settings.light_speed, Settings.light_width);
MqttPublishPrefixTopic_P(1, type);
mqtt_data[0] = '\0';
}

View File

@ -84,8 +84,8 @@ void Ws2812StripShow()
{
RgbColor c;
if (Settings.led_table) {
for (uint16_t i = 0; i < Settings.led_pixels; i++) {
if (Settings.light_correction) {
for (uint16_t i = 0; i < Settings.light_pixels; i++) {
c = strip->GetPixelColor(i);
strip->SetPixelColor(i, RgbColor(ledTable[c.R], ledTable[c.G], ledTable[c.B]));
}
@ -108,10 +108,10 @@ void Ws2812UpdatePixelColor(int position, struct RgbColor hand_color, uint8_t ha
{
RgbColor color;
uint16_t mod_position = mod(position, (int)Settings.led_pixels);
uint16_t mod_position = mod(position, (int)Settings.light_pixels);
color = strip->GetPixelColor(mod_position);
float dimmer = 100 / (float)Settings.led_dimmer;
float dimmer = 100 / (float)Settings.light_dimmer;
uint8_t offset = 1 << hand;
color.R = cmin(color.R + ((hand_color.R / dimmer) / offset), 255);
color.G = cmin(color.G + ((hand_color.G / dimmer) / offset), 255);
@ -122,7 +122,7 @@ void Ws2812UpdatePixelColor(int position, struct RgbColor hand_color, uint8_t ha
void Ws2812UpdateHand(int position, uint8_t index)
{
if (Settings.flag.ws_clock_reverse) {
position = Settings.led_pixels -position;
position = Settings.light_pixels -position;
}
RgbColor hand_color = RgbColor(Settings.ws_color[index][WS_RED], Settings.ws_color[index][WS_GREEN], Settings.ws_color[index][WS_BLUE]);
@ -136,7 +136,7 @@ void Ws2812UpdateHand(int position, uint8_t index)
void Ws2812Clock()
{
strip->ClearTo(0); // Reset strip
int clksize = 600 / (int)Settings.led_pixels;
int clksize = 600 / (int)Settings.light_pixels;
Ws2812UpdateHand((RtcTime.second * 10) / clksize, WS_SECOND);
Ws2812UpdateHand((RtcTime.minute * 10) / clksize, WS_MINUTE);
Ws2812UpdateHand((RtcTime.hour % 12) * (50 / clksize), WS_HOUR);
@ -159,7 +159,7 @@ void Ws2812GradientColor(uint8_t schemenr, struct WsColor* mColor, uint16_t rang
start = (scheme.count -1) - start;
end = (scheme.count -1) - end;
}
float dimmer = 100 / (float)Settings.led_dimmer;
float dimmer = 100 / (float)Settings.light_dimmer;
float fmyRed = (float)map(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].red, scheme.colors[end].red) / dimmer;
float fmyGrn = (float)map(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].green, scheme.colors[end].green) / dimmer;
float fmyBlu = (float)map(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].blue, scheme.colors[end].blue) / dimmer;
@ -182,20 +182,20 @@ void Ws2812Gradient(uint8_t schemenr)
return;
}
uint8_t repeat = kRepeat[Settings.led_width]; // number of scheme.count per ledcount
uint16_t range = (uint16_t)ceil((float)Settings.led_pixels / (float)repeat);
uint8_t repeat = kRepeat[Settings.light_width]; // number of scheme.count per ledcount
uint16_t range = (uint16_t)ceil((float)Settings.light_pixels / (float)repeat);
uint16_t gradRange = (uint16_t)ceil((float)range / (float)(scheme.count - 1));
uint16_t speed = ((Settings.led_speed * 2) -1) * (STATES / 10);
uint16_t speed = ((Settings.light_speed * 2) -1) * (STATES / 10);
uint16_t offset = speed > 0 ? strip_timer_counter / speed : 0;
WsColor oldColor, currentColor;
Ws2812GradientColor(schemenr, &oldColor, range, gradRange, offset);
currentColor = oldColor;
for (uint16_t i = 0; i < Settings.led_pixels; i++) {
if (kRepeat[Settings.led_width] > 1) {
for (uint16_t i = 0; i < Settings.light_pixels; i++) {
if (kRepeat[Settings.light_width] > 1) {
Ws2812GradientColor(schemenr, &currentColor, range, gradRange, i +offset);
}
if (Settings.led_speed > 0) {
if (Settings.light_speed > 0) {
// Blend old and current color based on time for smooth movement.
c.R = map(strip_timer_counter % speed, 0, speed, oldColor.red, currentColor.red);
c.G = map(strip_timer_counter % speed, 0, speed, oldColor.green, currentColor.green);
@ -225,17 +225,17 @@ void Ws2812Bars(uint8_t schemenr)
ColorScheme scheme = kSchemes[schemenr];
uint16_t maxSize = Settings.led_pixels / scheme.count;
if (kWidth[Settings.led_width] > maxSize) {
uint16_t maxSize = Settings.light_pixels / scheme.count;
if (kWidth[Settings.light_width] > maxSize) {
maxSize = 0;
}
uint16_t speed = ((Settings.led_speed * 2) -1) * (STATES / 10);
uint16_t speed = ((Settings.light_speed * 2) -1) * (STATES / 10);
uint8_t offset = speed > 0 ? strip_timer_counter / speed : 0;
WsColor mcolor[scheme.count];
memcpy(mcolor, scheme.colors, sizeof(mcolor));
float dimmer = 100 / (float)Settings.led_dimmer;
float dimmer = 100 / (float)Settings.light_dimmer;
for (i = 0; i < scheme.count; i++) {
float fmyRed = (float)mcolor[i].red / dimmer;
float fmyGrn = (float)mcolor[i].green / dimmer;
@ -245,9 +245,9 @@ void Ws2812Bars(uint8_t schemenr)
mcolor[i].blue = (uint8_t)fmyBlu;
}
uint8_t colorIndex = offset % scheme.count;
for (i = 0; i < Settings.led_pixels; i++) {
for (i = 0; i < Settings.light_pixels; i++) {
if (maxSize) {
colorIndex = ((i + offset) % (scheme.count * kWidth[Settings.led_width])) / kWidth[Settings.led_width];
colorIndex = ((i + offset) % (scheme.count * kWidth[Settings.light_width])) / kWidth[Settings.light_width];
}
c.R = mcolor[colorIndex].red;
c.G = mcolor[colorIndex].green;
@ -297,7 +297,7 @@ void Ws2812SetColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue)
strip->SetPixelColor(led -1, lcolor); // Led 1 is strip Led 0 -> substract offset 1
} else {
// strip->ClearTo(lcolor); // Set WS2812_MAX_LEDS pixels
for (uint16_t i = 0; i < Settings.led_pixels; i++) {
for (uint16_t i = 0; i < Settings.light_pixels; i++) {
strip->SetPixelColor(i, lcolor);
}
}
@ -334,7 +334,7 @@ void Ws2812ShowScheme(uint8_t scheme)
}
break;
default:
if (1 == Settings.led_fade) {
if (1 == Settings.light_fade) {
Ws2812Gradient(scheme -1);
} else {
Ws2812Bars(scheme -1);