LP5562-RK
Public Member Functions | Static Public Attributes | Protected Attributes
LP5562 Class Reference

Class for the LP5562 LED driver. More...

#include <LP5562-RK.h>

Public Member Functions

 LP5562 (uint8_t addr=0x30, TwoWire &wire=Wire)
 Construct the object. More...
 
virtual ~LP5562 ()
 Destructor. Not normally used as this is typically a globally instantiated object.
 
LP5562withLEDCurrent (float all)
 Sets the LED current. More...
 
LP5562withLEDCurrent (float red, float green, float blue, float white=0.1)
 Sets the LED current. More...
 
LP5562withUseExternalOscillator (bool value=true)
 Set external oscillator mode. Default is internal. More...
 
LP5562withUseLogarithmicMode (bool value=true)
 Use Logarithmic Mode for PWM brightness. Default = true. More...
 
LP5562withHighFrequencyMode (bool value=true)
 Enable high frequency PWM. Default = false. More...
 
bool begin ()
 Set up the I2C device and begin running. More...
 
void setR (uint8_t red)
 Sets the PWM for the red channel. More...
 
void setG (uint8_t green)
 Sets the PWM for the green channel. More...
 
void setB (uint8_t blue)
 Sets the PWM for the blue channel. More...
 
void setRGB (uint8_t red, uint8_t green, uint8_t blue)
 Sets the PWM for the R, G, and B channels. More...
 
void setRGB (uint32_t rgb)
 Sets the PWM for the R, G, and B channels. More...
 
void setW (uint8_t white)
 Sets the W channel to the specified PWM value. More...
 
void useDirectRGB ()
 Use direct mode on RGB LED. Changes the LED mapping register and if a program is running on the R, G, or B LEDs, stops it. More...
 
void useDirectW ()
 Use direct mode on W LED. Changes the LED mapping register and if a program is running on the W LED, stops it. More...
 
void setBlink (uint8_t red, uint8_t green, uint8_t blue, unsigned long msOn, unsigned long msOff)
 Set blinking mode on the RGB LED. More...
 
void setBlink (uint32_t rgb, unsigned long msOn, unsigned long msOff)
 Set blinking mode on the RGB LED. More...
 
void setBlink2 (uint8_t red1, uint8_t green1, uint8_t blue1, unsigned long ms1, uint8_t red2, uint8_t green2, uint8_t blue2, unsigned long ms2)
 Set alternating blink mode between two colors (no off phase) More...
 
void setBlink2 (uint32_t rgb1, unsigned long ms1, uint32_t rgb2, unsigned long ms2)
 Set alternating blink mode between two colors (no off phase) More...
 
void setBreathe (bool red, bool green, bool blue, uint8_t stepTimeHalfMs, uint8_t lowLevel, uint8_t highLevel)
 Set breathing mode. More...
 
void setIndicatorMode (unsigned long on1ms=500, unsigned long off1ms=500, unsigned long on2ms=100, unsigned long off2ms=100, uint8_t breatheTime=20)
 Set indicator mode. More...
 
bool setLedMapping (uint8_t red, uint8_t green, uint8_t blue, uint8_t white)
 Set ledMapping to program. Not normally necessary. More...
 
bool setLedMappingR (uint8_t mode, uint8_t value=0)
 Set the led mapping for the red LED. Typically used in indicator mode to set direct or program mode. More...
 
bool setLedMappingG (uint8_t mode, uint8_t value=0)
 Set the led mapping for the green LED. Typically used in indicator mode to set direct or program mode. More...
 
bool setLedMappingB (uint8_t mode, uint8_t value=0)
 Set the led mapping for the blue LED. Typically used in indicator mode to set direct or program mode. More...
 
bool setLedMappingW (uint8_t mode, uint8_t value=0)
 Set the led mapping for the white LED. Typically used in indicator mode to set direct or program mode. More...
 
uint8_t getLedMapping ()
 Get the value of the LED mapping register (0x70)
 
bool setEnable (uint8_t engineMask, uint8_t engineMode)
 Enable an engine mode on certain engines. More...
 
uint8_t getEnable ()
 Get the value of the enable register (0x00)
 
uint8_t engineNumToMask (size_t engine) const
 Convert an engine number 1 - 3 to an engineMask value. More...
 
bool setOpMode (size_t engine, uint8_t engineMode)
 Sets the operation mode register (0x01) More...
 
uint8_t getOpMode ()
 Get the value of the operation mode register (0x01)
 
uint8_t getStatus ()
 Get the value of the status/interrupt register. More...
 
bool clearProgram (size_t engine)
 Clears a program on the specified engine. More...
 
bool clearAllPrograms ()
 Clears programs on engines 1, 2, and 3 (all engines)
 
bool setProgram (size_t engine, const LP5562Program &program, bool startRunning)
 Sets a program on a specified engine from a LP5562Program object. More...
 
bool setProgram (size_t engine, const uint16_t *instructions, size_t numInstruction, bool startRunning)
 Sets a program on a specified engine from a from program words. More...
 
uint8_t floatToCurrent (float value) const
 Convert a current value in mA to the format used by the LP5562. More...
 
uint8_t readRegister (uint8_t reg)
 Low-level call to read a register value. More...
 
bool writeRegister (uint8_t reg, uint8_t value)
 Low-level call to write a register value. More...
 

Static Public Attributes

static const uint8_t REG_ENABLE = 0x00
 Enable register (0x00)
 
static const uint8_t REG_ENABLE_LOG_EN = 0x80
 The logarithmic mode for PWM brightness when set (instead of linear)
 
static const uint8_t REG_ENABLE_CHIP_EN = 0x40
 Enable the chip. Power-up default is off. Make sure you set the current before enabling!
 
static const uint8_t REG_ENABLE_HOLD = 0b00
 Put the engine in hold mode (stops execution) More...
 
static const uint8_t REG_ENABLE_STEP = 0b01
 Put the engine in single step mode. It will run the current instruction, increment the PC, then hold. More...
 
static const uint8_t REG_ENABLE_RUN = 0b10
 Put the engine in run mode. It will run the current code, until the code itself decides to halt or you change the run mode manually. More...
 
static const uint8_t REG_ENABLE_EXEC = 0b11
 Put the engine in direct execute mode. It will run the current instruction, then hold. More...
 
static const uint8_t REG_OP_MODE = 0x01
 Operation mode register (0x01)
 
static const uint8_t REG_ENGINE_DISABLED = 0b00
 Put the engine in disabled mode, and will no longer run. More...
 
static const uint8_t REG_ENGINE_LOAD = 0b01
 Put the engine in load mode. Required to load code. Handled automatically by setProgram(). More...
 
static const uint8_t REG_ENGINE_RUN = 0b10
 Put the engine in run mode. More...
 
static const uint8_t REG_ENGINE_DIRECT = 0b11
 Put the engine in direct mode. More...
 
static const uint8_t REG_B_PWM = 0x02
 Blue channel PWM direct register (0x02)
 
static const uint8_t REG_G_PWM = 0x03
 Green channel PWM direct register (0x03)
 
static const uint8_t REG_R_PWM = 0x04
 Red channel PWM direct register (0x04)
 
static const uint8_t REG_B_CURRENT = 0x05
 Blue channel current register in 0.1 mA units (0x05)
 
static const uint8_t REG_G_CURRENT = 0x06
 Green channel current register in 0.1 mA units (0x06)
 
static const uint8_t REG_R_CURRENT = 0x07
 Red channel current register in 0.1 mA units (0x07)
 
static const uint8_t REG_CONFIG = 0x08
 Config register.
 
static const uint8_t REG_CONFIG_HF = 0x40
 Config register HF (high frequency mode) enabled bit.
 
static const uint8_t REG_CONFIG_PS_EN = 0x20
 Config register powersave enabled bit.
 
static const uint8_t REG_CONFIG_CLK_DET_EN = 0x02
 Config register clock detect enable bit.
 
static const uint8_t REG_CONFIG_INT_CLK_EN = 0x01
 Config register internal clock bit.
 
static const uint8_t REG_ENG1_PC = 0x09
 Program counter for engine 1 (0 - 15)
 
static const uint8_t REG_ENG2_PC = 0x0a
 Program counter for engine 2 (0 - 15)
 
static const uint8_t REG_ENG3_PC = 0x0b
 Program counter for engine 3 (0 - 15)
 
static const uint8_t REG_STATUS = 0x0c
 Status register.
 
static const uint8_t REG_STATUS_EXT_CLK_USED = 0x08
 Status register external clock used bit.
 
static const uint8_t REG_STATUS_ENG1_INT = 0x04
 Status register engine 1 generated an interrupt if bit is set.
 
static const uint8_t REG_STATUS_ENG2_INT = 0x02
 Status register engine 2 generated an interrupt if bit is set.
 
static const uint8_t REG_STATUS_ENG3_INT = 0x01
 Status register engine 3 generated an interrupt if bit is set.
 
static const uint8_t REG_RESET = 0x0d
 Reset register. Write 0xff to clear all register to default values.
 
static const uint8_t REG_W_PWM = 0x0e
 White channel PWM direct register (0x0e)
 
static const uint8_t REG_W_CURRENT = 0x0f
 Blue channel current register in 0.1 mA units (0x0f)
 
static const uint8_t REG_PROGRAM_1 = 0x10
 Engine 1 instructions 0x10 to 0x2f (0x20 bytes = 16 16-bit instructions)
 
static const uint8_t REG_PROGRAM_2 = 0x30
 Engine 2 instructions 0x30 to 0x4f (0x20 bytes = 16 16-bit instructions)
 
static const uint8_t REG_PROGRAM_3 = 0x50
 Engine 3 instructions 0x50 to 0x6f (0x20 bytes = 16 16-bit instructions)
 
static const uint8_t REG_LED_MAP = 0x70
 LED mapping engine (direct or assigned to an engine)
 
static const uint8_t REG_LED_MAP_DIRECT = 0b00
 Sets the LED to direct PWM setting mode. More...
 
static const uint8_t REG_LED_MAP_ENGINE_1 = 0b01
 Sets the LED to be controlled by engine 1. More...
 
static const uint8_t REG_LED_MAP_ENGINE_2 = 0b10
 Sets the LED to be controlled by engine 2. More...
 
static const uint8_t REG_LED_MAP_ENGINE_3 = 0b11
 Sets the LED to be controlled by engine 3. More...
 
static const uint8_t MASK_ENGINE_1 = 0b001
 Mask value to pass to set setEnable to change the enable mode for one or more engines at once. More...
 
static const uint8_t MASK_ENGINE_2 = 0b010
 Mask value to pass to set setEnable to change the enable mode for one or more engines at once. More...
 
static const uint8_t MASK_ENGINE_3 = 0b100
 Mask value to pass to set setEnable to change the enable mode for one or more engines at once. More...
 
static const uint8_t MASK_ENGINE_ALL = 0b111
 Mask value to pass to set setEnable to change the enable mode for all engines at once. More...
 

Protected Attributes

uint8_t addr
 The I2C address (0x00 - 0x7f). Default is 0x30. More...
 
TwoWire & wire
 The I2C interface to use. Default is Wire. Could be Wire1 on some devices.
 
uint8_t redCurrent = 50
 Current to supply to the red LED. Default is 5 mA. More...
 
uint8_t greenCurrent = 50
 Current to supply to the green LED. Default is 5 mA. More...
 
uint8_t blueCurrent = 50
 Current to supply to the blue LED. Default is 5 mA. More...
 
uint8_t whiteCurrent = 50
 Current to supply to the white LED. Default is 5 mA. More...
 
bool useExternalOscillator = false
 Whether to use the internal oscillator (true) or external (false). Default is internal.
 
bool useLogarithmicMode = true
 Whether to use logarithmic mode for PWM values (true, default) or linear (false). More...
 
bool highFrequencyMode = false
 Whether to use low or high frequency for the PWM. Default is low (256 Hz). More...
 

Detailed Description

Class for the LP5562 LED driver.

Normally you create one of these as a global variable for each chip you have on your board.

You must initialize any configuration parameters before calling begin(). This is typically done in setup().

For example, to set the RGB and W current to 10 mA instead of 5 mA, use:

ledDriver.withLEDCurrent(10.0).begin();

You can chain the with options, fluent-style if desired:

ledDriver.withLEDCurrent(10.0, 10.0, 10.0, 20.0).withExternalOscillator().begin();

Constructor & Destructor Documentation

◆ LP5562()

LP5562::LP5562 ( uint8_t  addr = 0x30,
TwoWire &  wire = Wire 
)

Construct the object.

Parameters
addrThe address. Can be 0 - 3 based on the address select pins, using the normal base address of 0x30 to make 0x30 to 0x33. Or you can pass in the full I2C address 0x00 - 0x7f.
wireThe I2C interface to use. Normally Wire, the primary I2C interface. Can be a different one on devices with more than one I2C interface.

Member Function Documentation

◆ begin()

bool LP5562::begin ( )

Set up the I2C device and begin running.

You cannot do this from STARTUP or global object construction time. It should only be done from setup or loop (once).

Make sure you set the LED current using withLEDCurrent() before calling begin if your LED has a current other than the default of 5 mA.

◆ clearProgram()

bool LP5562::clearProgram ( size_t  engine)
inline

Clears a program on the specified engine.

Parameters
engineAn engine number 1 <= engine <= 3

◆ engineNumToMask()

uint8_t LP5562::engineNumToMask ( size_t  engine) const

Convert an engine number 1 - 3 to an engineMask value.

Parameters
engineAn engine number 1 <= engine <= 3
Returns
A mask value MASK_ENGINE_1, MASK_ENGINE_2, or MASK_ENGINE_3

engine mask 1 0b001 2 0b010 3 0b100

◆ floatToCurrent()

uint8_t LP5562::floatToCurrent ( float  value) const

Convert a current value in mA to the format used by the LP5562.

Parameters
valueValue in mA
Returns
A uint8_t value in tenths of a mA. For example, passing 5 (mA) will return 50.

◆ getStatus()

uint8_t LP5562::getStatus ( )
inline

Get the value of the status/interrupt register.

Reading the status/interrupt register will clear any interrupts that are set.

◆ readRegister()

uint8_t LP5562::readRegister ( uint8_t  reg)

Low-level call to read a register value.

Parameters
regThe register to read (0x00 to 0x70)

◆ setB()

void LP5562::setB ( uint8_t  blue)

Sets the PWM for the blue channel.

Parameters
bluevalue 0 - 255. 0 = off, 255 = full brightness.

If you were previously using a program (setProgram, setBlink, setBlink2, or setBreathe, you must stop the program using useDirectRGB() before you can set the RGB values.

◆ setBlink() [1/2]

void LP5562::setBlink ( uint8_t  red,
uint8_t  green,
uint8_t  blue,
unsigned long  msOn,
unsigned long  msOff 
)

Set blinking mode on the RGB LED.

Parameters
redvalue 0 - 255. 0 = off, 255 = full brightness.
greenvalue 0 - 255. 0 = off, 255 = full brightness.
bluevalue 0 - 255. 0 = off, 255 = full brightness.
msOnThe number of milliseconds to be on (1 - 61916)
msOffThe number of milliseconds to be off (1 - 61916)

◆ setBlink() [2/2]

void LP5562::setBlink ( uint32_t  rgb,
unsigned long  msOn,
unsigned long  msOff 
)
inline

Set blinking mode on the RGB LED.

Parameters
rgbValue in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness).
msOnThe number of milliseconds to be on (1 - 61916)
msOffThe number of milliseconds to be off (1 - 61916)

◆ setBlink2() [1/2]

void LP5562::setBlink2 ( uint8_t  red1,
uint8_t  green1,
uint8_t  blue1,
unsigned long  ms1,
uint8_t  red2,
uint8_t  green2,
uint8_t  blue2,
unsigned long  ms2 
)

Set alternating blink mode between two colors (no off phase)

Parameters
red1value 0 - 255. 0 = off, 255 = full brightness.
green1value 0 - 255. 0 = off, 255 = full brightness.
blue1value 0 - 255. 0 = off, 255 = full brightness.
ms1The number of milliseconds to be the 1 color (1 - 61916)
red2value 0 - 255. 0 = off, 255 = full brightness.
green2value 0 - 255. 0 = off, 255 = full brightness.
blue2value 0 - 255. 0 = off, 255 = full brightness.
ms2The number of milliseconds to be the 2 color (1 - 61916)

◆ setBlink2() [2/2]

void LP5562::setBlink2 ( uint32_t  rgb1,
unsigned long  ms1,
uint32_t  rgb2,
unsigned long  ms2 
)

Set alternating blink mode between two colors (no off phase)

Parameters
rgb1Value in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness).
ms1The number of milliseconds to be the 1 color (1 - 61916)
rgb2Value in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness).
ms2The number of milliseconds to be the 2 color (1 - 61916)

◆ setBreathe()

void LP5562::setBreathe ( bool  red,
bool  green,
bool  blue,
uint8_t  stepTimeHalfMs,
uint8_t  lowLevel,
uint8_t  highLevel 
)

Set breathing mode.

Because of hardware limitations, breathing mode can only be done for the 7 full brightness colors: red true, false, false green false, true, false blue false, false, true yellow true, true, false cyan false, true, true magenta true, false, true white true, true, true

Parameters
redtrue to breathe the red channel
greentrue to breathe the green channel
bluetrue to breathe the blue channel
stepTimeHalfMsAmount of time between step changes from 1 to 63 in half millisecond increments.
lowLevelStart at this level (0 - 255). Typically 0.
highLevelEnd at this level (0 - 255). Typically 255. lowLevel must be < highLevel.

◆ setEnable()

bool LP5562::setEnable ( uint8_t  engineMask,
uint8_t  engineMode 
)

Enable an engine mode on certain engines.

Parameters
engineMaskA mask of the engines to send to. Logical OR the values MASK_ENGINE_1, MASK_ENGINE_2, and MASK_ENGINE_3 or use MASK_ENGINE_ALL for all 3 engines.
engineModeOne of the constants: REG_ENGINE_DISABLED, REG_ENGINE_LOAD, REG_ENGINE_RUN, or REG_ENGINE_DIRECT.

This is normally done automatically for you when entering program mode or direct mode.

◆ setG()

void LP5562::setG ( uint8_t  green)

Sets the PWM for the green channel.

Parameters
greenvalue 0 - 255. 0 = off, 255 = full brightness.

If you were previously using a program (setProgram, setBlink, setBlink2, or setBreathe, you must stop the program using useDirectRGB() before you can set the RGB values.

◆ setIndicatorMode()

void LP5562::setIndicatorMode ( unsigned long  on1ms = 500,
unsigned long  off1ms = 500,
unsigned long  on2ms = 100,
unsigned long  off2ms = 100,
uint8_t  breatheTime = 20 
)

Set indicator mode.

Engine 1 = Blink Engine 2 = Fast Blink Engine 3 = Breathe

◆ setLedMapping()

bool LP5562::setLedMapping ( uint8_t  red,
uint8_t  green,
uint8_t  blue,
uint8_t  white 
)

Set ledMapping to program. Not normally necessary.

Parameters
redREG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3.
greenREG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3.
blueREG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3.
whiteREG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3.

This method is used to map the LED to direct or program mode. This is used internally by setRGB, setBlink, setBlink2, or setBreathe so you don't normally need to call this yourself.

◆ setLedMappingB()

bool LP5562::setLedMappingB ( uint8_t  mode,
uint8_t  value = 0 
)

Set the led mapping for the blue LED. Typically used in indicator mode to set direct or program mode.

mode REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3

value If using REG_LED_MAP_DIRECT, the intensity value 0 = off, 255 = full brightness

◆ setLedMappingG()

bool LP5562::setLedMappingG ( uint8_t  mode,
uint8_t  value = 0 
)

Set the led mapping for the green LED. Typically used in indicator mode to set direct or program mode.

mode REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3

value If using REG_LED_MAP_DIRECT, the intensity value 0 = off, 255 = full brightness

◆ setLedMappingR()

bool LP5562::setLedMappingR ( uint8_t  mode,
uint8_t  value = 0 
)

Set the led mapping for the red LED. Typically used in indicator mode to set direct or program mode.

mode REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3

value If using REG_LED_MAP_DIRECT, the intensity value 0 = off, 255 = full brightness

◆ setLedMappingW()

bool LP5562::setLedMappingW ( uint8_t  mode,
uint8_t  value = 0 
)

Set the led mapping for the white LED. Typically used in indicator mode to set direct or program mode.

mode REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3

value If using REG_LED_MAP_DIRECT, the intensity value 0 = off, 255 = full brightness

◆ setOpMode()

bool LP5562::setOpMode ( size_t  engine,
uint8_t  engineMode 
)

Sets the operation mode register (0x01)

Parameters
engineThe engine number to set (1, 2, or 3)
engineModeThe mode to set: REG_ENGINE_DISABLED, REG_ENGINE_LOAD (also resets PC), REG_ENGINE_RUN, REG_ENGINE_DIRECT

◆ setProgram() [1/2]

bool LP5562::setProgram ( size_t  engine,
const LP5562Program program,
bool  startRunning 
)
inline

Sets a program on a specified engine from a LP5562Program object.

Parameters
engineAn engine number 1 <= engine <= 3
programThe program to set
startRunningtrue to start the program running immediately or false to leave it in halt mode

◆ setProgram() [2/2]

bool LP5562::setProgram ( size_t  engine,
const uint16_t *  instructions,
size_t  numInstruction,
bool  startRunning 
)

Sets a program on a specified engine from a from program words.

Parameters
engineAn engine number 1 <= engine <= 3
instructionsAn array of uint16_t values containing up to 16 instructions. Can be NULL if numInstruction == 0.
numInstructionThe number of instruction words (0 - 15).
startRunningtrue to start the program running immediately or false to leave it in halt mode.

The unused instruction words (numInstruction to 16) are always set to 0 for safety. If you call this with numInstruction == 0 it clears the program (which is what clearProgram and clearAllPrograms do).

◆ setR()

void LP5562::setR ( uint8_t  red)

Sets the PWM for the red channel.

Parameters
redvalue 0 - 255. 0 = off, 255 = full brightness.

If you were previously using a program (setProgram, setBlink, setBlink2, or setBreathe, you must stop the program using useDirectRGB() before you can set the RGB values.

◆ setRGB() [1/2]

void LP5562::setRGB ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Sets the PWM for the R, G, and B channels.

Parameters
redvalue 0 - 255. 0 = off, 255 = full brightness.
greenvalue 0 - 255. 0 = off, 255 = full brightness.
bluevalue 0 - 255. 0 = off, 255 = full brightness.

If you were previously using a program (setProgram, setBlink, setBlink2, or setBreathe, you must stop the program using useDirectRGB() before you can set the RGB values.

◆ setRGB() [2/2]

void LP5562::setRGB ( uint32_t  rgb)

Sets the PWM for the R, G, and B channels.

Parameters
rgbValue in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness).

If you were previously using a program (setProgram, setBlink, setBlink2, or setBreathe, you must stop the program using useDirectRGB() before you can set the RGB values.

◆ setW()

void LP5562::setW ( uint8_t  white)

Sets the W channel to the specified PWM value.

Parameters
whitevalue 0 - 255. 0 = off, 255 = full brightness.

◆ useDirectRGB()

void LP5562::useDirectRGB ( )

Use direct mode on RGB LED. Changes the LED mapping register and if a program is running on the R, G, or B LEDs, stops it.

If you call setProgram() or functions like setBlink(), setBlink2(), or setBreathe() you must call this before calling setRGB() or the program will continue to run and override your manual setting!

◆ useDirectW()

void LP5562::useDirectW ( )

Use direct mode on W LED. Changes the LED mapping register and if a program is running on the W LED, stops it.

If you call setProgram() or functions like setBlink(), setBlink2(), or setBreathe() you must call this before calling setW() or the program will continue to run and override your manual setting!

◆ withHighFrequencyMode()

LP5562& LP5562::withHighFrequencyMode ( bool  value = true)
inline

Enable high frequency PWM. Default = false.

Low frequency (default) is 256 Hz. High frequency is 558 Hz.

This method returns a LP5562 object so you can chain multiple configuration calls together, fluent-style.

◆ withLEDCurrent() [1/2]

LP5562& LP5562::withLEDCurrent ( float  all)
inline

Sets the LED current.

Parameters
allThe current for all LEDs (R, G, B, and W). You can set specific different currents with the other overload. The default is 5 mA. The range of from 0.1 to 25.5 mA in increments of 0.1 mA.

This method returns a LP5562 object so you can chain multiple configuration calls together, fluent-style.

◆ withLEDCurrent() [2/2]

LP5562 & LP5562::withLEDCurrent ( float  red,
float  green,
float  blue,
float  white = 0.1 
)

Sets the LED current.

Parameters
redThe current for the red LED. The default is 5 mA. The range of from 0.1 to 25.5 mA in increments of 0.1 mA.
greenThe current for the green LED. The default is 5 mA. The range of from 0.1 to 25.5 mA in increments of 0.1 mA.
blueThe current for the blue LED. The default is 5 mA. The range of from 0.1 to 25.5 mA in increments of 0.1 mA.
whiteThe current for the white LED. The default is 5 mA. The range of from 0.1 to 25.5 mA in increments of 0.1 mA.

This method returns a LP5562 object so you can chain multiple configuration calls together, fluent-style.

◆ withUseExternalOscillator()

LP5562& LP5562::withUseExternalOscillator ( bool  value = true)
inline

Set external oscillator mode. Default is internal.

This method returns a LP5562 object so you can chain multiple configuration calls together, fluent-style.

◆ withUseLogarithmicMode()

LP5562& LP5562::withUseLogarithmicMode ( bool  value = true)
inline

Use Logarithmic Mode for PWM brightness. Default = true.

This adjusts the PWM value for the perceived brightness from the human eye vs. actual linear values.

This method returns a LP5562 object so you can chain multiple configuration calls together, fluent-style.

◆ writeRegister()

bool LP5562::writeRegister ( uint8_t  reg,
uint8_t  value 
)

Low-level call to write a register value.

Parameters
regThe register to read (0x00 to 0x70)
valueThe value to set

Note that setProgram bypasses this to write multiple bytes at once, to improve efficiency.

Field Documentation

◆ addr

uint8_t LP5562::addr
protected

The I2C address (0x00 - 0x7f). Default is 0x30.

If you passed in an address 0 - 3 into the constructor, 0x30 - 0x33 is stored here.

◆ blueCurrent

uint8_t LP5562::blueCurrent = 50
protected

Current to supply to the blue LED. Default is 5 mA.

Make sure this is set before calling begin! Setting the value too high can destroy the LED! Note the hardware value is even higher, but the library sets it always and uses a safe default.

◆ greenCurrent

uint8_t LP5562::greenCurrent = 50
protected

Current to supply to the green LED. Default is 5 mA.

Make sure this is set before calling begin! Setting the value too high can destroy the LED! Note the hardware value is even higher, but the library sets it always and uses a safe default.

◆ highFrequencyMode

bool LP5562::highFrequencyMode = false
protected

Whether to use low or high frequency for the PWM. Default is low (256 Hz).

Low frequency (default) is 256 Hz. High frequency is 558 Hz.

◆ MASK_ENGINE_1

const uint8_t LP5562::MASK_ENGINE_1 = 0b001
static

Mask value to pass to set setEnable to change the enable mode for one or more engines at once.

Logically OR MASK_ENGINE_1 | MASK_ENGINE_2 | MASK_ENGINE_3 as desired for which engines you want. You can also use MASK_ENGINE_ALL to act on all engines.

◆ MASK_ENGINE_2

const uint8_t LP5562::MASK_ENGINE_2 = 0b010
static

Mask value to pass to set setEnable to change the enable mode for one or more engines at once.

Logically OR MASK_ENGINE_1 | MASK_ENGINE_2 | MASK_ENGINE_3 as desired for which engines you want. You can also use MASK_ENGINE_ALL to act on all engines.

◆ MASK_ENGINE_3

const uint8_t LP5562::MASK_ENGINE_3 = 0b100
static

Mask value to pass to set setEnable to change the enable mode for one or more engines at once.

Logically OR MASK_ENGINE_1 | MASK_ENGINE_2 | MASK_ENGINE_3 as desired for which engines you want. You can also use MASK_ENGINE_ALL to act on all engines.

◆ MASK_ENGINE_ALL

const uint8_t LP5562::MASK_ENGINE_ALL = 0b111
static

Mask value to pass to set setEnable to change the enable mode for all engines at once.

The same as MASK_ENGINE_1 | MASK_ENGINE_2 | MASK_ENGINE_3.

◆ redCurrent

uint8_t LP5562::redCurrent = 50
protected

Current to supply to the red LED. Default is 5 mA.

Make sure this is set before calling begin! Setting the value too high can destroy the LED! Note the hardware value is even higher, but the library sets it always and uses a safe default.

◆ REG_ENABLE_EXEC

const uint8_t LP5562::REG_ENABLE_EXEC = 0b11
static

Put the engine in direct execute mode. It will run the current instruction, then hold.

This constant is also passed setEnable() to specify which enable mode you want the engine to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENABLE_HOLD, REG_ENABLE_STEP, REG_ENABLE_RUN, REG_ENABLE_EXEC.

◆ REG_ENABLE_HOLD

const uint8_t LP5562::REG_ENABLE_HOLD = 0b00
static

Put the engine in hold mode (stops execution)

This constant is also passed setEnable() to specify which enable mode you want the engine to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENABLE_HOLD, REG_ENABLE_STEP, REG_ENABLE_RUN, REG_ENABLE_EXEC.

◆ REG_ENABLE_RUN

const uint8_t LP5562::REG_ENABLE_RUN = 0b10
static

Put the engine in run mode. It will run the current code, until the code itself decides to halt or you change the run mode manually.

This constant is also passed setEnable() to specify which enable mode you want the engine to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENABLE_HOLD, REG_ENABLE_STEP, REG_ENABLE_RUN, REG_ENABLE_EXEC.

◆ REG_ENABLE_STEP

const uint8_t LP5562::REG_ENABLE_STEP = 0b01
static

Put the engine in single step mode. It will run the current instruction, increment the PC, then hold.

This constant is also passed setEnable() to specify which enable mode you want the engine to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENABLE_HOLD, REG_ENABLE_STEP, REG_ENABLE_RUN, REG_ENABLE_EXEC.

◆ REG_ENGINE_DIRECT

const uint8_t LP5562::REG_ENGINE_DIRECT = 0b11
static

Put the engine in direct mode.

This constant is also passed setOpMode() to specify which operation mode you want it to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENGINE_DISABLED, REG_ENGINE_LOAD, REG_ENGINE_RUN, REG_ENGINE_DIRECT.Put the engine in disabled mode. This bit mask is shifted left depending on which engine you are setting in the op register.

◆ REG_ENGINE_DISABLED

const uint8_t LP5562::REG_ENGINE_DISABLED = 0b00
static

Put the engine in disabled mode, and will no longer run.

This constant is also passed setOpMode() to specify which operation mode you want it to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENGINE_DISABLED, REG_ENGINE_LOAD, REG_ENGINE_RUN, REG_ENGINE_DIRECT.Put the engine in disabled mode. This bit mask is shifted left depending on which engine you are setting in the op register.

◆ REG_ENGINE_LOAD

const uint8_t LP5562::REG_ENGINE_LOAD = 0b01
static

Put the engine in load mode. Required to load code. Handled automatically by setProgram().

This constant is also passed setOpMode() to specify which operation mode you want it to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENGINE_DISABLED, REG_ENGINE_LOAD, REG_ENGINE_RUN, REG_ENGINE_DIRECT.

◆ REG_ENGINE_RUN

const uint8_t LP5562::REG_ENGINE_RUN = 0b10
static

Put the engine in run mode.

This constant is also passed setOpMode() to specify which operation mode you want it to be in.

This value is shifted depending on the engine when storing directly in the enable register:

Engine 1: Left shift 4 Engine 2: Left shift 2 Engine 3: No shift

This is part of a set of mutually exclusive options (for a given engine): REG_ENGINE_DISABLED, REG_ENGINE_LOAD, REG_ENGINE_RUN, REG_ENGINE_DIRECT.

◆ REG_LED_MAP_DIRECT

const uint8_t LP5562::REG_LED_MAP_DIRECT = 0b00
static

Sets the LED to direct PWM setting mode.

This constant is also passed setLedMapping() to specify how you want to control a specific LED.

This value is shifted depending on the engine when storing directly in the enable register:

White LED: left shift 6 Red LED: left shift 4 Green LED: left shift 2 Blue LED: don't shift

This is part of a set of mutually exclusive values: REG_LED_MAP_DIRECT, REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, and REG_LED_MAP_ENGINE_3.

◆ REG_LED_MAP_ENGINE_1

const uint8_t LP5562::REG_LED_MAP_ENGINE_1 = 0b01
static

Sets the LED to be controlled by engine 1.

This constant is also passed setLedMapping() to specify how you want to control a specific LED.

This value is shifted depending on the engine when storing directly in the enable register:

White LED: left shift 6 Red LED: left shift 4 Green LED: left shift 2 Blue LED: don't shift

You can connect multiple LEDs to a single engine. For example, if you wanted to breathe cyan you could connect blue and green to a single engine that's ramping up and down. Or connect R, G, and B to have the LED run the program in white.

This is part of a set of mutually exclusive values: REG_LED_MAP_DIRECT, REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, and REG_LED_MAP_ENGINE_3.

◆ REG_LED_MAP_ENGINE_2

const uint8_t LP5562::REG_LED_MAP_ENGINE_2 = 0b10
static

Sets the LED to be controlled by engine 2.

This constant is also passed setLedMapping() to specify how you want to control a specific LED.

This value is shifted depending on the engine when storing directly in the enable register:

White LED: left shift 6 Red LED: left shift 4 Green LED: left shift 2 Blue LED: don't shift

You can connect multiple LEDs to a single engine. For example, if you wanted to breathe cyan you could connect blue and green to a single engine that's ramping up and down. Or connect R, G, and B to have the LED run the program in white.

This is part of a set of mutually exclusive values: REG_LED_MAP_DIRECT, REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, and REG_LED_MAP_ENGINE_3.

◆ REG_LED_MAP_ENGINE_3

const uint8_t LP5562::REG_LED_MAP_ENGINE_3 = 0b11
static

Sets the LED to be controlled by engine 3.

This constant is also passed setLedMapping() to specify how you want to control a specific LED.

This value is shifted depending on the engine when storing directly in the enable register:

White LED: left shift 6 Red LED: left shift 4 Green LED: left shift 2 Blue LED: don't shift

You can connect multiple LEDs to a single engine. For example, if you wanted to breathe cyan you could connect blue and green to a single engine that's ramping up and down. Or connect R, G, and B to have the LED run the program in white.

This is part of a set of mutually exclusive values: REG_LED_MAP_DIRECT, REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, and REG_LED_MAP_ENGINE_3.

◆ useLogarithmicMode

bool LP5562::useLogarithmicMode = true
protected

Whether to use logarithmic mode for PWM values (true, default) or linear (false).

Logarithmic varies the PWM values to their perceived brightness by the human eye.

◆ whiteCurrent

uint8_t LP5562::whiteCurrent = 50
protected

Current to supply to the white LED. Default is 5 mA.

Make sure this is set before calling begin! Setting the value too high can destroy the LED! Note the hardware value is even higher, but the library sets it always and uses a safe default.


The documentation for this class was generated from the following files: