LP5562-RK
|
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. | |
LP5562 & | withLEDCurrent (float all) |
Sets the LED current. More... | |
LP5562 & | withLEDCurrent (float red, float green, float blue, float white=0.1) |
Sets the LED current. More... | |
LP5562 & | withUseExternalOscillator (bool value=true) |
Set external oscillator mode. Default is internal. More... | |
LP5562 & | withUseLogarithmicMode (bool value=true) |
Use Logarithmic Mode for PWM brightness. Default = true. More... | |
LP5562 & | withHighFrequencyMode (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... | |
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();
LP5562::LP5562 | ( | uint8_t | addr = 0x30 , |
TwoWire & | wire = Wire |
||
) |
Construct the object.
addr | The 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. |
wire | The I2C interface to use. Normally Wire, the primary I2C interface. Can be a different one on devices with more than one I2C interface. |
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.
|
inline |
Clears a program on the specified engine.
engine | An engine number 1 <= engine <= 3 |
uint8_t LP5562::engineNumToMask | ( | size_t | engine | ) | const |
Convert an engine number 1 - 3 to an engineMask value.
engine | An engine number 1 <= engine <= 3 |
engine mask 1 0b001 2 0b010 3 0b100
uint8_t LP5562::floatToCurrent | ( | float | value | ) | const |
Convert a current value in mA to the format used by the LP5562.
value | Value in mA |
|
inline |
Get the value of the status/interrupt register.
Reading the status/interrupt register will clear any interrupts that are set.
uint8_t LP5562::readRegister | ( | uint8_t | reg | ) |
Low-level call to read a register value.
reg | The register to read (0x00 to 0x70) |
void LP5562::setB | ( | uint8_t | blue | ) |
Sets the PWM for the blue channel.
blue | value 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.
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.
red | value 0 - 255. 0 = off, 255 = full brightness. |
green | value 0 - 255. 0 = off, 255 = full brightness. |
blue | value 0 - 255. 0 = off, 255 = full brightness. |
msOn | The number of milliseconds to be on (1 - 61916) |
msOff | The number of milliseconds to be off (1 - 61916) |
|
inline |
Set blinking mode on the RGB LED.
rgb | Value in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness). |
msOn | The number of milliseconds to be on (1 - 61916) |
msOff | The number of milliseconds to be off (1 - 61916) |
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)
red1 | value 0 - 255. 0 = off, 255 = full brightness. |
green1 | value 0 - 255. 0 = off, 255 = full brightness. |
blue1 | value 0 - 255. 0 = off, 255 = full brightness. |
ms1 | The number of milliseconds to be the 1 color (1 - 61916) |
red2 | value 0 - 255. 0 = off, 255 = full brightness. |
green2 | value 0 - 255. 0 = off, 255 = full brightness. |
blue2 | value 0 - 255. 0 = off, 255 = full brightness. |
ms2 | The number of milliseconds to be the 2 color (1 - 61916) |
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)
rgb1 | Value in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness). |
ms1 | The number of milliseconds to be the 1 color (1 - 61916) |
rgb2 | Value in the form of 0x00RRGGBB. Each of RR, GG, and BB are from 0x00 (off) to 0xFF (full brightness). |
ms2 | The number of milliseconds to be the 2 color (1 - 61916) |
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
red | true to breathe the red channel |
green | true to breathe the green channel |
blue | true to breathe the blue channel |
stepTimeHalfMs | Amount of time between step changes from 1 to 63 in half millisecond increments. |
lowLevel | Start at this level (0 - 255). Typically 0. |
highLevel | End at this level (0 - 255). Typically 255. lowLevel must be < highLevel. |
bool LP5562::setEnable | ( | uint8_t | engineMask, |
uint8_t | engineMode | ||
) |
Enable an engine mode on certain engines.
engineMask | A 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. |
engineMode | One 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.
void LP5562::setG | ( | uint8_t | green | ) |
Sets the PWM for the green channel.
green | value 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.
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
bool LP5562::setLedMapping | ( | uint8_t | red, |
uint8_t | green, | ||
uint8_t | blue, | ||
uint8_t | white | ||
) |
Set ledMapping to program. Not normally necessary.
red | REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3. |
green | REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3. |
blue | REG_LED_MAP_DIRECT (direct RGB, default), REG_LED_MAP_ENGINE_1, REG_LED_MAP_ENGINE_2, or REG_LED_MAP_ENGINE_3. |
white | REG_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.
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
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
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
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
bool LP5562::setOpMode | ( | size_t | engine, |
uint8_t | engineMode | ||
) |
Sets the operation mode register (0x01)
engine | The engine number to set (1, 2, or 3) |
engineMode | The mode to set: REG_ENGINE_DISABLED, REG_ENGINE_LOAD (also resets PC), REG_ENGINE_RUN, REG_ENGINE_DIRECT |
|
inline |
Sets a program on a specified engine from a LP5562Program object.
engine | An engine number 1 <= engine <= 3 |
program | The program to set |
startRunning | true to start the program running immediately or false to leave it in halt mode |
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.
engine | An engine number 1 <= engine <= 3 |
instructions | An array of uint16_t values containing up to 16 instructions. Can be NULL if numInstruction == 0. |
numInstruction | The number of instruction words (0 - 15). |
startRunning | true 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).
void LP5562::setR | ( | uint8_t | red | ) |
Sets the PWM for the red channel.
red | value 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.
void LP5562::setRGB | ( | uint8_t | red, |
uint8_t | green, | ||
uint8_t | blue | ||
) |
Sets the PWM for the R, G, and B channels.
red | value 0 - 255. 0 = off, 255 = full brightness. |
green | value 0 - 255. 0 = off, 255 = full brightness. |
blue | value 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.
void LP5562::setRGB | ( | uint32_t | rgb | ) |
Sets the PWM for the R, G, and B channels.
rgb | Value 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.
void LP5562::setW | ( | uint8_t | white | ) |
Sets the W channel to the specified PWM value.
white | value 0 - 255. 0 = off, 255 = full brightness. |
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!
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!
|
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.
|
inline |
Sets the LED current.
all | The 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.
LP5562 & LP5562::withLEDCurrent | ( | float | red, |
float | green, | ||
float | blue, | ||
float | white = 0.1 |
||
) |
Sets the LED current.
red | The 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. |
green | The 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. |
blue | The 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. |
white | The 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.
|
inline |
Set external oscillator mode. Default is internal.
This method returns a LP5562 object so you can chain multiple configuration calls together, fluent-style.
|
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.
bool LP5562::writeRegister | ( | uint8_t | reg, |
uint8_t | value | ||
) |
Low-level call to write a register value.
reg | The register to read (0x00 to 0x70) |
value | The value to set |
Note that setProgram bypasses this to write multiple bytes at once, to improve efficiency.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.