Skip to content

Commit

Permalink
Add HUB75 RGB Matrix utility & README updates
Browse files Browse the repository at this point in the history
  • Loading branch information
RetiredWizard committed May 10, 2024
1 parent c399b99 commit 70d4df1
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 10 deletions.
2 changes: 1 addition & 1 deletion PyDOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def PyDOS():
global envVars
if "envVars" not in globals().keys():
envVars = {}
_VER = "1.36"
_VER = "1.37"
prmpVals = ['>','(',')','&','|','\x1b','\b','<','=',' ',_VER,'\n','$','']

print("Starting Py-DOS...")
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**Check out the demo video at https://www.youtube.com/watch?v=Az_oiq8GE4Y**

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

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.
Expand Down Expand Up @@ -143,11 +143,15 @@ environment variables to the newly booted environment as well as code that resto
original **code.py**/**main.py** files and causes a second soft reboot returning control to
PyDOS.

**virtrepl.py** - Launches a python REPL that can be run from PyDOS. Type "exit" to close and return to PyDOS.

**edlin.py [[path]filename]** - line editor inspired by DOS edlin. Intial program structure of line editor by Joesph Long
https://github.com/j-osephlong/Python-Text-Editor

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

**bounce.py** - Terminal User Interface demo of a bouncing ball. Modified version of bounce by [DuckyPolice](https://github.com/DuckyPolice)

**xcopy.py[/S][/Y][/V] [path]filename [path][filename]** - a more robust version of the copy command
- /S Copies specified files from directories and subdirectories, except for empty ones
- /Y Suppresses prompting to confirm you want to overwrite an existing destination file
Expand All @@ -160,7 +164,7 @@ PyDOS.

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

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

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

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

**reboot.py** - performs a soft reboot (Micropython requires a Ctrl-D to complete)

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

and then power cycled or hard reset.

**setenv.py** - Helper program for adding the WiFi SSID and Password to settings.toml (used by setup.bat).

*WiFi enabled boards only*
**wifi_finance** - Displays the current Nasdaq prices by connecting to a financial website and scraping the information.
**wifi_weather** - Displays the 7 day forcast from api.weather.gov
Expand Down Expand Up @@ -303,7 +311,7 @@ At the REPL prompt type "**import PyDOS**" to start PyDOS. From PyDOS type **set

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.

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:
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:

storage.remount("/",True)

Expand Down
8 changes: 4 additions & 4 deletions lib/pydos_wifi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyDOS_wifi_VER = "1.36"
PyDOS_wifi_VER = "1.37"

import os
import time
Expand All @@ -9,7 +9,7 @@
import adafruit_requests
import adafruit_connection_manager

if board.board_id == 'arduino_nano_rp2040_connect' or hasattr(board,'ESP_CS'):
if hasattr(board,'ESP_CS'):
import busio
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
Expand Down Expand Up @@ -95,7 +95,7 @@ def is_connected(self):

def connect(self,ssid,passwd,espspi_debug=False):
if implementation.name.upper() == "CIRCUITPYTHON":
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
if 'ESP_CS' in dir(board):
if not self.is_connected:
# ESP32 pins
if 'ESP_CS' in dir(board):
Expand Down Expand Up @@ -282,7 +282,7 @@ def close(self):
self.response.close()
self.response = None
adafruit_connection_manager.connection_manager_close_all(release_references=True)
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
if 'ESP_CS' in dir(board):
self.radio.disconnect()
self.radio = None
self._esp32_cs.deinit()
Expand Down
96 changes: 96 additions & 0 deletions matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This will initalize connected HUB75 RGB Matrix panels as a CircuitPython Display

import board
import displayio
import terminalio
import framebufferio
import rgbmatrix
import supervisor

try:
type(passedIn)
except:
passedIn = ""

if passedIn == '1':
base_width = 64
base_height = 32
bit_depth = 1
chain_across = 1
tile_down = 1
elif passedIn == '4':
base_width = 64
base_height = 32
bit_depth = 1
chain_across = 2
tile_down = 2
else:
try:
base_width = int(input('Panel pixel width (64): '))
except:
base_width = 64
try:
base_height = int(input('Panel pixel height (32): '))
except:
base_height = 32
try:
bit_depth = int(input('Bit Depth (1): '))
except:
bit_depth = 1
try:
chain_across = int(input('Number of panels across (1): '))
except:
chain_across = 1
try:
tile_down = int(input('Number of panels down (1): '))
except:
tile_down = 1

serpentine = True

width = base_width * chain_across
height = base_height * tile_down

displayio.release_displays()

matrix = rgbmatrix.RGBMatrix(
width=width,height=height, bit_depth=bit_depth,
rgb_pins=[
board.MTX_R1,
board.MTX_G1,
board.MTX_B1,
board.MTX_R2,
board.MTX_G2,
board.MTX_B2
],
addr_pins=[
board.MTX_ADDRA,
board.MTX_ADDRB,
board.MTX_ADDRC,
board.MTX_ADDRD
],
clock_pin=board.MTX_CLK,
latch_pin=board.MTX_LAT,
output_enable_pin=board.MTX_OE,
tile=tile_down, serpentine=serpentine,
)
# Associate the RGB matrix with a Display so that we can use displayio features

try:
type(envVars)
except:
envVars = {}

envVars["_display"] = framebufferio.FramebufferDisplay(matrix)

# Remove Blinka and CP Status from top line of display
envVars["_display"].root_group[0].hidden = False
envVars["_display"].root_group[1].hidden = True # logo
envVars["_display"].root_group[2].hidden = True # status bar
supervisor.reset_terminal(envVars["_display"].width, 75)
envVars["_display"].root_group[0].y=-2
envVars["_display"].root_group[0].x=0

envVars["_scrWidth"]=round(envVars["_display"].width/((terminalio.FONT.bitmap.width/95)*displayio.CIRCUITPYTHON_TERMINAL.scale))-1
envVars["_scrHeight"]=round(envVars["_display"].height/(terminalio.FONT.bitmap.height*displayio.CIRCUITPYTHON_TERMINAL.scale))

4 changes: 2 additions & 2 deletions setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ copy /cpython/kbdFeatherWing/lib/* /lib/
rename /lib/pydos_ui.py /lib/pydos_ui_uart.py
echo copy /lib/pydos_ui_kfw.py /lib/pydos_ui.py
copy /lib/pydos_ui_kfw.py /lib/pydos_ui.py
rename /virtrepl.py /repl.py
rem rename /virtrepl.py /repl.py
if %_ans2% == O del /lib/kfw_s2_board.py
if %_ans2% == E del /lib/kfw_pico_board.py
goto wifienv
Expand All @@ -225,7 +225,7 @@ rem Make kfw copy so that ui.bat can be used to switch modes
copy /cpython/lib/optional/pydos_ui_bbkeybd.py /lib/pydos_ui_kfw.py
copy /cpython/kbdFeatherWing/*.bat /
copy /cpython/kbdFeatherWing/lib/bbq10keyboard.* /lib/
rename /virtrepl.py /repl.py
rem rename /virtrepl.py /repl.py

:tftfeatherwing
set/p _ans3 = Do you have a TFT FeatherWing Touch connected (Y/N)?:
Expand Down
2 changes: 2 additions & 0 deletions virtrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
except:
pass

print("REPL in (Circuit-)Python (type exit to close)")

__cmd = ""
while True:
if 'compile_command' in dir():
Expand Down

0 comments on commit 70d4df1

Please sign in to comment.