Skip to content

Commit 7c8c2bf

Browse files
committed
misc fixes for terminalio display support & running external progams w/o PyDOS
1 parent 57a875c commit 7c8c2bf

File tree

6 files changed

+54
-13
lines changed

6 files changed

+54
-13
lines changed

PyDOS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def PyDOS():
7373
global envVars
7474
if "envVars" not in globals().keys():
7575
envVars = {}
76-
_VER = "1.48"
76+
_VER = "1.49"
7777
prmpVals = ['>','(',')','&','|','\x1b','\b','<','=',' ',_VER,'\n','$','']
7878

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

bounce.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
Pydos_ui = None
99

1010
x = 10; y = 10; d = 1; e = 1
11-
m='⬤'
11+
#m='⬤'
12+
m='O'
1213
try:
1314
width = int(envVars.get('_scrWidth',80))
1415
height = int(envVars.get('_scrHeight',24))

cpython/matrix.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
import framebufferio
77
import rgbmatrix
88
import supervisor
9+
from os import getenv
910

1011
try:
1112
type(passedIn)
13+
except:
14+
passedIn = getenv('PYDOS_MATRIX_CONFIG')
15+
16+
try:
1217
args = passedIn.split(',')
1318
[base_width,base_height,bit_depth,chain_across,tile_down] = [int(p) for p in args]
1419
except:

cpython/playimage.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
from supervisor import runtime
1212
try:
1313
from pydos_ui import Pydos_ui
14+
readkbd = Pydos_ui.read_keyboard
15+
sba = Pydos_ui.serial_bytes_available
16+
except:
17+
Pydos_ui = []
18+
from sys import stdin
19+
readkbd = stdin.read
20+
sba = lambda : runtime.serial_bytes_available
21+
try:
1422
from pydos_ui import input
1523
Pydos_display = ('display' in dir(Pydos_ui))
1624
except:
@@ -171,8 +179,8 @@ def playimage(passedIn=""):
171179
cmnd = ""
172180
stop = adafruit_ticks.ticks_add(adafruit_ticks.ticks_ms(),int(dispseconds*1000))
173181
while adafruit_ticks.ticks_less(adafruit_ticks.ticks_ms(),stop):
174-
if Pydos_ui.serial_bytes_available():
175-
cmnd = Pydos_ui.read_keyboard(1)
182+
if sba():
183+
cmnd = readkbd(1)
176184
print(cmnd, end="", sep="")
177185
if cmnd.upper() == "Q":
178186
break
@@ -233,8 +241,8 @@ def playimage(passedIn=""):
233241
stop = adafruit_ticks.ticks_add(adafruit_ticks.ticks_ms(),int(dispseconds*1000))
234242
while adafruit_ticks.ticks_less(adafruit_ticks.ticks_ms(),stop) or singleimage:
235243

236-
if Pydos_ui.serial_bytes_available():
237-
cmnd = Pydos_ui.read_keyboard(1)
244+
if sba():
245+
cmnd = readkbd(1)
238246
print(cmnd, end="", sep="")
239247
if cmnd.upper() == "Q":
240248
break

fileview.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import os
2-
from pydos_ui import Pydos_ui
2+
import supervisor
3+
from sys import implementation
4+
try:
5+
from pydos_ui import Pydos_ui
6+
except:
7+
Pydos_ui = None
8+
from sys import stdin
39
try:
410
from pydos_ui import input
511
except:
612
pass
713
#import uselect
814

9-
def viewFile(args):
15+
def viewFile(args,scrsiz=()):
16+
# scrsiz can be used if running program from REPL to specify the screen dimensions
17+
# first import launches with defaults but subsequent launches can use:
18+
# fileview.viewFile("filename.txt",(height,width))
1019

1120
def chkPath(tstPath):
1221
validPath = True
@@ -60,19 +69,34 @@ def absolutePath(argPath,currDir):
6069

6170
scrLines = int(envVars["_scrHeight"])
6271
scrWidth = int(envVars["_scrWidth"])
72+
elif scrsiz:
73+
(scrLines,scrWidth) = scrsiz
6374
elif 'get_screensize' in dir(Pydos_ui):
6475
(scrLines,scrWidth) = Pydos_ui.get_screensize()
6576
else:
66-
scrLines = 24
67-
scrWidth = 80
77+
if 'height' in dir(supervisor.runtime.display):
78+
scrLines = supervisor.runtime.display.height
79+
scrWidth = supervisor.runtime.display.width
80+
else:
81+
scrLines = 24
82+
scrWidth = 80
83+
84+
try:
85+
type(envVars)
86+
except:
87+
envVars={}
6888

6989
if "_scrollable" in envVars.keys():
7090
scrollable = (envVars["_scrollable"] == True) or (envVars["_scrollable"] == "True")
7191
else:
7292
try:
7393
scrollable = Pydos_ui.scrollable
7494
except:
75-
scrollable = False
95+
if implementation.name.upper() == 'CIRCUITPYTHON':
96+
# Once CircuitPython 9.2.4 is stable this can be change to True
97+
scrollable = False
98+
else:
99+
scrollable = False
76100

77101
savDir = os.getcwd()
78102
args = absolutePath(args,savDir)
@@ -108,7 +132,10 @@ def absolutePath(argPath,currDir):
108132
strtCol = 0
109133
while cmnd.upper() != "Q":
110134
#cmnd = kbdInterrupt()
111-
cmnd = Pydos_ui.read_keyboard(1)
135+
if Pydos_ui:
136+
cmnd = Pydos_ui.read_keyboard(1)
137+
else:
138+
cmnd = stdin.read(1)
112139

113140
if ord(cmnd) == 27 and seqCnt == 0:
114141
seqCnt = 1

lib/pydos_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self):
2424
elif bool(getattr(runtime,'display',False)):
2525
self.display = runtime.display
2626
else:
27-
self.scrollable = True
27+
self.scrollable = True
2828
else:
2929
self.scrollable = True
3030

0 commit comments

Comments
 (0)