mirror of
https://github.com/micropython/micropython.git
synced 2025-08-09 12:12:09 +02:00
Some checks are pending
JavaScript code lint and formatting with Biome / eslint (push) Waiting to run
Check code formatting / code-formatting (push) Waiting to run
Check code size / build (push) Waiting to run
Check spelling with codespell / codespell (push) Waiting to run
Check commit message formatting / build (push) Waiting to run
Build docs / build (push) Waiting to run
Check examples / embedding (push) Waiting to run
Package mpremote / build (push) Waiting to run
.mpy file format and tools / test (push) Waiting to run
Build ports metadata / build (push) Waiting to run
cc3200 port / build (push) Waiting to run
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Waiting to run
esp32 port / build_idf (esp32_build_s3_c3) (push) Waiting to run
esp8266 port / build (push) Waiting to run
mimxrt port / build (push) Waiting to run
nrf port / build (push) Waiting to run
powerpc port / build (push) Waiting to run
qemu-arm port / build_and_test (push) Waiting to run
qemu-riscv port / build_and_test (push) Waiting to run
renesas-ra port / build_renesas_ra_board (push) Waiting to run
rp2 port / build (push) Waiting to run
samd port / build (push) Waiting to run
stm32 port / build_stm32 (stm32_misc_build) (push) Waiting to run
stm32 port / build_stm32 (stm32_nucleo_build) (push) Waiting to run
stm32 port / build_stm32 (stm32_pyb_build) (push) Waiting to run
unix port / minimal (push) Waiting to run
unix port / reproducible (push) Waiting to run
unix port / standard (push) Waiting to run
unix port / standard_v2 (push) Waiting to run
unix port / coverage (push) Waiting to run
unix port / coverage_32bit (push) Waiting to run
unix port / nanbox (push) Waiting to run
unix port / float (push) Waiting to run
unix port / stackless_clang (push) Waiting to run
unix port / float_clang (push) Waiting to run
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
Signed-off-by: Tim Weber <scy@scy.name>
75 lines
2.0 KiB
ReStructuredText
75 lines
2.0 KiB
ReStructuredText
:mod:`neopixel` --- control of WS2812 / NeoPixel LEDs
|
|
=====================================================
|
|
|
|
.. module:: neopixel
|
|
:synopsis: control of WS2812 / NeoPixel LEDs
|
|
|
|
This module provides a driver for WS2818 / NeoPixel LEDs.
|
|
|
|
.. note:: This module is only included by default on the ESP8266, ESP32 and RP2
|
|
ports. On STM32 / Pyboard and others, you can either install the
|
|
``neopixel`` package using :term:`mip`, or you can download the module
|
|
directly from :term:`micropython-lib` and copy it to the filesystem.
|
|
|
|
class NeoPixel
|
|
--------------
|
|
|
|
This class stores pixel data for a WS2812 LED strip connected to a pin. The
|
|
application should set pixel data and then call :meth:`NeoPixel.write`
|
|
when it is ready to update the strip.
|
|
|
|
For example::
|
|
|
|
import neopixel
|
|
|
|
# 32 LED strip connected to X8.
|
|
p = machine.Pin.board.X8
|
|
n = neopixel.NeoPixel(p, 32)
|
|
|
|
# Draw a red gradient.
|
|
for i in range(32):
|
|
n[i] = (i * 8, 0, 0)
|
|
|
|
# Update the strip.
|
|
n.write()
|
|
|
|
Constructors
|
|
------------
|
|
|
|
.. class:: NeoPixel(pin, n, *, bpp=3, timing=1)
|
|
|
|
Construct an NeoPixel object. The parameters are:
|
|
|
|
- *pin* is a machine.Pin instance.
|
|
- *n* is the number of LEDs in the strip.
|
|
- *bpp* is 3 for RGB LEDs, and 4 for RGBW LEDs.
|
|
- *timing* is 0 for 400KHz, and 1 for 800kHz LEDs (most are 800kHz). You
|
|
may also supply a timing tuple as accepted by `machine.bitstream()`.
|
|
|
|
Pixel access methods
|
|
--------------------
|
|
|
|
.. method:: NeoPixel.fill(pixel)
|
|
|
|
Sets the value of all pixels to the specified *pixel* value (i.e. an
|
|
RGB/RGBW tuple).
|
|
|
|
.. method:: NeoPixel.__len__()
|
|
|
|
Returns the number of LEDs in the strip.
|
|
|
|
.. method:: NeoPixel.__setitem__(index, val)
|
|
|
|
Set the pixel at *index* to the value, which is an RGB/RGBW tuple.
|
|
|
|
.. method:: NeoPixel.__getitem__(index)
|
|
|
|
Returns the pixel at *index* as an RGB/RGBW tuple.
|
|
|
|
Output methods
|
|
--------------
|
|
|
|
.. method:: NeoPixel.write()
|
|
|
|
Writes the current pixel data to the strip.
|