M5Unit-RGB 0.0.1 git rev:55cb205
Loading...
Searching...
No Matches
m5::unit::UnitLED Class Reference

LED base unit. More...

#include <unit_LED.hpp>

Inheritance diagram for m5::unit::UnitLED:
m5::unit::UnitSK6812 m5::unit::UnitWS2812 m5::unit::UnitSK6812GRB m5::unit::UnitSK6812GRBW m5::unit::UnitHexLED37< UnitWS2812 > m5::unit::UnitRectLED< 18, 7, UnitWS2812 > m5::unit::UnitRectLED< 5, 5, UnitWS2812 > m5::unit::UnitRectLED< 8, 8, UnitWS2812 > m5::unit::UnitNeco m5::unit::UnitHexLED37< UnitSK6812GRB > m5::unit::UnitRGB m5::unit::UnitRGBLED144 m5::unit::UnitRGBLED15 m5::unit::UnitRGBLED288 m5::unit::UnitRGBLED29 m5::unit::UnitRGBLED72 m5::unit::UnitRGBLEDStrip120 m5::unit::UnitRGBLEDStrip30 m5::unit::UnitRGBLEDStrip300 m5::unit::UnitRGBLEDStrip60 m5::unit::UnitHex m5::unit::HatNeoFlash m5::unit::UnitAtomMatrixRGB m5::unit::UnitPuzzle

Classes

struct  config_t
 Settings for begin. More...
 

Public Types

using container_type = std::vector<uint8_t>
 pixel container
 
using item_container_type = std::vector<gpio::m5_rmt_item_t>
 item container
 

Public Member Functions

 UnitLED (const uint16_t num_of_pixels, const rgb::Order order)
 Constructor.
 
virtual bool begin () override
 Begin the unit.
 
Configuration for begin
config_t config ()
 Gets the configuration.
 
void config (const config_t &cfg)
 Set the configuration.
 
Properties
uint16_t numPixels () const
 Number of the pixels.
 
uint8_t brightness () const
 Brightness.
 
virtual uint16_t width () const
 Number of the pixels.
 
virtual uint16_t height () const
 Number of the pixels.
 
bool hasWhite () const
 Has white data?
 
rgb::Order order () const
 Color order.
 
int8_t offsetR () const
 Offset of red.
 
int8_t offsetG () const
 Offset of green.
 
int8_t offsetB () const
 Offset of blue.
 
int8_t offsetW () const
 Offset of white.
 
const container_typepixels () const
 pixels container
 
rgb::Color color (const uint16_t n) const
 Get the Color.
 
rgb::Color absoluteColor (const uint16_t n) const
 Get the Color.
 
Apply
bool writePixels ()
 Write pixel color to LED.
 
bool show ()
 Write pixel color to LED (alias)
 
Modifiers
Note
Calling writePixels() or show() is reflected in LEDs
void setBrightness (const uint8_t b)
 Set the brightness.
 
bool setPixelColor (const uint16_t n, const uint8_t r, const uint8_t g, const uint8_t b)
 Set pixel color (RGB)
 
bool setPixelColor (const uint16_t n, const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w)
 Set pixel color (RGBW)
 
bool setPixelColor (const uint16_t n, const rgb::wrgb32_color_t c)
 Set pixel color.
 
bool setPixelColor (const uint16_t n, const rgb::Color &c)
 Set pixel color.
 
bool fill (const rgb::Color &c, const uint16_t first=0, const uint16_t count=0)
 Fill the specified range with the specified color.
 
void clear (void)
 Clear pixels.
 
bool fillRainbow (const uint16_t first=0, const uint16_t count=0, const uint8_t firstHue=0)
 Fill the specified range to rainbow.
 
bool fillGradation (const rgb::Color &firstClr, const rgb::Color &lastClr, const uint16_t first=0, const uint16_t count=0)
 Fill the specified range to gradation pixels.
 
bool fillRandom (const uint16_t first=0, const uint16_t count=0)
 Fill the specified range to random color pixels.
 
void shiftLeft (const uint16_t count=1)
 Shift pixels left.
 
void shiftRight (const uint16_t count=1)
 Shift pixels right.
 
void rotateLeft (const uint16_t count=1)
 Rotate pixels left.
 
void rotateRight (const uint16_t count=1)
 Rotate pixels right.
 
Rotation
Note
Calling writePixel or show is reflected in LEDs
1 rot angle varies from unit to unit (e.g. Puzzle 90 deg Hex 60 deg)
Rotation direction is clockwise
virtual uint8_t maxRotation () const
 Get the max rotation.
 
float rotationDegree () const
 Get the rotation angle per 1 (degree)
 
int8_t rotation () const
 Get the rotation.
 
void setRotation (const int8_t rot)
 Set the rotation.
 
Pixels element access
Note
Affected by rotation
rgb::Color operator[] (const uint16_t i) const
 rvalue
 
PixelProxy operator[] (const uint16_t i)
 lvalue
 

Protected Member Functions

virtual types::category_t unit_category () const override
 
virtual gpio::adapter_config_t rmt_config ()
 
virtual gpio::m5_rmt_item_t rmt_item_one ()
 
virtual gpio::m5_rmt_item_t rmt_item_zero ()
 
virtual gpio::m5_rmt_item_t rmt_item_reset ()
 
container_typepixels ()
 
rgb::Color get_pixel_color (const uint16_t n) const
 
bool set_pixel_color (const uint16_t n, const rgb::Color &c)
 
uint8_t rotation_of (const int8_t r) const
 
virtual uint16_t index_of (const uint16_t n) const
 
container_type rgb888_items ()
 
item_container_type items ()
 
void shift_left (const uint16_t count, const bool wrap)
 
void shift_right (const uint16_t count, const bool wrap)
 

Friends

class InterfaceGPIO
 
class InterfacePbHub
 

Detailed Description

LED base unit.

Constructor & Destructor Documentation

◆ UnitLED()

m5::unit::UnitLED::UnitLED ( const uint16_t num_of_pixels,
const rgb::Order order )
inlineexplicit

Constructor.

Parameters
num_of_pixelsNumber of pixels
orderColor order

Member Function Documentation

◆ absoluteColor()

rgb::Color m5::unit::UnitLED::absoluteColor ( const uint16_t n) const
inline

Get the Color.

Parameters
nPosition of the pixels
Returns
Color if exists
Note
Not affected by rotation

◆ begin()

bool m5::unit::UnitLED::begin ( )
overridevirtual

Begin the unit.

Reimplemented in m5::unit::UnitAtomMatrixRGB, and m5::unit::UnitNeco.

◆ brightness()

uint8_t m5::unit::UnitLED::brightness ( ) const
inline

Brightness.

Note
Scaling factor(255 = 100%)

◆ clear()

void m5::unit::UnitLED::clear ( void )
inline

Clear pixels.

Note
All pixel color to WRGB 0,0,0,0

◆ color()

rgb::Color m5::unit::UnitLED::color ( const uint16_t n) const
inline

Get the Color.

Parameters
nPosition of the pixels
Returns
Color if exists
Note
Affected by rotation

◆ fill()

bool m5::unit::UnitLED::fill ( const rgb::Color & c,
const uint16_t first = 0,
const uint16_t count = 0 )

Fill the specified range with the specified color.

Parameters
crgb::Color
firstFirst position of the pixels
countNumber of pixels to fill (To the end if zero)
Returns
True if successful
Note
Affected by rotation
Warning
If white is not supported, white is ignored

◆ fillGradation()

bool m5::unit::UnitLED::fillGradation ( const rgb::Color & firstClr,
const rgb::Color & lastClr,
const uint16_t first = 0,
const uint16_t count = 0 )

Fill the specified range to gradation pixels.

Parameters
firstClrFirst Color
lastClrLast Color
firstFirst position of the pixels
countNumber of pixels to fill (To the end if zero)
Returns
True if successful
Note
Affected by rotation

◆ fillRainbow()

bool m5::unit::UnitLED::fillRainbow ( const uint16_t first = 0,
const uint16_t count = 0,
const uint8_t firstHue = 0 )

Fill the specified range to rainbow.

Parameters
firstFirst position of the pixels
countNumber of pixels to fill (To the end if zero)
firstHueThe first hue value
Returns
True if successful
Note
Affected by rotation

◆ fillRandom()

bool m5::unit::UnitLED::fillRandom ( const uint16_t first = 0,
const uint16_t count = 0 )

Fill the specified range to random color pixels.

Parameters
firstFirst position of the pixels
countNumber of pixels to fill (To the end if zero)
Returns
True if successful
Note
Affected by rotation

◆ height()

◆ rotateLeft()

void m5::unit::UnitLED::rotateLeft ( const uint16_t count = 1)
inline

Rotate pixels left.

Parameters
countNumber of rotates
Note
Affected by rotation

◆ rotateRight()

void m5::unit::UnitLED::rotateRight ( const uint16_t count = 1)
inline

Rotate pixels right.

Parameters
countNumber of rotates
Note
Affected by rotation

◆ setBrightness()

void m5::unit::UnitLED::setBrightness ( const uint8_t b)
inline

Set the brightness.

Parameters
bbrightness (255 = 100%)
Note
Behaves similar to FastLED
Internal pixels's color is not changed
The brightness applied on writePixels()

◆ setPixelColor() [1/4]

bool m5::unit::UnitLED::setPixelColor ( const uint16_t n,
const rgb::Color & c )
inline

Set pixel color.

Parameters
nPosition of the pixels
crgb::Color
Returns
True if successful
Note
Affected by rotation
Warning
If white is not supported, white is ignored

◆ setPixelColor() [2/4]

bool m5::unit::UnitLED::setPixelColor ( const uint16_t n,
const rgb::wrgb32_color_t c )
inline

Set pixel color.

Parameters
nPosition of the pixels
cWRGB 32bits color
Returns
True if successful
Note
Affected by rotation
Warning
If white is not supported, white is ignored

◆ setPixelColor() [3/4]

bool m5::unit::UnitLED::setPixelColor ( const uint16_t n,
const uint8_t r,
const uint8_t g,
const uint8_t b )

Set pixel color (RGB)

Parameters
nPosition of the pixels
rRed
gGreen
bBlue
Returns
True if successful
Note
If white is supported, white value does not change
Affected by rotation

◆ setPixelColor() [4/4]

bool m5::unit::UnitLED::setPixelColor ( const uint16_t n,
const uint8_t r,
const uint8_t g,
const uint8_t b,
const uint8_t w )
inline

Set pixel color (RGBW)

Parameters
nPosition of the pixels
rRed
gGreen
bBlue
wWhite
Returns
True if successful
Note
Affected by rotation
Warning
If white is not supported, white is ignored

◆ shiftLeft()

void m5::unit::UnitLED::shiftLeft ( const uint16_t count = 1)
inline

Shift pixels left.

Parameters
countNumber of shifts
Note
The empty space will be WRGB 0,0,0,0
Affected by rotation

◆ shiftRight()

void m5::unit::UnitLED::shiftRight ( const uint16_t count = 1)
inline

Shift pixels right.

Parameters
countNumber of shifts
Note
The empty space will be WRGB 0,0,0,0
Affected by rotation

◆ width()