Skip to content

Commit 70d4df1

Browse files
committed
Add HUB75 RGB Matrix utility & README updates
1 parent c399b99 commit 70d4df1

File tree

6 files changed

+116
-10
lines changed

6 files changed

+116
-10
lines changed

PyDOS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def PyDOS():
6767
global envVars
6868
if "envVars" not in globals().keys():
6969
envVars = {}
70-
_VER = "1.36"
70+
_VER = "1.37"
7171
prmpVals = ['>','(',')','&','|','\x1b','\b','<','=',' ',_VER,'\n','$','']
7272

7373
print("Starting Py-DOS...")

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
**Check out the demo video at https://www.youtube.com/watch?v=Az_oiq8GE4Y**
77

88
*Related Repositories:*
9-
[PyDOS_virtkey](https://github.com/RetiredWizard/PyDOS_virtkeyboard) - The modules needed to add virtual keybaord support to PyDOS
9+
[PyDOS_virtkey](https://github.com/RetiredWizard/PyDOS_virtkeyboard) - The modules needed to add virtual keyboard support to PyDOS
1010
[PyDOS_wifi](https://github.com/RetiredWizard/PyDOS_wifi) - Generalized Python based microcontroller WiFi API
1111

1212
See the Installation section below to install all the external commands and customize the install for the particular microcontroller you are using. However, **if you just want to launch the shell or have limited flash space, the PyDOS.py program will run standadlone** so you can simply copy **PyDOS.py** to your microcontroller to begin.
@@ -143,11 +143,15 @@ environment variables to the newly booted environment as well as code that resto
143143
original **code.py**/**main.py** files and causes a second soft reboot returning control to
144144
PyDOS.
145145

146+
**virtrepl.py** - Launches a python REPL that can be run from PyDOS. Type "exit" to close and return to PyDOS.
147+
146148
**edlin.py [[path]filename]** - line editor inspired by DOS edlin. Intial program structure of line editor by Joesph Long
147149
https://github.com/j-osephlong/Python-Text-Editor
148150

149151
**edit.py [[path]filename]** - shell to load full screen editor from https://github.com/robert-hh/Micropython-Editor
150152

153+
**bounce.py** - Terminal User Interface demo of a bouncing ball. Modified version of bounce by [DuckyPolice](https://github.com/DuckyPolice)
154+
151155
**xcopy.py[/S][/Y][/V] [path]filename [path][filename]** - a more robust version of the copy command
152156
- /S Copies specified files from directories and subdirectories, except for empty ones
153157
- /Y Suppresses prompting to confirm you want to overwrite an existing destination file
@@ -160,7 +164,7 @@ PyDOS.
160164

161165
**setdate.py [mm-dd-yy]** - initalizes the real time clock to an entered date
162166
**settime.py [hh:mm:ss]** - initalizes the real time clock to an entered time
163-
**ntpdate.py [timzone offset]** (WiFi enabled boards) - sets the time and date using the Internet NTP protocol
167+
**getdate.py [timzone offset]** (WiFi enabled boards) - sets the time and date from worldtimeapi.org and failing that, uses the Internet NTP protocol
164168

165169
**diff.py [filename1,filename2]** - performs a file comparison
166170

@@ -183,6 +187,8 @@ CircuitPython LCD libraries from https://github.com/dhylands/python_lcd
183187
**rgbblink.py [rgb led pin number]** - program to blink an onboard neopixel or dotstar
184188
**rgbrainbow.py [rgb led pin number]** - program to color cycle an onboard neopixel or dotstar
185189

190+
**matrix.py** - program to initalize connected HUB75 RGB Matrix Panels as a CircuitPython display. The display object is stored as a PyDOS environment variable (_display)
191+
186192
**reboot.py** - performs a soft reboot (Micropython requires a Ctrl-D to complete)
187193

188194
**keys.bat** - (Keyboard Featherwing/BBQ Keyboard only) Displays keyboard mappings for hidden keys and functions
@@ -198,6 +204,8 @@ replaced or modified from the host computer so that it contains the following in
198204

199205
and then power cycled or hard reset.
200206

207+
**setenv.py** - Helper program for adding the WiFi SSID and Password to settings.toml (used by setup.bat).
208+
201209
*WiFi enabled boards only*
202210
**wifi_finance** - Displays the current Nasdaq prices by connecting to a financial website and scraping the information.
203211
**wifi_weather** - Displays the 7 day forcast from api.weather.gov
@@ -303,7 +311,7 @@ At the REPL prompt type "**import PyDOS**" to start PyDOS. From PyDOS type **set
303311

304312
Once the **setup.bat** script has been run if you have more files to copy to the microcontroller (PyBasic for example) or you want to run **circup**, you will need to give the host computer read/write access to the mounted microcontroller drive. This is done by typing **"fs ro"** at the PyDOS prompt and then power cycling the board.
305313

306-
After running circuip or deleting/copying files using the Host computer, when you want to run PyDOS normally again, edit the **boot.py** file in the root folder of the mounted microcontroller drive (usally CIRCUITPY) and change the line that reads:
314+
After running circuip or deleting/copying files using the Host computer, when you want to run PyDOS normally again, edit the **boot.py** file in the root folder of the mounted microcontroller drive (usually CIRCUITPY) and change the line that reads:
307315

308316
storage.remount("/",True)
309317

lib/pydos_wifi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PyDOS_wifi_VER = "1.36"
1+
PyDOS_wifi_VER = "1.37"
22

33
import os
44
import time
@@ -9,7 +9,7 @@
99
import adafruit_requests
1010
import adafruit_connection_manager
1111

12-
if board.board_id == 'arduino_nano_rp2040_connect' or hasattr(board,'ESP_CS'):
12+
if hasattr(board,'ESP_CS'):
1313
import busio
1414
from digitalio import DigitalInOut
1515
from adafruit_esp32spi import adafruit_esp32spi
@@ -95,7 +95,7 @@ def is_connected(self):
9595

9696
def connect(self,ssid,passwd,espspi_debug=False):
9797
if implementation.name.upper() == "CIRCUITPYTHON":
98-
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
98+
if 'ESP_CS' in dir(board):
9999
if not self.is_connected:
100100
# ESP32 pins
101101
if 'ESP_CS' in dir(board):
@@ -282,7 +282,7 @@ def close(self):
282282
self.response.close()
283283
self.response = None
284284
adafruit_connection_manager.connection_manager_close_all(release_references=True)
285-
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
285+
if 'ESP_CS' in dir(board):
286286
self.radio.disconnect()
287287
self.radio = None
288288
self._esp32_cs.deinit()

matrix.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# This will initalize connected HUB75 RGB Matrix panels as a CircuitPython Display
2+
3+
import board
4+
import displayio
5+
import terminalio
6+
import framebufferio
7+
import rgbmatrix
8+
import supervisor
9+
10+
try:
11+
type(passedIn)
12+
except:
13+
passedIn = ""
14+
15+
if passedIn == '1':
16+
base_width = 64
17+
base_height = 32
18+
bit_depth = 1
19+
chain_across = 1
20+
tile_down = 1
21+
elif passedIn == '4':
22+
base_width = 64
23+
base_height = 32
24+
bit_depth = 1
25+
chain_across = 2
26+
tile_down = 2
27+
else:
28+
try:
29+
base_width = int(input('Panel pixel width (64): '))
30+
except:
31+
base_width = 64
32+
try:
33+
base_height = int(input('Panel pixel height (32): '))
34+
except:
35+
base_height = 32
36+
try:
37+
bit_depth = int(input('Bit Depth (1): '))
38+
except:
39+
bit_depth = 1
40+
try:
41+
chain_across = int(input('Number of panels across (1): '))
42+
except:
43+
chain_across = 1
44+
try:
45+
tile_down = int(input('Number of panels down (1): '))
46+
except:
47+
tile_down = 1
48+
49+
serpentine = True
50+
51+
width = base_width * chain_across
52+
height = base_height * tile_down
53+
54+
displayio.release_displays()
55+
56+
matrix = rgbmatrix.RGBMatrix(
57+
width=width,height=height, bit_depth=bit_depth,
58+
rgb_pins=[
59+
board.MTX_R1,
60+
board.MTX_G1,
61+
board.MTX_B1,
62+
board.MTX_R2,
63+
board.MTX_G2,
64+
board.MTX_B2
65+
],
66+
addr_pins=[
67+
board.MTX_ADDRA,
68+
board.MTX_ADDRB,
69+
board.MTX_ADDRC,
70+
board.MTX_ADDRD
71+
],
72+
clock_pin=board.MTX_CLK,
73+
latch_pin=board.MTX_LAT,
74+
output_enable_pin=board.MTX_OE,
75+
tile=tile_down, serpentine=serpentine,
76+
)
77+
# Associate the RGB matrix with a Display so that we can use displayio features
78+
79+
try:
80+
type(envVars)
81+
except:
82+
envVars = {}
83+
84+
envVars["_display"] = framebufferio.FramebufferDisplay(matrix)
85+
86+
# Remove Blinka and CP Status from top line of display
87+
envVars["_display"].root_group[0].hidden = False
88+
envVars["_display"].root_group[1].hidden = True # logo
89+
envVars["_display"].root_group[2].hidden = True # status bar
90+
supervisor.reset_terminal(envVars["_display"].width, 75)
91+
envVars["_display"].root_group[0].y=-2
92+
envVars["_display"].root_group[0].x=0
93+
94+
envVars["_scrWidth"]=round(envVars["_display"].width/((terminalio.FONT.bitmap.width/95)*displayio.CIRCUITPYTHON_TERMINAL.scale))-1
95+
envVars["_scrHeight"]=round(envVars["_display"].height/(terminalio.FONT.bitmap.height*displayio.CIRCUITPYTHON_TERMINAL.scale))
96+

setup.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ copy /cpython/kbdFeatherWing/lib/* /lib/
203203
rename /lib/pydos_ui.py /lib/pydos_ui_uart.py
204204
echo copy /lib/pydos_ui_kfw.py /lib/pydos_ui.py
205205
copy /lib/pydos_ui_kfw.py /lib/pydos_ui.py
206-
rename /virtrepl.py /repl.py
206+
rem rename /virtrepl.py /repl.py
207207
if %_ans2% == O del /lib/kfw_s2_board.py
208208
if %_ans2% == E del /lib/kfw_pico_board.py
209209
goto wifienv
@@ -225,7 +225,7 @@ rem Make kfw copy so that ui.bat can be used to switch modes
225225
copy /cpython/lib/optional/pydos_ui_bbkeybd.py /lib/pydos_ui_kfw.py
226226
copy /cpython/kbdFeatherWing/*.bat /
227227
copy /cpython/kbdFeatherWing/lib/bbq10keyboard.* /lib/
228-
rename /virtrepl.py /repl.py
228+
rem rename /virtrepl.py /repl.py
229229

230230
:tftfeatherwing
231231
set/p _ans3 = Do you have a TFT FeatherWing Touch connected (Y/N)?:

virtrepl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
except:
99
pass
1010

11+
print("REPL in (Circuit-)Python (type exit to close)")
12+
1113
__cmd = ""
1214
while True:
1315
if 'compile_command' in dir():

0 commit comments

Comments
 (0)