Skip to content

Commit f37681e

Browse files
docs: Update V1 neopixel module support for RGBW (bbcmicrobit#736)
* docs: Update V1 neopixel module support for RGBW. Based on the changes added to the V2 documentation from PR bbcmicrobit#694 Co-authored-by: Carlos Pereira Atencio <[email protected]> * docs: Fix typo in NeoPixel module. Co-authored-by: Mark <[email protected]> Co-authored-by: Mark <[email protected]>
1 parent 63ca6de commit f37681e

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

docs/neopixel.rst

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ NeoPixel
44
.. py:module:: neopixel
55
66
The ``neopixel`` module lets you use NeoPixel (WS2812) individually addressable
7-
RGB LED strips with the micro:bit. Note to use the ``neopixel`` module, you
8-
need to import it separately with::
7+
RGB and RGBW LED strips with the micro:bit. Note to use the ``neopixel``
8+
module, you need to import it separately with::
99

1010
import neopixel
1111

@@ -27,6 +27,8 @@ contains everything to plug them into a micro:bit and create funky displays,
2727
art and games such as the demo shown below.
2828

2929
.. image:: neopixel.gif
30+
:alt: Neopixel flexible tile
31+
Image attribution: `adafruit flexible Neopixel matrix <https://www.adafruit.com/product/2547>`_
3032

3133
To connect a strip of neopixels you'll need to attach the micro:bit as shown
3234
below (assuming you want to drive the pixels from pin 0 - you can connect
@@ -50,12 +52,18 @@ Classes
5052
=======
5153

5254
.. py:class::
53-
NeoPixel(pin, n)
55+
NeoPixel(pin, n, bpp=3)
5456

5557
Initialise a new strip of ``n`` number of neopixel LEDs controlled via pin
56-
``pin``. Each pixel is addressed by a position (starting from 0). Neopixels
57-
are given RGB (red, green, blue) values between 0-255 as a tuple. For
58-
example, ``(255,255,255)`` is white.
58+
``pin``. To support RGBW neopixels, a third argument can be passed to
59+
``NeoPixel`` to indicate the number of bytes per pixel (``bpp``).
60+
For RGBW, this is is ``4`` rather than the default of ``3`` for
61+
RGB and GRB.
62+
63+
Each pixel is addressed by a position (starting from 0). Neopixels
64+
are given RGB (red, green, blue) / RGBW (red, green, blue, white)
65+
values between 0-255 as a tuple. For example, in RGB, ``(255,255,255)`` is
66+
white. In RGBW, ``(255,255,255,0)`` or ``(0,0,0,255)`` is white.
5967

6068
.. py:method:: clear()
6169
@@ -87,10 +95,10 @@ Using Neopixels
8795
===============
8896

8997
Interact with Neopixels as if they were a list of tuples. Each tuple represents
90-
the RGB (red, green and blue) mix of colours for a specific pixel. The RGB
91-
values can range between 0 to 255.
98+
the RGB (red, green and blue) / RGBW (red, green,blue and white) mix of colours
99+
for a specific pixel. The RGBW values can range between 0 to 255.
92100

93-
For example, initialise a strip of 8 neopixels on a strip connected to pin0
101+
For example, initialise a strip of 8 RGB neopixels on a strip connected to pin0
94102
like this::
95103

96104
import neopixel

0 commit comments

Comments
 (0)