pymcu-lib-neopixel
WS2812 / NeoPixel addressable LED strips for PyMCU — compiled to native machine code, with no interpreter on the chip.
pymcu install neopixel
The same strip, three APIs
Which one you get depends on the stdlib layer your project declares. The import is
always neopixel.
Native (stdlib unset):
from neopixel import NeoPixel
strip = NeoPixel("PD6", 8)
strip[0] = (255, 0, 0)
strip.show()
MicroPython (stdlib = ["micropython"]) — a MicroPython script, unchanged:
from machine import Pin
from neopixel import NeoPixel
np = NeoPixel(Pin(6), 8)
np[0] = (255, 0, 0)
np.write()
CircuitPython (stdlib = ["circuitpython"]) — a CircuitPython script, unchanged:
import board
import neopixel
pixels = neopixel.NeoPixel(board.D6, 8, auto_write=False)
pixels.fill((0, 32, 0))
pixels.show()
None of those three files contains a single conditional: the layer adapters are plain
Python written against each API as it is documented upstream. Everything that has to
know about a chip lives in one private module, _neopixel_core, and the compiler folds
it away.
Cost
Colours live in a per-strip SRAM framebuffer, 3 bytes per pixel in WS2812 wire order —
24 bytes for a strip of 8, and nothing else. Every method is @inline, so no object is
allocated on the device and no method call survives compilation.
Measured figures per chip are published in the library index, and the flash cost of every example in this repo is in docs/Getting-started.md.
Supported hardware
WS2812 / WS2812B / NeoPixel strips on AVR (ATmega328P and friends) at 16 MHz, on
pins PB0-PB5 and PD2-PD7. show() / write() disables interrupts for the
duration of the transmission and restores them afterwards, since WS2812 bit timing has
no clock line to resynchronize against — see
docs/How-it-works.md.
Bit timing (750 ns / 437.5 ns high pulses, inside both the WS2812 and WS2812B
datasheet windows) is verified by tests/test_timing.py, which compiles a probe
program and measures it cycle-by-cycle on the avr8sharp AVR emulator — not yet
verified against a real strip on a logic analyzer. One pin, PB0, is not yet covered
by this fix and should be avoided until it is. See
docs/How-it-works.md
for the measured numbers, the PB0 gap, and how the numbers were obtained.
Other architectures raise a compile-time error rather than returning something that
looks like it worked. Ports are welcome: _neopixel_avr.py is the whole contract —
see docs/Porting-to-a-new-architecture.md.
Examples
Five complete, buildable PyMCU projects live under
src/pymcu_lib_neopixel/examples/: the native,
MicroPython and CircuitPython APIs doing the same fill-and-blink, plus a per-pixel
colour wipe and an auto_write demo. See
docs/Getting-started.md for how to build them and their
measured flash cost.
Documentation
- docs/Home.md — start here
- docs/Getting-started.md
- docs/The-three-APIs.md
- docs/How-it-works.md
- docs/Porting-to-a-new-architecture.md
- docs/Troubleshooting.md
License
MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymcu_lib_neopixel-0.1.1.tar.gz.
File metadata
- Download URL: pymcu_lib_neopixel-0.1.1.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05734669c0903fcafc45498ad48350148ecb05ac138a6975c9c1bd694e114b04
|
|
| MD5 |
4cc2796e6991fa10b04c3fd8a4911de7
|
|
| BLAKE2b-256 |
2b297c1d2f38d0b48a8b7dc3a333d6a5a9afba1c1277bbfa9821c73e36cd25c8
|
Provenance
The following attestation bundles were made for pymcu_lib_neopixel-0.1.1.tar.gz:
Publisher:
publish.yml on PyMCU/pymcu-lib-neopixel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcu_lib_neopixel-0.1.1.tar.gz -
Subject digest:
05734669c0903fcafc45498ad48350148ecb05ac138a6975c9c1bd694e114b04 - Sigstore transparency entry: 2495936375
- Sigstore integration time:
-
Permalink:
PyMCU/pymcu-lib-neopixel@2c8696a8964525b7b07cf3a7337b346f9eb1966a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/PyMCU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c8696a8964525b7b07cf3a7337b346f9eb1966a -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymcu_lib_neopixel-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pymcu_lib_neopixel-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0add8477b617e4014c02d5b6d3b7829dba031a74d1f44cfb6035ac5a62a9bb30
|
|
| MD5 |
855ff46ec4aaf13104bd930685b4d49a
|
|
| BLAKE2b-256 |
20622d23fa1a587cd246ba5f73d9beb4245e5d1a02ac7b5ca25b1b1329cb8ebf
|
Provenance
The following attestation bundles were made for pymcu_lib_neopixel-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on PyMCU/pymcu-lib-neopixel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcu_lib_neopixel-0.1.1-py3-none-any.whl -
Subject digest:
0add8477b617e4014c02d5b6d3b7829dba031a74d1f44cfb6035ac5a62a9bb30 - Sigstore transparency entry: 2495937122
- Sigstore integration time:
-
Permalink:
PyMCU/pymcu-lib-neopixel@2c8696a8964525b7b07cf3a7337b346f9eb1966a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/PyMCU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c8696a8964525b7b07cf3a7337b346f9eb1966a -
Trigger Event:
release
-
Statement type: