Class daisy::LedDriverPca9685¶
template <int numDrivers, bool persistentBufferContents>
ClassList > daisy > LedDriverPca9685
#include <leddriver.h>
Public Types¶
Type | Name |
---|---|
typedef PCA9685TransmitBuffer[numDrivers] | DmaBuffer |
Public Functions¶
Type | Name |
---|---|
constexpr int | GetNumLeds () const |
void | Init (I2CHandle i2c, const uint8_t(&) addresses, DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, Pin oe_pin=Pin(PORTX, 0)) |
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 () |
struct | __attribute__ ((packed)) |
Detailed Description¶
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.
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.
Public Types Documentation¶
typedef DmaBuffer¶
using daisy::LedDriverPca9685< numDrivers, persistentBufferContents >::DmaBuffer = PCA9685TransmitBuffer[numDrivers];
Buffer type for the entire DMA buffer.
Public Functions Documentation¶
function GetNumLeds¶
Returns the number of leds available from this driver.
function Init¶
inline void daisy::LedDriverPca9685::Init (
I2CHandle i2c,
const uint8_t (&) addresses,
DmaBuffer dma_buffer_a,
DmaBuffer dma_buffer_b,
Pin oe_pin=Pin ( PORTX , 0)
)
Initialises the driver.
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 <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 <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.
function SetAllTo [½]¶
Sets all leds to a gamma corrected brightness between 0.0f and 1.0f.
function SetAllTo [2/2]¶
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 [2/2]¶
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.
function __attribute__¶
Buffer Type for a single PCA9685 driver chip.
The documentation for this class was generated from the following file external-docs/libDaisy/src/dev/leddriver.h