FastLED 3.9.7
Loading...
Searching...
No Matches
pixel_controller.h File Reference

Detailed Description

Low level pixel data writing class.

Definition in file pixel_controller.h.

#include <stddef.h>
#include "FastLED.h"
#include "rgbw.h"
#include "five_bit_hd_gamma.h"
#include "fl/force_inline.h"
#include "fl/namespace.h"
#include "eorder.h"
#include "dither_mode.h"
#include "pixel_iterator.h"
#include "crgb.h"

Go to the source code of this file.

Classes

struct  ColorAdjustment
 
struct  PixelController< RGB_ORDER, LANES, MASK >
 Pixel controller class. More...
 

Macros

#define RO(X)   RGB_BYTE(RGB_ORDER, X)
 Gets the assigned color channel for a byte's position in the output, using the color order (EOrder) template parameter from the LED controller.
 
#define RGB_BYTE(RO, X)   (((RO)>>(3*(2-(X)))) & 0x3)
 Gets the assigned color channel for a byte's position in the output, using a passed RGB color order.
 
#define RGB_BYTE0(RO)   ((RO>>6) & 0x3)
 Gets the color channel for byte 0.
 
#define RGB_BYTE1(RO)   ((RO>>3) & 0x3)
 Gets the color channel for byte 1.
 
#define RGB_BYTE2(RO)   ((RO) & 0x3)
 Gets the color channel for byte 2.
 
#define MAX_LIKELY_UPDATE_RATE_HZ   400
 Predicted max update rate, in Hertz.
 
#define MIN_ACCEPTABLE_DITHER_RATE_HZ   50
 Minimum acceptable dithering rate, in Hertz.
 
#define UPDATES_PER_FULL_DITHER_CYCLE   (MAX_LIKELY_UPDATE_RATE_HZ / MIN_ACCEPTABLE_DITHER_RATE_HZ)
 The number of updates in a single dither cycle.
 
#define RECOMMENDED_VIRTUAL_BITS
 Set "virtual bits" of dithering to the highest level that is not likely to cause excessive flickering at low brightness levels + low update rates.
 
#define VIRTUAL_BITS   RECOMMENDED_VIRTUAL_BITS
 Alias for RECOMMENDED_VIRTUAL_BITS.
 

Macro Definition Documentation

◆ MAX_LIKELY_UPDATE_RATE_HZ

#define MAX_LIKELY_UPDATE_RATE_HZ   400

Predicted max update rate, in Hertz.

Definition at line 189 of file pixel_controller.h.

◆ MIN_ACCEPTABLE_DITHER_RATE_HZ

#define MIN_ACCEPTABLE_DITHER_RATE_HZ   50

Minimum acceptable dithering rate, in Hertz.

Definition at line 192 of file pixel_controller.h.

◆ RECOMMENDED_VIRTUAL_BITS

#define RECOMMENDED_VIRTUAL_BITS
Value:

Set "virtual bits" of dithering to the highest level that is not likely to cause excessive flickering at low brightness levels + low update rates.

These pre-set values are a little ambitious, since a 400Hz update rate for WS2811-family LEDs is only possible with 85 pixels or fewer. Once we have a "number of milliseconds since last update" value available here, we can quickly calculate the correct number of "virtual bits" on the fly with a couple of "if" statements – no division required. At this point, the division is done at compile time, so there's no runtime cost, but the values are still hard-coded.

Todo
Can these macros be replaced with constants scoped to PixelController::init_binary_dithering()?

Definition at line 210 of file pixel_controller.h.

◆ RGB_BYTE

#define RGB_BYTE ( RO,
X )   (((RO)>>(3*(2-(X)))) & 0x3)

Gets the assigned color channel for a byte's position in the output, using a passed RGB color order.

Parameters
ROthe RGB color order
Xthe byte's position in the output (0-2)
Returns
the color channel for that byte (0 = red, 1 = green, 2 = blue)
See also
EOrder

Definition at line 41 of file pixel_controller.h.

◆ RGB_BYTE0

#define RGB_BYTE0 ( RO)    ((RO>>6) & 0x3)

Gets the color channel for byte 0.

See also
RGB_BYTE(RO,X)

Definition at line 45 of file pixel_controller.h.

◆ RGB_BYTE1

#define RGB_BYTE1 ( RO)    ((RO>>3) & 0x3)

Gets the color channel for byte 1.

See also
RGB_BYTE(RO,X)

Definition at line 48 of file pixel_controller.h.

◆ RGB_BYTE2

#define RGB_BYTE2 ( RO)    ((RO) & 0x3)

Gets the color channel for byte 2.

See also
RGB_BYTE(RO,X)

Definition at line 51 of file pixel_controller.h.

◆ RO

#define RO ( X)    RGB_BYTE(RGB_ORDER, X)

Gets the assigned color channel for a byte's position in the output, using the color order (EOrder) template parameter from the LED controller.

Parameters
Xthe byte's position in the output (0-2)
Returns
the color channel for that byte (0 = red, 1 = green, 2 = blue)
See also
EOrder

Definition at line 33 of file pixel_controller.h.

◆ UPDATES_PER_FULL_DITHER_CYCLE

#define UPDATES_PER_FULL_DITHER_CYCLE   (MAX_LIKELY_UPDATE_RATE_HZ / MIN_ACCEPTABLE_DITHER_RATE_HZ)

The number of updates in a single dither cycle.

Definition at line 195 of file pixel_controller.h.

◆ VIRTUAL_BITS

#define VIRTUAL_BITS   RECOMMENDED_VIRTUAL_BITS

Alias for RECOMMENDED_VIRTUAL_BITS.

Definition at line 220 of file pixel_controller.h.