Skip to content

Latest commit

 

History

History
96 lines (58 loc) · 3.49 KB

009_neopixel_extended.md

File metadata and controls

96 lines (58 loc) · 3.49 KB

NeoPixel Extended

Table of Contents

Prolog

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.

NeoPixel Matrix Module

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).

Requirements

Example

rgb_matrix_panel.jpg

Code

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.

NeoPixel Matrix Icons

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).

Code

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).

NeoPixel Matrix Bounce

This small example should show you further possibilities with an LED matrix. You will also learn a few basics about random number generators.

Code

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.

Home | Previous | Next