Class for Lumissil IS31FL3741 LED driver. This is the base class upon which the rest of this code builds. It focuses on lowest- level I2C operations and the chip registers, and has no concept of a 2D graphics coordinate system, nor of RGB colors. It is linear and monochromatic.
More...
#include <Adafruit_IS31FL3741.h>
|
| Adafruit_IS31FL3741 () |
| Constructor for IS31FL3741 LED driver.
|
|
bool | begin (uint8_t addr=IS3741_ADDR_DEFAULT, TwoWire *theWire=&Wire) |
| Initialize I2C and IS31FL3741 hardware. More...
|
|
bool | reset (void) |
| Perform software reset, update all registers to POR values. More...
|
|
bool | enable (bool en) |
| Enable/disable output via the shutdown register bit. More...
|
|
bool | unlock (void) |
| Allows changing of command register by writing 0xC5 to 0xFE. More...
|
|
bool | setGlobalCurrent (uint8_t current) |
| Set global current-mirror from 0 (off) to 255 (brightest). More...
|
|
uint8_t | getGlobalCurrent (void) |
| Get the global current-mirror register setting. More...
|
|
bool | setLEDscaling (uint16_t lednum, uint8_t scale) |
| Set the scaling level for a single LED. More...
|
|
bool | setLEDscaling (uint8_t scale) |
| Set the scaling level for all LEDs. Optimized for fewer I2C transfers vs. setting each individually. More...
|
|
bool | setLEDPWM (uint16_t lednum, uint8_t pwm) |
| Set the PWM level for a single LED. More...
|
|
bool | fill (uint8_t fillpwm=0) |
| Set the PWM value for all LEDs - great for clearing the whole display at once. Optimized for fewer I2C transfers vs. setting each individually. More...
|
|
void | show (void) |
| Empty function makes direct & buffered code more interchangeable. Direct classes have an immediate effect when setting LED states, only buffered ones need an explicit call to show(), but it gets annoying when moving code back and forth. So this does nothing in the direct case. For code that you KNOW will always be strictly unbuffered, don't call this, it sets a bad precedent.
|
|
|
static uint16_t | color565 (uint8_t red, uint8_t green, uint8_t blue) |
| Converter for RGB888-format color (separate) to RGB565-format. More...
|
|
static uint16_t | color565 (uint32_t color) |
| Converter for RGB888-format color (packed) to RGB565-format. More...
|
|
static uint32_t | Color (uint8_t r, uint8_t g, uint8_t b) |
| Convert separate red, green and blue values into a single "packed" 24-bit RGB color. More...
|
|
static uint8_t | gamma8 (uint8_t x) |
| An 8-bit gamma-correction function for basic pixel brightness adjustment. Makes color transitions appear more perceptially correct. More...
|
|
static uint32_t | gamma32 (uint32_t x) |
| A gamma-correction function for 32-bit packed RGB colors. Makes color transitions appear more perceptially correct. More...
|
|
static uint32_t | ColorHSV (uint16_t hue, uint8_t sat=255, uint8_t val=255) |
| Convert hue, saturation and value into a packed 32-bit RGB color that can be passed to setPixelColor() or Color565(). Swiped directly from Adafruit_NeoPixel. More...
|
|
|
bool | selectPage (uint8_t page) |
| Select a given bank/page in the chip memory for subsequent reads/writes. More...
|
|
bool | setLEDvalue (uint8_t first_page, uint16_t lednum, uint8_t value) |
| Set either the PWM or scaling level for a single LED; used by the setLEDPWM() and setLEDscaling() functions, not directly. More...
|
|
bool | fillTwoPages (uint8_t first_page, uint8_t value) |
| Fill two pages of IS31FL3741 registers related to PWM levels or scaling; used by the fill() and setLEDscaling() functions, not directly. More...
|
|
|
int8_t | _page = -1 |
| Cached value of the page we're currently addressing.
|
|
Adafruit_I2CDevice * | _i2c_dev = NULL |
| Pointer to I2C device.
|
|
Class for Lumissil IS31FL3741 LED driver. This is the base class upon which the rest of this code builds. It focuses on lowest- level I2C operations and the chip registers, and has no concept of a 2D graphics coordinate system, nor of RGB colors. It is linear and monochromatic.
◆ begin()
bool Adafruit_IS31FL3741::begin |
( |
uint8_t |
addr = IS3741_ADDR_DEFAULT , |
|
|
TwoWire * |
theWire = &Wire |
|
) |
| |
Initialize I2C and IS31FL3741 hardware.
- Parameters
-
addr | I2C address where we expect to find the chip. |
theWire | Pointer to TwoWire I2C bus to use, defaults to &Wire. |
- Returns
- true on success, false if chip isn't found.
◆ reset()
bool Adafruit_IS31FL3741::reset |
( |
void |
| ) |
|
Perform software reset, update all registers to POR values.
- Returns
- true if I2C command acknowledged, false on error.
◆ enable()
bool Adafruit_IS31FL3741::enable |
( |
bool |
en | ) |
|
Enable/disable output via the shutdown register bit.
- Parameters
-
en | true to enable, false to disable. |
- Returns
- true if I2C command acknowledged, false on error.
◆ unlock()
bool Adafruit_IS31FL3741::unlock |
( |
void |
| ) |
|
Allows changing of command register by writing 0xC5 to 0xFE.
- Returns
- true if I2C command acknowledged, false on error.
◆ setGlobalCurrent()
bool Adafruit_IS31FL3741::setGlobalCurrent |
( |
uint8_t |
current | ) |
|
Set global current-mirror from 0 (off) to 255 (brightest).
- Parameters
-
current | 8-bit level, 0 to 255. |
- Returns
- true if I2C command acknowledged, false on error.
◆ getGlobalCurrent()
uint8_t Adafruit_IS31FL3741::getGlobalCurrent |
( |
void |
| ) |
|
Get the global current-mirror register setting.
- Returns
- 0 (off) to 255 (brightest)
◆ setLEDscaling() [1/2]
bool Adafruit_IS31FL3741::setLEDscaling |
( |
uint16_t |
lednum, |
|
|
uint8_t |
scale |
|
) |
| |
Set the scaling level for a single LED.
- Parameters
-
lednum | The individual LED to set: 0 to 350. |
scale | Level from 0 to 255. |
- Returns
- true if I2C command acknowledged, false if LED index is out of range or if I2C error.
- Note
- This refers to individual LED registers as controlled by the driver, not RGB pixels – that's a different thing handled in subclasses as needed.
◆ setLEDscaling() [2/2]
bool Adafruit_IS31FL3741::setLEDscaling |
( |
uint8_t |
scale | ) |
|
Set the scaling level for all LEDs. Optimized for fewer I2C transfers vs. setting each individually.
- Parameters
-
scale | Level from 0 to 255. |
- Returns
- true if I2C transfers completed successfully, false on error.
◆ setLEDPWM()
bool Adafruit_IS31FL3741::setLEDPWM |
( |
uint16_t |
lednum, |
|
|
uint8_t |
pwm |
|
) |
| |
Set the PWM level for a single LED.
- Parameters
-
lednum | The individual LED to set: 0 to 350. |
pwm | Level from 0 to 255. |
- Returns
- true if I2C command acknowledged, false if LED index is out of range or if I2C error.
- Note
- This refers to individual LED registers as controlled by the driver, not RGB pixels – that's a different thing handled in subclasses as needed.
◆ fill()
bool Adafruit_IS31FL3741::fill |
( |
uint8_t |
fillpwm = 0 | ) |
|
Set the PWM value for all LEDs - great for clearing the whole display at once. Optimized for fewer I2C transfers vs. setting each individually.
- Parameters
-
fillpwm | PWM level from 0 to 255, default is 0 (off). |
- Returns
- true if I2C transfers completed successfully, false on error.
◆ color565() [1/2]
static uint16_t Adafruit_IS31FL3741::color565 |
( |
uint8_t |
red, |
|
|
uint8_t |
green, |
|
|
uint8_t |
blue |
|
) |
| |
|
inlinestatic |
Converter for RGB888-format color (separate) to RGB565-format.
- Parameters
-
red | 8-bit red value. |
green | 8-bit green value. |
blue | 8-bit blue value. |
- Returns
- Packed 16-bit RGB565 color.
- Note
- Yes, the name is unfortunate – have lowercase color565() here, and uppercase Color and ColorHSV() later. This is for compatibility with existing code from Adafruit_GFX and Adafruit_NeoPixel, which were separately developed and used differing cases. The idea here is to help re-use existing Arduino sketch code from other projects, so don't "fix" this.
◆ color565() [2/2]
static uint16_t Adafruit_IS31FL3741::color565 |
( |
uint32_t |
color | ) |
|
|
inlinestatic |
Converter for RGB888-format color (packed) to RGB565-format.
- Parameters
-
color | 24-bit value (0x00RRGGBB) |
- Returns
- Packed 16-bit RGB565 color (0bRRRRRGGGGGGBBBBB)
- Note
- See notes above re: naming.
◆ Color()
static uint32_t Adafruit_IS31FL3741::Color |
( |
uint8_t |
r, |
|
|
uint8_t |
g, |
|
|
uint8_t |
b |
|
) |
| |
|
inlinestatic |
Convert separate red, green and blue values into a single "packed" 24-bit RGB color.
- Parameters
-
r | Red brightness, 0 to 255. |
g | Green brightness, 0 to 255. |
b | Blue brightness, 0 to 255. |
- Returns
- Packed RGB value, which can then be assigned to a variable for later use or passed to the setPixelColor() function in some subclasses. Packed RGB format is predictable (0x00RRGGBB), regardless of LED color order.
◆ gamma8()
static uint8_t Adafruit_IS31FL3741::gamma8 |
( |
uint8_t |
x | ) |
|
|
inlinestatic |
An 8-bit gamma-correction function for basic pixel brightness adjustment. Makes color transitions appear more perceptially correct.
- Parameters
-
x | Input brightness, 0 (minimum or off/black) to 255 (maximum). |
- Returns
- Gamma-adjusted brightness, can then be passed to one of the setPixelColor() functions. This uses a fixed gamma correction exponent of 2.6, which seems reasonably okay for average RGB LEDs in average tasks. If you need finer control you'll need to provide your own gamma-correction function instead.
- Note
- Copied from Adafruit_NeoPixel, only the table name changed.
◆ gamma32()
uint32_t Adafruit_IS31FL3741::gamma32 |
( |
uint32_t |
x | ) |
|
|
static |
A gamma-correction function for 32-bit packed RGB colors. Makes color transitions appear more perceptially correct.
- Parameters
-
- Returns
- Gamma-adjusted packed color, can then be passed in one of the setPixelColor() functions. Like gamma8(), this uses a fixed gamma correction exponent of 2.6, which seems reasonably okay for average NeoPixels in average tasks. If you need finer control you'll need to provide your own gamma-correction function instead.
◆ ColorHSV()
uint32_t Adafruit_IS31FL3741::ColorHSV |
( |
uint16_t |
hue, |
|
|
uint8_t |
sat = 255 , |
|
|
uint8_t |
val = 255 |
|
) |
| |
|
static |
Convert hue, saturation and value into a packed 32-bit RGB color that can be passed to setPixelColor() or Color565(). Swiped directly from Adafruit_NeoPixel.
- Parameters
-
hue | An unsigned 16-bit value, 0 to 65535, representing one full loop of the color wheel, which allows 16-bit hues to "roll
over" while still doing the expected thing (and allowing more precision than the wheel() function that was common to prior NeoPixel examples). |
sat | Saturation, 8-bit value, 0 (min or pure grayscale) to 255 (max or pure hue). Default of 255 if unspecified. |
val | Value (brightness), 8-bit value, 0 (min / black / off) to 255 (max or full brightness). Default of 255 if unspecified. |
- Returns
- Packed 32-bit RGB with the most significant byte set to 0. Result is linearly but not perceptually correct, so you may want to pass the result through a gamma function.
- Note
- Yes, the name is unfortunate – have uppercase ColorHSV() here, and lowercase color565() elsewhere. This is for compatibility with existing code from Adafruit_NeoPixel amd Adafruit_GFX, which were separately developed and used differing cases. The idea here is to help re-use existing Arduino sketch code, so don't "fix."
◆ selectPage()
bool Adafruit_IS31FL3741::selectPage |
( |
uint8_t |
page | ) |
|
|
protected |
Select a given bank/page in the chip memory for subsequent reads/writes.
- Parameters
-
page | The IS41 page to switch to (0 to 4). |
- Returns
- true if I2C command acknowledged, false on invalid page or I2C error.
◆ setLEDvalue()
bool Adafruit_IS31FL3741::setLEDvalue |
( |
uint8_t |
first_page, |
|
|
uint16_t |
lednum, |
|
|
uint8_t |
value |
|
) |
| |
|
protected |
Set either the PWM or scaling level for a single LED; used by the setLEDPWM() and setLEDscaling() functions, not directly.
- Parameters
-
first_page | Determines whether scaling or PWM will be set: 0 for PWM, 2 for scaling. |
lednum | The individual LED to set: 0 to 350. |
value | PWM or scaling value from 0 to 255. |
- Returns
- true if I2C command acknowledged, false if LED index is out of range or if I2C error.
- Note
- This refers to individual LED registers as controlled by the driver, not RGB pixels – that's a different thing handled in subclasses as needed.
◆ fillTwoPages()
bool Adafruit_IS31FL3741::fillTwoPages |
( |
uint8_t |
first_page, |
|
|
uint8_t |
value |
|
) |
| |
|
protected |
Fill two pages of IS31FL3741 registers related to PWM levels or scaling; used by the fill() and setLEDscaling() functions, not directly.
- Parameters
-
first_page | First of two successive pages to fill; usually 0 or 2. |
value | Setting from 0 to 255. |
- Returns
- true if I2C transfers completed successfully, false on error.
The documentation for this class was generated from the following files: