FastLED 3.10.6
Loading...
Searching...
No Matches

◆ init()

static FASTLED_FORCE_INLINE void fl::BinaryDither::init ( u8(&) d[3],
u8(&) e[3],
const u8(&) scale[3],
u8 frame )
inlinestatic

Set up e from the per-channel brightness scale and d from frame.

Lower brightness needs a bigger offset: e = 256/scale, so the offset spans one output step's worth of input. A zero scale (unlit channel) gets no dither.

Definition at line 151 of file binary_dither.h.

152 {
153 const u8 q = phase(frame);
154 for (int i = 0; i < 3; ++i) {
155 // Computed in a local and stored once; re-reading `e[i]` after
156 // the `d[i]` store cost 36 B on AVR (#4672).
157 const u8 s = scale[i];
158 u8 range = s ? (256 / s) + 1 : 0;
159 d[i] = offset(q, range);
160 if (range) { --range; }
161 e[i] = range;
162 }
163 }
fl::UISlider scale("Scale", 4,.1, 4,.1)
unsigned char u8
Definition stdint.h:131
static FASTLED_FORCE_INLINE u8 phase(u8 frame) FL_NO_EXCEPT
The frame's offset pattern value Q: frame wrapped to VIRTUAL_BITS, bit-reversed so consecutive frames...
static FASTLED_FORCE_INLINE u8 offset(u8 q, u8 range) FL_NO_EXCEPT
Q scaled into [0, range): the offset for one channel.

References FASTLED_FORCE_INLINE, fl::FL_NO_EXCEPT, offset(), phase(), and scale.

Referenced by PixelController< RGB_ORDER, LANES, MASK >::init_binary_dithering().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: