Skip to content

Commit

Permalink
apa102: fix end frame
Browse files Browse the repository at this point in the history
end frame is used to supply clock pulses
so that data goes to last LED in the chain.
Thus, it depends on the number of LEDs in
the chain.
Previously, the number of ones sent into
the end frame was hard-coded and limited
the usage of the driver to 64 LEDs in the
strip.

Signed-off-by: Cyril Fougeray <cyril.fougeray@toolsforhumanity.com>
  • Loading branch information
fouge committed Nov 6, 2024
1 parent d4b7bf9 commit 9c628d8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/led_strip/apa102.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ static int apa102_update(const struct device *dev, void *buf, size_t size)
{
const struct apa102_config *config = dev->config;
static const uint8_t zeros[] = { 0, 0, 0, 0 };
static const uint8_t ones[] = { 0xFF, 0xFF, 0xFF, 0xFF };

/*
* the only function of the “End frame” is to supply more clock pulses
* to the string until the data has permeated to the last LED. The
* number of clock pulses required is exactly half the total number
* of LEDs in the string
*/
uint8_t ones[((size / sizeof(struct led_rgb)) / 2) + 1];

memset(ones, 0xFF, sizeof(ones));

const struct spi_buf tx_bufs[] = {
{
/* Start frame: at least 32 zeros */
Expand Down

0 comments on commit 9c628d8

Please sign in to comment.