Basic support for driving a display with rpi_ws281x
NOTE: weatherscene.py is known to NOT work under Python 3.x due to
an incompatibility with MicroPython's handling of strings and bytes.
This can be easily resolved although I opted to not do this, to preserve
compabilitity with the original code.
To use this on a Raspberry Pi, try:
sudo apt install -y python-pip python-requests
sudo pip install rpi_ws281x
Then connect the display's data line to the Raspberry Pi's GPIO 18 (PCM CLK)
(see https://pinout.xyz/)
References:
- https://github.com/noahwilliamsson/lamatrix/issues/1
- https://github.com/rpi-ws281x/rpi-ws281x-python (userspace WS281x driver)
- https://github.com/jgarff/rpi_ws281x (wiring docs)
This commit is contained in:
12
main.py
12
main.py
@@ -36,12 +36,18 @@ if hasattr(sys,'implementation') and sys.implementation.name == 'micropython':
|
||||
tmp = None
|
||||
del uname
|
||||
else:
|
||||
# Emulate https://docs.pycom.io/firmwareapi/micropython/utime.html
|
||||
time.ticks_ms = lambda: int(time.time() * 1000)
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
from arduinoserialhal import ArduinoSerialHAL as HAL
|
||||
# Kludge to allow this project to be used with a Raspberry Pi instead of
|
||||
# an MCU: see https://github.com/noahwilliamsson/lamatrix/issues/1
|
||||
try:
|
||||
# If the rpi_ws281x Python module is available, then use that...
|
||||
from raspberrypihal import RaspberryPiHAL as HAL
|
||||
except:
|
||||
# ...else assume that there's an MCU (driving the display) connected
|
||||
# to a serial port
|
||||
from arduinoserialhal import ArduinoSerialHAL as HAL
|
||||
|
||||
gc.collect()
|
||||
from renderloop import RenderLoop
|
||||
|
||||
Reference in New Issue
Block a user