From 0235bc0f8cb93b78b7c2dcfbca9641f30ce0c921 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Wed, 14 Aug 2019 14:52:37 +0100 Subject: [PATCH 1/2] Tuya Dimmer: Make dimmer lower limit optional. Not all Tuya dimmers have a lower limit of 10% (25) --- sonoff/settings.h | 2 +- sonoff/settings.ino | 1 + sonoff/xdrv_16_tuyadimmer.ino | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sonoff/settings.h b/sonoff/settings.h index 8af704831..11e200a99 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -82,7 +82,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t tuya_dimmer_range_255 : 1; // bit 16 (v6.6.0.1) - SetOption66 - Enable or Disable Dimmer range 255 slider control uint32_t buzzer_enable : 1; // bit 17 (v6.6.0.1) - SetOption67 - Enable buzzer when available uint32_t pwm_multi_channels : 1; // bit 18 (v6.6.0.3) - SetOption68 - Enable multi-channels PWM instead of Color PWM - uint32_t spare19 : 1; + uint32_t tuya_dimmer_min_limit : 1; // bit 19 (v6.6.0.5) - SetOption69 - Limits Tuya dimmers to minimum of 10% (25) when enabled. uint32_t spare20 : 1; uint32_t spare21 : 1; uint32_t spare22 : 1; diff --git a/sonoff/settings.ino b/sonoff/settings.ino index c94674b49..35659a543 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -890,6 +890,7 @@ void SettingsDefaultSet2(void) Settings.light_pixels = WS2812_LEDS; // Settings.light_rotation = 0; SettingsDefaultSet_5_8_1(); // Clock color + Settings.flag3.tuya_dimmer_min_limit = 1; // Display SettingsDefaultSet_5_10_1(); // Display settings diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index 362d85a3a..a1d3ec91f 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -143,7 +143,9 @@ bool TuyaSetChannels(void) void LightSerialDuty(uint8_t duty) { if (duty > 0 && !tuya_ignore_dim && TuyaSerial) { - if (duty < 25) { duty = 25; } // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself + if (Settings.flag3.tuya_dimmer_min_limit) { // Enable dimming limit SetOption69: Enabled by default + if (duty < 25) { duty = 25; } // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself + } if (Settings.flag3.tuya_show_dimmer == 0) { if(Settings.flag3.tuya_dimmer_range_255 == 0) { From 82622e1c1a379fd4793de98b17496811f38b8d2d Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 14 Aug 2019 16:41:45 +0200 Subject: [PATCH 2/2] Keep defaults --- sonoff/settings.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 35659a543..c94674b49 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -890,7 +890,6 @@ void SettingsDefaultSet2(void) Settings.light_pixels = WS2812_LEDS; // Settings.light_rotation = 0; SettingsDefaultSet_5_8_1(); // Clock color - Settings.flag3.tuya_dimmer_min_limit = 1; // Display SettingsDefaultSet_5_10_1(); // Display settings