Skip to content

Commit

Permalink
basic matrix portal support
Browse files Browse the repository at this point in the history
  • Loading branch information
RetiredWizard committed Jun 22, 2023
1 parent 07132ea commit a52904a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ The setup batch file will then copy the programs and libraries appropriate for t
## Implemented DOS Commands:
(syntax and descriptions taken from https://home.csulb.edu/~murdock/dosindex.html)

PyDOS requires all switches to immediatly following the command with no spaces between the command or switches.
PyDOS requires all switches to immediatly follow the command with no spaces between the command or switches. This
is necessary becuase PyDOS currently adopts the *nix forward slash directory seperator rather than the DOS back slash.

If a command argument contains spaces the argument must be enclosed in quotes.

Expand Down Expand Up @@ -71,7 +72,7 @@ Example: `prompt $e[44m$p$g` sets the backgound blue and displays the current di
**TYPE (MORE)[/P] [path]filename** - Displays the contents of a file.
- /P Pauses after each screenful of information (Q or C to abort listing)

**CD [[d:]path]** - Displays working (current) directory and/or changes to a different directory.
**CD [[d:]path]** - Displays working (current) directory or changes to a different directory.
**CD ..** - Changes to parent directory of current directory.

**MKDIR (MD) path** - Creates a new subdirectory.
Expand Down Expand Up @@ -128,7 +129,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]** (ESP32xxx, Pico W and Nano Connect) - sets the time and date using the Internet NTP protocol
**ntpdate.py [timzone offset]** (WiFi enabled boards) - sets the time and date using the Internet NTP protocol

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

Expand Down Expand Up @@ -166,6 +167,10 @@ replaced or modified from the host computer so that it contains the following in

and then power cycled or hard reset.

**WiFi Enabled Boards Only**
**wifi_finance** - Displays the current Nasdaq prices by connecting to finance.yahoo.com and scraping the website.

**wifi_weather** - Displays the 7 day forcast from api.weather.gov

## Hardware (Pin) customization file (pydos_bcfg.py)

Expand Down Expand Up @@ -334,3 +339,4 @@ At the REPL prompt type "**import PyDOS*** to start PyDOS and then type **setup*
- Rename should allow wildcards in filenames, i.e. "rename *.bas *.txt" or "rename code.py *.sav"
- Quiet, /Q switches to DEL, RMDIR, COPY, XCOPY commands
- PgUp/PgDwn support in fileview.py
- switch directory seperator to back slash
14 changes: 14 additions & 0 deletions cpython/boardconfigs/pydos_bcfg_matrixportal_m4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PyDOS Board Configuration for Adafruit 'matrixportal_m4'

import board

Pydos_pins = {
'sndPin' : (board.A2,"A2"),
'neoPixel' : (board.NEOPIXEL,"NEOPIXEL"),
'SCL' : (board.SCL,"SCL"),
'SDA' : (board.SDA,"SDA"),
'SCK' : [(board.SCK,"SCK")],
'MOSI' : [(board.MOSI,"MOSI")],
'MISO' : [(board.MISO,"MISO")],
'CS' : [(board.A3,"A3")]
}
24 changes: 15 additions & 9 deletions lib/pydos_wifi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyDOS_wifi_VER = "1.20"
PyDOS_wifi_VER = "1.21"

import os
import time
Expand All @@ -8,7 +8,7 @@
import board
import adafruit_requests as requests

if board.board_id == 'arduino_nano_rp2040_connect':
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
import busio
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
Expand Down Expand Up @@ -55,7 +55,7 @@ def __init__(self,timeout=15000):
self._poller = None

if implementation.name.upper() == "CIRCUITPYTHON":
if board.board_id == 'arduino_nano_rp2040_connect':
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
self._https = requests
elif implementation.name.upper() == 'MICROPYTHON':
self._socket = socket
Expand Down Expand Up @@ -91,7 +91,7 @@ def getenv(self,tomlKey):
@property
def is_connected(self):
if implementation.name.upper() == "CIRCUITPYTHON":
if board.board_id == 'arduino_nano_rp2040_connect':
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
if self.esp != None:
retVal = self.esp.is_connected
else:
Expand All @@ -109,15 +109,21 @@ def is_connected(self):

def connect(self,ssid,passwd,espspi_debug=False):
if implementation.name.upper() == "CIRCUITPYTHON":
if board.board_id == 'arduino_nano_rp2040_connect':
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
if not self.is_connected:
# ESP32 pins
self._esp32_cs = DigitalInOut(board.CS1)
if 'ESP_CS' in dir(board):
self._esp32_cs = DigitalInOut(board.ESP_CS)
else:
self._esp32_cs = DigitalInOut(board.CS1)
self._esp32_ready = DigitalInOut(board.ESP_BUSY)
self._esp32_reset = DigitalInOut(board.ESP_RESET)

# uses the secondary SPI connected through the ESP32
self._spi = busio.SPI(board.SCK1, board.MOSI1, board.MISO1)
if 'SCK1' in dir(board):
# uses the secondary SPI connected through the ESP32
self._spi = busio.SPI(board.SCK1, board.MOSI1, board.MISO1)
else:
self._spi = busio.SPI(board.SCK, board.MOSI, board.MISO)

self.esp = adafruit_esp32spi.ESP_SPIcontrol(self._spi, self._esp32_cs, \
self._esp32_ready, self._esp32_reset, debug=espspi_debug)
Expand Down Expand Up @@ -275,7 +281,7 @@ def next(self,size=256):

def close(self):
if implementation.name.upper() == 'CIRCUITPYTHON':
if board.board_id == 'arduino_nano_rp2040_connect':
if board.board_id in ['arduino_nano_rp2040_connect'] or 'ESP_CS' in dir(board):
self.esp.disconnect()
self.esp = None
self._esp32_cs.deinit()
Expand Down
8 changes: 6 additions & 2 deletions setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ rem Feather Huzzah may need the sound pin mod but doesn't have the memory to spa
if "%_boardID%" == "adafruit_feather_huzzah32" del /autoexec.bat
if "%_boardID%" == "adafruit_feather_huzzah32" del /boot.py
if "%_boardID%" == "adafruit_feather_huzzah32" goto copy_code
if "%_boardID%" == "matrixportal_m4" goto copy_code
if %_ans2% == E goto skip_codecopy
if exist /lib/pydos_wifi.py del /lib/pydos_wifi.py
if exist /ntpdate.py del /ntpdate.py
Expand Down Expand Up @@ -173,7 +174,8 @@ goto bbkeyboard
rename /lib/pydos_ui.py /lib/pydos_ui_uart.py
echo copy /cpython/lib/optional/pydos_ui_bbkeybd.py /lib/pydos_ui.py
copy /cpython/lib/optional/pydos_ui_bbkeybd.py /lib/pydos_ui.py
copy /lib/pydos_ui.py /lib/pydos_ui_kfw.py
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/

Expand All @@ -200,15 +202,17 @@ echo copy /cpython/boardconfigs/pydos_bcfg_cytron_maker_pi_pico.py /lib/pydos_bc
copy/y /cpython/boardconfigs/pydos_bcfg_cytron_maker_pi_pico.py /lib/pydos_bcfg.py

:wifienv
if "%_boardID%" == "matrixportal_m4" goto entercreds
if %_ans2% == O goto done

:entercreds
set/p _ans3 = Enter Wifi credentials now (/settings.toml file can be edited later) (Y/N)?:
if %_ans3% == N goto done
if %_ans3% == n goto done
if %_ans3% == Y goto dotenv
if %_ans3% == y goto dotenv
echo Invalid Selection (Y or N)
goto wifienv
goto entercreds

:dotenv
setenv.py
Expand Down

0 comments on commit a52904a

Please sign in to comment.