From 473362cbee37eda055b7ec3f410129665cf849c9 Mon Sep 17 00:00:00 2001 From: Scoobler Date: Fri, 30 Oct 2020 13:49:36 +0000 Subject: [PATCH 1/6] Added DimmerStep to allow the change of the Dimmer Auto (+/-) Step value Signed-off-by: Scoobler --- tasmota/i18n.h | 1 + tasmota/settings.h | 5 +++-- tasmota/settings.ino | 2 ++ tasmota/tasmota_globals.h | 3 +++ tasmota/xdrv_04_light.ino | 31 +++++++++++++++++++++++++------ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 4a2a03281..8bcd461ee 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -421,6 +421,7 @@ #define D_CMND_COLORTEMPERATURE "CT" #define D_CMND_DIMMER "Dimmer" #define D_CMND_DIMMER_RANGE "DimmerRange" +#define D_CMND_DIMMER_STEP "DimmerStep" #define D_CMND_HSBCOLOR "HSBColor" #define D_CMND_LED "Led" #define D_CMND_LEDTABLE "LedTable" diff --git a/tasmota/settings.h b/tasmota/settings.h index d2227d050..044773115 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -635,8 +635,9 @@ struct { uint8_t shutter_mode; // F43 uint16_t energy_power_delta[3]; // F44 uint16_t shutter_pwmrange[2][MAX_SHUTTERS]; // F4A - - uint8_t free_f5a[89]; // F5A Decrement if adding new Setting variables just above and below + uint8_t dimmer_step; // F5A + + uint8_t free_f5b[88]; // F5B - Decrement if adding new Setting variables just above and below // Only 32 bit boundary variables below SysBitfield5 flag5; // FB4 diff --git a/tasmota/settings.ino b/tasmota/settings.ino index c1aa605e1..5ee75c2ce 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -1015,6 +1015,8 @@ void SettingsDefaultSet2(void) Settings.dimmer_hw_max = DEFAULT_DIMMER_MAX; Settings.dimmer_hw_min = DEFAULT_DIMMER_MIN; + Settings.dimmer_step = DEFAULT_DIMMER_STEP; + // Display // Settings.display_model = 0; Settings.display_mode = 1; diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index fa6a4f9fc..cfb5315b7 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -219,6 +219,9 @@ String EthernetMacAddress(void); #ifndef DEFAULT_DIMMER_MIN #define DEFAULT_DIMMER_MIN 0 #endif +#ifndef DEFAULT_DIMMER_STEP +#define DEFAULT_DIMMER_STEP 10 +#endif #ifndef DEFAULT_LIGHT_DIMMER #define DEFAULT_LIGHT_DIMMER 10 #endif diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index fb6f06dd2..04c051d8b 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -129,7 +129,7 @@ enum LightSchemes { LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_M const uint8_t LIGHT_COLOR_SIZE = 25; // Char array scolor size const char kLightCommands[] PROGMEM = "|" // No prefix - D_CMND_COLOR "|" D_CMND_COLORTEMPERATURE "|" D_CMND_DIMMER "|" D_CMND_DIMMER_RANGE "|" D_CMND_LEDTABLE "|" D_CMND_FADE "|" + D_CMND_COLOR "|" D_CMND_COLORTEMPERATURE "|" D_CMND_DIMMER "|" D_CMND_DIMMER_RANGE "|" D_CMND_DIMMER_STEP "|" D_CMND_LEDTABLE "|" D_CMND_FADE "|" D_CMND_RGBWWTABLE "|" D_CMND_SCHEME "|" D_CMND_SPEED "|" D_CMND_WAKEUP "|" D_CMND_WAKEUPDURATION "|" D_CMND_WHITE "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR #ifdef USE_LIGHT_PALETTE @@ -141,7 +141,7 @@ const char kLightCommands[] PROGMEM = "|" // No prefix "|UNDOCA" ; void (* const LightCommand[])(void) PROGMEM = { - &CmndColor, &CmndColorTemperature, &CmndDimmer, &CmndDimmerRange, &CmndLedTable, &CmndFade, + &CmndColor, &CmndColorTemperature, &CmndDimmer, &CmndDimmerRange, &CmndDimmerStep, &CmndLedTable, &CmndFade, &CmndRgbwwTable, &CmndScheme, &CmndSpeed, &CmndWakeup, &CmndWakeupDuration, &CmndWhite, &CmndChannel, &CmndHsbColor, #ifdef USE_LIGHT_PALETTE @@ -2829,8 +2829,8 @@ void CmndDimmer(void) // Dimmer1 0..100 - Change RGB Dimmer // Dimmer2 0..100 - Change W(W) Dimmer // Dimmer3 0..100 - Change both RGB and W(W) Dimmers with no fading - // Dimmer + - Incerement Dimmer in steps of 10 - // Dimmer - - Decrement Dimmer in steps of 10 + // Dimmer + - Incerement Dimmer in steps of DimmerStep + // Dimmer - - Decrement Dimmer in steps of DimmerStep uint32_t dimmer; if (XdrvMailbox.index == 3) { TasmotaGlobal.skip_light_fade = true; @@ -2848,9 +2848,9 @@ void CmndDimmer(void) // Handle +/- special command if (1 == XdrvMailbox.data_len) { if ('+' == XdrvMailbox.data[0]) { - XdrvMailbox.payload = (dimmer > 89) ? 100 : dimmer + 10; + XdrvMailbox.payload = (dimmer > (100 - Settings.dimmer_step - 1)) ? 100 : dimmer + Settings.dimmer_step; } else if ('-' == XdrvMailbox.data[0]) { - XdrvMailbox.payload = (dimmer < 11) ? 1 : dimmer - 10; + XdrvMailbox.payload = (dimmer < (Settings.dimmer_step + 1)) ? 1 : dimmer - Settings.dimmer_step; } } // If value is ok, change it, otherwise report old value @@ -2907,6 +2907,25 @@ void CmndDimmerRange(void) Response_P(PSTR("{\"" D_CMND_DIMMER_RANGE "\":{\"Min\":%d,\"Max\":%d}}"), Settings.dimmer_hw_min, Settings.dimmer_hw_max); } +void CmndDimmerStep(void) +{ + // DimmerStep - Show current dimmer step as used by Dimmer +/- + // DimmerStep - Set dimmer step + if (XdrvMailbox.data_len > 0) { + uint32_t parm[1]; + parm[0] = Settings.dimmer_step; + ParseParameters(1, parm); + if (parm[0] < 1) { + Settings.dimmer_step = 1; + } else if (parm[0] > 10) { + Settings.dimmer_step = 10; + } else { + Settings.dimmer_step = parm[0]; + } + } + Response_P(PSTR("{\"" D_CMND_DIMMER_STEP "\":%d}"), Settings.dimmer_step); + + void CmndLedTable(void) { // LedTable - Show current LedTable state From b8abc8300c8390bab98aa673fe8470e571c4b92a Mon Sep 17 00:00:00 2001 From: James Turton Date: Wed, 4 Nov 2020 11:02:34 +0100 Subject: [PATCH 2/6] Allow to be between 1 and 50. --- tasmota/xdrv_04_light.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 04c051d8b..17cc46e17 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2910,21 +2910,21 @@ void CmndDimmerRange(void) void CmndDimmerStep(void) { // DimmerStep - Show current dimmer step as used by Dimmer +/- - // DimmerStep - Set dimmer step + // DimmerStep 1..50 - Set dimmer step if (XdrvMailbox.data_len > 0) { uint32_t parm[1]; parm[0] = Settings.dimmer_step; ParseParameters(1, parm); if (parm[0] < 1) { Settings.dimmer_step = 1; - } else if (parm[0] > 10) { - Settings.dimmer_step = 10; + } else if (parm[0] > 50) { + Settings.dimmer_step = 50; } else { Settings.dimmer_step = parm[0]; } } Response_P(PSTR("{\"" D_CMND_DIMMER_STEP "\":%d}"), Settings.dimmer_step); - +} void CmndLedTable(void) { From 2d03bb3672be2c8b2aed98bb352c436277d52a90 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 4 Nov 2020 17:30:09 +0100 Subject: [PATCH 3/6] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3211e2985..96c63651b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ build build_output firmware.map firmware.asm -tasmota.ino.cpp +tasmota/tasmota.ino.cpp tasmota*.bin tasmota*.bin.gz tasmota*.map From 78196f03910e94cd26c96bde578e8ebcc2736656 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 4 Nov 2020 17:42:30 +0100 Subject: [PATCH 4/6] Removed auto output selection Removed auto output selection of decimal or hexadecimal data based on user input. Now only based on ``SetOption17`` --- CHANGELOG.md | 3 +++ RELEASENOTES.md | 1 + tasmota/xdrv_04_light.ino | 9 ++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2cbe6fd6..5c1018102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,9 @@ All notable changes to this project will be documented in this file. - Rule handling of JSON ``null`` regression from v8.5.0.1 (#9685) - Arilux RF remote detection regression from v8.3.0 +### Removed +- Auto output selection of decimal or hexadecimal data based on user input. Now only based on ``SetOption17`` + ## [9.0.0.2] - 20201025 ### Added - Support for Vietnamese language translations by Tâm.NT diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a8ed1e970..1a8731a89 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -133,3 +133,4 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Support for direct upgrade from Tasmota versions before v7.0 - Support for downgrade to versions before 9.0 keeping current GPIO configuration - Auto config update for all Friendlynames and Switchtopic from Tasmota versions before v8.0 +- Auto output selection of decimal or hexadecimal data based on user input. Now only based on ``SetOption17`` diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 5f8491dc0..d91666992 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2556,9 +2556,12 @@ bool LightColorEntry(char *buffer, uint32_t buffer_length) entry_type = 1; // Hexadecimal } } - if (entry_type) { - Settings.flag.decimal_text = entry_type -1; // SetOption17 - Switch between decimal or hexadecimal output - } + +// Too much magic so removed since 9.0.0.3 +// if (entry_type) { +// Settings.flag.decimal_text = entry_type -1; // SetOption17 - Switch between decimal or hexadecimal output +// } + return (entry_type); } From c93bfd15bfefeecab5ea4098f165fba290babc10 Mon Sep 17 00:00:00 2001 From: James Turton Date: Wed, 4 Nov 2020 19:05:19 +0100 Subject: [PATCH 5/6] Updated `CmndDimmerStep()`. --- tasmota/xdrv_04_light.ino | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 17cc46e17..11fd178fb 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2912,18 +2912,15 @@ void CmndDimmerStep(void) // DimmerStep - Show current dimmer step as used by Dimmer +/- // DimmerStep 1..50 - Set dimmer step if (XdrvMailbox.data_len > 0) { - uint32_t parm[1]; - parm[0] = Settings.dimmer_step; - ParseParameters(1, parm); - if (parm[0] < 1) { - Settings.dimmer_step = 1; - } else if (parm[0] > 50) { - Settings.dimmer_step = 50; + if (XdrvMailbox.payload < 1) { + Settings.dimmer_step = 1; + } else if (XdrvMailbox.payload > 50) { + Settings.dimmer_step = 50; } else { - Settings.dimmer_step = parm[0]; + Settings.dimmer_step = XdrvMailbox.payload; } } - Response_P(PSTR("{\"" D_CMND_DIMMER_STEP "\":%d}"), Settings.dimmer_step); + ResponseCmndNumber(Settings.dimmer_step); } void CmndLedTable(void) From 4d8fab75a843d9fc2dcd4491934e5d69192dd526 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 5 Nov 2020 10:01:15 +0100 Subject: [PATCH 6/6] Add command ``DimmerStep 1..50`` Add command ``DimmerStep 1..50`` to change default dimmer up and down step of 10% by James Turton (#9733) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1018102..91ae263bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. - Command ``Gpios 255`` to show all possible GPIO configurations - Command ``SwitchText`` to change JSON switch names by barbudor (#9691) - Command ``SetOption114 1`` to detach Switches from Relays and enable MQTT action state for all the SwitchModes returning `{"Switch1":{"Action":"ON"}}` +- Command ``DimmerStep 1..50`` to change default dimmer up and down step of 10% by James Turton (#9733) - HM10 Beacon support and refactoring by Christian Baars (#9702) - Support for Hass discovery of TuyaMcu and Sonoff Ifan by Federico Leoni (#9727) - Initial support for iBeacons (Sensor52) on ESP32 using internal BLE by rvbglas (#9732) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 1a8731a89..bee5835e9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -59,6 +59,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ## Changelog v9.0.0.3 ### Added +- Command ``DimmerStep 1..50`` to change default dimmer up and down step of 10% by James Turton (#9733) - Command ``Gpios 255`` to show all possible GPIO configurations - Command ``NoDelay`` for immediate backlog command execution by Erik Montnemery (#9544) - Command ``ShutterChange`` to increment change position (#9594)