From 00b470bc83e1094a909c68bf821df0077d8ce721 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 9 Feb 2021 23:48:45 +0300 Subject: [PATCH] lights: always check for transformation flags amend bdbd127bfbc0163474b6b20c99a2cf668e1f1f9f --- code/espurna/light.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/code/espurna/light.cpp b/code/espurna/light.cpp index e8702336..a246a9e4 100644 --- a/code/espurna/light.cpp +++ b/code/espurna/light.cpp @@ -659,7 +659,7 @@ namespace { // Gamma Correction lookup table (8 bit, ~2.2) // (note that the table could be constexpr, *but* the whole function needs to be constexpr as well) -uint8_t _lightGammaMap(unsigned char value) { +uint8_t _lightGammaMap(uint8_t value) { static uint8_t gamma[256] PROGMEM { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, @@ -722,14 +722,12 @@ public: bool target_state = state && channel.state; channel.target = target_state ? channel.value : Light::ValueMin; - if (target_state) { - if (channel.gamma) { - channel.target = _lightGammaMap(channel.target); - } + if (channel.gamma) { + channel.target = _lightGammaMap(channel.target); + } - if (channel.inverse) { - channel.target = Light::ValueMax - channel.target; - } + if (channel.inverse) { + channel.target = Light::ValueMax - channel.target; } float diff = static_cast(channel.target) - channel.current;