FastLED 3.6.0
Loading...
Searching...
No Matches
controller.h File Reference

Detailed Description

base definitions used by led controllers for writing out led data

Definition in file controller.h.

#include "FastLED.h"
#include "led_sysdefs.h"
#include "pixeltypes.h"
#include "color.h"
#include <stddef.h>

Go to the source code of this file.

Classes

class  CLEDController
 Base definition for an LED controller. More...
 
struct  PixelController< RGB_ORDER, LANES, MASK >
 Pixel controller class. More...
 
class  CPixelLEDController< RGB_ORDER, LANES, MASK >
 Template extension of the CLEDController 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 DISABLE_DITHER   0x00
 Disable dithering.
 
#define BINARY_DITHER   0x01
 Enable dithering using binary dithering (only option)
 
#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.
 

Typedefs

typedef uint8_t EDitherMode
 The dither setting, either DISABLE_DITHER or BINARY_DITHER.
 

Macro Definition Documentation

◆ BINARY_DITHER

#define BINARY_DITHER   0x01

Enable dithering using binary dithering (only option)

Definition at line 46 of file controller.h.

◆ DISABLE_DITHER

#define DISABLE_DITHER   0x00

Disable dithering.

Definition at line 44 of file controller.h.

◆ MAX_LIKELY_UPDATE_RATE_HZ

#define MAX_LIKELY_UPDATE_RATE_HZ   400

Predicted max update rate, in Hertz.

Definition at line 335 of file controller.h.

◆ MIN_ACCEPTABLE_DITHER_RATE_HZ

#define MIN_ACCEPTABLE_DITHER_RATE_HZ   50

Minimum acceptable dithering rate, in Hertz.

Definition at line 338 of file 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 356 of file controller.h.

◆ RGB_BYTE

#define RGB_BYTE (   RO,
 
)    (((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 29 of file 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 33 of file 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 36 of file 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 39 of file 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 21 of file 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 341 of file controller.h.

◆ VIRTUAL_BITS

#define VIRTUAL_BITS   RECOMMENDED_VIRTUAL_BITS

Alias for RECOMMENDED_VIRTUAL_BITS.

Definition at line 366 of file controller.h.

Typedef Documentation

◆ EDitherMode

typedef uint8_t EDitherMode

The dither setting, either DISABLE_DITHER or BINARY_DITHER.

Definition at line 48 of file controller.h.