Browse Source

light: more refactoring related input & value stages

Fixes color+(white or cct) brightness function factor calculation
to actually do what the comment says it does.

No more unsigned char for value, consistent integer math and
explicit clamping of the input & output values.

As a follow-up for the a55cf0b, reworks brightness functions:
- value input and application implemented as part of the channel class
- track value changes externally, no need for OnceFlag
- simple all, only-rgb, color+white and color+cct are distinct
  functions, where brightness classes implement the actual math
- avoid accidentally doing an actual function call through
  `lightChannels()` by not accessing channels elements & size directly
  through the vector (yay c++ strictness regarding *public* symbols)
pull/2471/head
Maxim Prokhorov 2 years ago
parent
commit
32aae70374
2 changed files with 442 additions and 281 deletions
  1. +2
    -5
      code/espurna/compat.h
  2. +440
    -276
      code/espurna/light.cpp

+ 2
- 5
code/espurna/compat.h View File

@ -87,13 +87,13 @@ long __attribute__((deprecated("Please avoid using map() with Core 2.3.0"))) ma
// Proxy min & max same as the latest Arduino.h
// -----------------------------------------------------------------------------
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef min
#undef max
#undef _min
#undef _max
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#include <algorithm>
using std::min;
@ -101,9 +101,6 @@ using std::max;
using std::isinf;
using std::isnan;
#define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; })
#define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; })
#endif
// -----------------------------------------------------------------------------


+ 440
- 276
code/espurna/light.cpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save