From 012c3818a59cd46cc89e2affc5ddcdea427a17c1 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 6 Feb 2021 05:53:52 +0300 Subject: [PATCH] tuya: send channel value directly --- code/espurna/light.h | 2 +- code/espurna/tuya.cpp | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/code/espurna/light.h b/code/espurna/light.h index 6caa47eb6d..2520075c46 100644 --- a/code/espurna/light.h +++ b/code/espurna/light.h @@ -75,7 +75,7 @@ class LightProvider { public: virtual void update() = 0; virtual void state(bool) = 0; - virtual void channel(unsigned char ch, double value) = 0; + virtual void channel(unsigned char ch, float value) = 0; }; struct LightTransition { diff --git a/code/espurna/tuya.cpp b/code/espurna/tuya.cpp index afb64b1f16..5389ad3647 100644 --- a/code/espurna/tuya.cpp +++ b/code/espurna/tuya.cpp @@ -139,7 +139,7 @@ namespace tuya { } } - void channel(unsigned char channel, double value) override { + void channel(unsigned char channel, float value) override { // XXX: can't handle channel values when OFF, and will turn the lights ON if (!_last_state) { return; @@ -150,18 +150,9 @@ namespace tuya { return; } - auto rounded = static_cast(value); - // input dimmer channel value when lights are OFF is 16 // for the same reason as above, don't send OFF values - constexpr unsigned int Low { 16u }; - constexpr unsigned int High { 255u }; - rounded = std::clamp(rounded, Low, High); - if (rounded == 16u) { - return; - } - - send(entry->dp_id, rounded); + send(entry->dp_id, static_cast(value)); } private: