Browse Source

lights: always check for transformation flags

amend bdbd127bfb
mcspr-patch-1
Maxim Prokhorov 3 years ago
parent
commit
00b470bc83
1 changed files with 6 additions and 8 deletions
  1. +6
    -8
      code/espurna/light.cpp

+ 6
- 8
code/espurna/light.cpp View File

@ -659,7 +659,7 @@ namespace {
// Gamma Correction lookup table (8 bit, ~2.2) // 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) // (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 { static uint8_t gamma[256] PROGMEM {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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; bool target_state = state && channel.state;
channel.target = target_state ? channel.value : Light::ValueMin; 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<float>(channel.target) - channel.current; float diff = static_cast<float>(channel.target) - channel.current;


Loading…
Cancel
Save