If you work a lot with NeoPixel, you will quickly notice that the standard module already provides you with a lot, but you still have to code a lot yourself. So that you can save some time and work, here are a few modules that can help you.
With a NeoPixel Matrix you can create incredibly beautiful effects. This module offers you methods to control the LEDs not only via index. You can use x,y - coordinates, draw lines (horizontal, vertical) as well rectangles and numbers (from 0 - 9).
- Waveshare - Pico RGB LED
- or you create own matrix with NeoPixel strips (with rows & cols)
Example
Library & example script
Source Code: Module for
lib/neopixelmatrix.py
# download module
$ curl -L 'https://raw.githubusercontent.com/Lupin3000/ESP/master/lib/neopixelmatrix.py' -o lib/neopixelmatrix.py
Source Code: Example script for
neopixel_matrix.py
Usage example
# copy module file into lib
(venv) $ rshell -p [SERIAL-PORT] cp lib/neopixelmatrix.py
# copy example file into pyboard as main.py
(venv) $ rshell -p [SERIAL-PORT] cp examples/neopixel/neopixel_matrix.py /pyboard/main.py
# start repl
(venv) $ rshell -p [SERIAL-PORT] repl
Start with keys Control
+ d
. To leave the REPL, press keys Control
+ x
.
Through inheritance of the neopixelmatrix
module, you can easily extend the module to draw simple icons on the Matrix. This saves you a lot of time, and you don't have to control every NeoPixel (using the existing methods of the module).
The icons are not real pictures! By the way ... the same principle is used in the tutorial for OLED Display (ssd1306).
Source Code for
neopixel_matrix_icon.py
# copy example file into pyboard as main.py
(venv) $ rshell -p [SERIAL-PORT] cp examples/neopixel/neopixel_matrix_icon.py /pyboard/main.py
# start repl
(venv) $ rshell -p [SERIAL-PORT] repl
Start with keys Control
+ d
or press reset
key. To stop the loop press keys Control
+ c
, to leave the REPL, press keys Control
+ x
.
You could also display multicolored icons! For example by specifying further numbers like 2, 3, 4 (inside the icon definition) and so on with the respective RGB tuples (as method parameters).
This small example should show you further possibilities with an LED matrix. You will also learn a few basics about random number generators.
Source Code for
neopixel_matrix_bounce.py
# copy example file into pyboard as main.py
(venv) $ rshell -p [SERIAL-PORT] cp examples/neopixel/neopixel_matrix_bounce.py /pyboard/main.py
# start repl
(venv) $ rshell -p [SERIAL-PORT] repl
Start with keys Control
+ d
or press reset
key. To stop the loop press keys Control
+ c
, to leave the REPL, press keys Control
+ x
.