From 8622ae1c82ff7c437a14f5a84ba47da4f8d9ad3b Mon Sep 17 00:00:00 2001 From: IFX-Anusha Date: Wed, 21 Aug 2024 13:19:17 +0530 Subject: [PATCH] docs/psoc6: Neopixel documentation. Signed-off-by: IFX-Anusha --- docs/psoc6/quickref.rst | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/psoc6/quickref.rst b/docs/psoc6/quickref.rst index a674b7a235ccf..dfb7f5e0e2d9d 100644 --- a/docs/psoc6/quickref.rst +++ b/docs/psoc6/quickref.rst @@ -48,13 +48,40 @@ The :mod:`machine` module:: from machine import bitstream - timing = [1000, 7000, 5000, 2500] #timing (high_time_0, low_time_0, high_time_1, low_time_1)in ns - buf = bytearray([0xAB]) #buffer data + timing = [1000, 7000, 5000, 2500] # timing (high_time_0, low_time_0, high_time_1, low_time_1)in ns + buf = bytearray([0xAB]) # buffer data bitstream('P13_6', 0, timing, buf) # bitstrem buffer data with timing through pin P13_6 .. note:: + Bitstream is set for the CPU frequency of 100MHz. At other clock frequencies, the timing will not fit. All timings greater than 1500 ns work and the accuracy of the timing is +/- 400 ns. - Supported timing_ns ranges below 1500 ns is [500, 1125, 800, 750]. + Supported timing_ns ranges below 1500 ns are [500, 1125, 800, 750], [400, 850, 800, 450], [300, 900, 600, 600] and [800, 1700, 1600, 900]. + +Neopixel driver +--------------- + +Neopixel library is supported in this port. The library can be installed using mip. + +:: + + import mip + mip.install('neopixel') + +neopixel driver can be used as follows. see the :mod:`neopixel` for more details. + +:: + + import neopixel + from machine import Pin + p0 = Pin('P9_1', Pin.OUT, value=0) # set P9_1 to output to drive NeoPixels + np = neopixel.NeoPixel(p0,8,bpp=3) # create NeoPixel object on pin P9_1 with 8 pixels and 3 bytes per pixel with default timing=1 + np[0] = (255, 255, 255) # set the first pixel to white + np.write() # write data to all pixels + +.. note:: + - The timing parameter can be used in the Neopixel constructor as timing tuples supported by bitstream() function. The timing parameter is optional and by default set to 1 which is the default timing [400, 850, 800, 450] for WS2812B LEDs at 800kHz. + - Use timing = 0 for WS2812B LEDs at 400kHz ie, [800, 1700, 1600, 900]. + - Use timing = [300, 900, 600, 600] for SK612 LEDs. Delay and timing ----------------