This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new d9d6491  drivers/leds/ws2812: optimize reset bytes
d9d6491 is described below

commit d9d649105d179ca82ceefd22ad5d10ba66d8934e
Author: Diego Herranz <diegoherr...@diegoherranz.com>
AuthorDate: Wed Dec 9 09:36:15 2020 +0000

    drivers/leds/ws2812: optimize reset bytes
    
    It's not necessary to send a reset pulse after sending the RGB data
    since the first thing that a new transmission does is sending the long
    reset pulse. I have left 1 reset byte after the RGB data to keep some
    padding given that the bits inside the byte are shifted by 1 bit although
    I think it wouldn't be necessary either. But just in case.
    
    This reduces the memory usage (you can easily save 60 bytes) and increases
    the maximum refresh rate.
---
 drivers/leds/ws2812.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/ws2812.c b/drivers/leds/ws2812.c
index bc58f9d..867a183 100644
--- a/drivers/leds/ws2812.c
+++ b/drivers/leds/ws2812.c
@@ -78,17 +78,17 @@
 #define WS2812_RW_PIXEL_SIZE  4
 
 /* Transmit buffer looks like:
- * [<----reset bytes---->|<-RGBn->...<-RGB0->|<----reset bytes---->]
+ * [<----N reset bytes---->|<-RGBn->...<-RGB0->|<----1 reset byte---->]
  *
  * It is important that this is shipped as close to one chunk as possible
  * in order to meet timing requirements and to keep MOSI from going high
  * between transactions.  Some chips will leave MOSI at the state of the
  * MSB of the last byte for this reason it is recommended to shift the
  * bits that represents the zero or one waveform so that the MSB is 0.
- * The reset clocks will pad the shortened low at the end.
+ * The reset byte after the RGB data will pad the shortened low at the end.
  */
 
-#define TXBUFF_SIZE(n) (WS2812_RST_CYCLES * 2 + n * WS2812_BYTES_PER_LED)
+#define TXBUFF_SIZE(n) (WS2812_RST_CYCLES + n * WS2812_BYTES_PER_LED + 1)
 
 /****************************************************************************
  * Private Types

Reply via email to