daisy::LedDriverPca9685¶
#include <leddriver.h>
Public Types¶
Name | |
---|---|
using PCA9685TransmitBuffer[numDrivers] | DmaBuffer |
Public Functions¶
Name | |
---|---|
struct | attribute((packed) ) |
void | Init(I2CHandle i2c, const uint8_t(&) addresses[numDrivers], DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, dsy_gpio_pin oe_pin ={DSY_GPIOX, 0}) |
constexpr int | GetNumLeds() const |
void | SetAllTo(float brightness) |
void | SetAllTo(uint8_t brightness) |
void | SetAllToRaw(uint16_t rawBrightness) |
void | SetLed(int ledIndex, float brightness) |
void | SetLed(int ledIndex, uint8_t brightness) |
void | SetLedRaw(int ledIndex, uint16_t rawBrightness) |
void | SwapBuffersAndTransmit() |
Detailed Description¶
Parameters:
- numDrivers The number of PCA9685 driver attached to the I2C peripheral.
- persistentBufferContents If set to true, the current draw buffer contents will be copied to the next draw buffer during SwapBuffersAndTransmit(). Use this, if you plan to write single leds at a time. If you will alway update all leds before calling SwapBuffersAndTransmit(), you can set this to false and safe some cycles.
LED driver for one or multiple PCA9685 12bit PWM chips connected to a single I2C peripheral. It includes gamma correction from 8bit brightness values but it can also be supplied with raw 12bit values. This driver uses two buffers - one for drawing, one for transmitting. Multiple LedDriverPca9685 instances can be used at the same time.
Public Types Documentation¶
using DmaBuffer¶
using daisy::LedDriverPca9685< numDrivers, persistentBufferContents >::DmaBuffer = PCA9685TransmitBuffer[numDrivers];
Buffer type for the entire DMA buffer.
Public Functions Documentation¶
function attribute¶
Buffer Type for a single PCA9685 driver chip.
register address
cycle at which to switch on the led
cycle at which to switch off the led
full size in bytes
function Init¶
inline void Init(
I2CHandle i2c,
const uint8_t(&) addresses[numDrivers],
DmaBuffer dma_buffer_a,
DmaBuffer dma_buffer_b,
dsy_gpio_pin oe_pin ={DSY_GPIOX, 0}
)
Parameters:
- i2c The I2C peripheral to use.
- addresses An array of addresses for each of the driver chips.
- dma_buffer_a The first buffer for the DMA. This must be placed in D2 memory by adding the DMA_BUFFER_MEM_SECTION attribute like this:
[LedDriverPca9685](/libDaisy/Classes/classdaisy_1_1_led_driver_pca9685/)<2>::DmaBuffer DMA_BUFFER_MEM_SECTION bufferA;
- dma_buffer_b The second buffer for the DMA. This must be placed in D2 memory by adding the DMA_BUFFER_MEM_SECTION attribute like this:
[LedDriverPca9685](/libDaisy/Classes/classdaisy_1_1_led_driver_pca9685/)<2>::DmaBuffer DMA_BUFFER_MEM_SECTION bufferB;
- oe_pin If the output enable pin is used, supply its configuration here. It will automatically be pulled low by the driver.
Initialises the driver.
function GetNumLeds¶
Returns the number of leds available from this driver.
function SetAllTo¶
Sets all leds to a gamma corrected brightness between 0.0f and 1.0f.
function SetAllTo¶
Sets all leds to a gamma corrected brightness between 0 and 255.
function SetAllToRaw¶
Sets all leds to a raw 12bit brightness between 0 and 4095.
function SetLed¶
Sets a single led to a gamma corrected brightness between 0.0f and 1.0f.
function SetLed¶
Sets a single led to a gamma corrected brightness between 0 and 255.
function SetLedRaw¶
Sets a single led to a raw 12bit brightness between 0 and 4095.
function SwapBuffersAndTransmit¶
Swaps the current draw buffer and the current transmit buffer and starts transmitting the values to all chips.
---¶
Updated on 2024-01-03 at 19:41:01 +0000