Skip to content

Commit 9c628d8

Browse files
committed
apa102: fix end frame
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 <[email protected]>
1 parent d4b7bf9 commit 9c628d8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/led_strip/apa102.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,17 @@ static int apa102_update(const struct device *dev, void *buf, size_t size)
2121
{
2222
const struct apa102_config *config = dev->config;
2323
static const uint8_t zeros[] = { 0, 0, 0, 0 };
24-
static const uint8_t ones[] = { 0xFF, 0xFF, 0xFF, 0xFF };
24+
25+
/*
26+
* the only function of the “End frame” is to supply more clock pulses
27+
* to the string until the data has permeated to the last LED. The
28+
* number of clock pulses required is exactly half the total number
29+
* of LEDs in the string
30+
*/
31+
uint8_t ones[((size / sizeof(struct led_rgb)) / 2) + 1];
32+
33+
memset(ones, 0xFF, sizeof(ones));
34+
2535
const struct spi_buf tx_bufs[] = {
2636
{
2737
/* Start frame: at least 32 zeros */

0 commit comments

Comments
 (0)