Skip to content

Commit 0282c05

Browse files
committed
update to new fourwire module, proper use of edit shell, PyBasic decimal format fix
1 parent 7c8c2bf commit 0282c05

File tree

10 files changed

+55
-23
lines changed

10 files changed

+55
-23
lines changed

PyBasic/PyBasic README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,6 @@ control flow changes to the Program object, is used consistently throughout the
10071007

10081008
* It is not possible to renumber a program. This would require considerable extra functionality.
10091009
* Negative values are printed with a space (e.g. '- 5') in program listings because of tokenization. This does not affect functionality.
1010-
* Decimal values less than one must be expressed with a leading zero (i.e. 0.34 rather than .34)
10111010
* User input values cannot be directly assigned to array variables in an **INPUT** or **READ** statement
10121011
* Strings representing numbers (e.g. "10") can actually be assigned to numeric variables in **INPUT** and **READ** statements without an
10131012
error, Python will silently convert them to integers.

PyBasic/lexer.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ def tokenize(self, stmt):
9999
break
100100

101101
# Process numbers
102-
elif c.isdigit():
103-
token.category = Token.UNSIGNEDINT
104-
found_point = False
102+
elif c.isdigit() or c == ".":
103+
if c == ".":
104+
token.category = Token.UNSIGNEDFLOAT
105+
found_point = True
106+
else:
107+
token.category = Token.UNSIGNEDINT
108+
found_point = False
105109

106110
# Consume all of the digits, including any decimal point
107111
while True:

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.49"
76+
_VER = "1.50"
7777
prmpVals = ['>','(',')','&','|','\x1b','\b','<','=',' ',_VER,'\n','$','']
7878

7979
print("Starting Py-DOS...")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import board
2+
3+
Pydos_pins = {
4+
'SCL' : (board.SCL,"SCL GP17"),
5+
'SDA' : (board.SDA,"SDA GP16"),
6+
# SDIO is faster
7+
# 'SCK' : [(board.SD_SCK,"SD_SCK GP36")],
8+
# 'MOSI' : [(board.SD_MOSI,"SD_MOSI GP36")],
9+
# 'MISO' : [(board.SD_MISO,"SD_MISO GP37")],
10+
# 'CS' : [(board.SD_CS,"SD_CS GP34")],
11+
'SDIO_CLK' : (board.GP36,"GP36"),
12+
'SDIO_CMD' : (board.GP35,"GP35"),
13+
'SDIO_DPINS' : ([board.GP37, board.GP33, board.GP38, board.GP34],"[GP37, GP33, GP38, GP34]")
14+
}

cpython/kbdFeatherWing/factory_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import adafruit_sdcard
55
import digitalio
66
import displayio
7+
import fourwire
78
import neopixel
89
import storage
910
import board
@@ -28,7 +29,7 @@
2829
sd_cs = board.D5
2930
neopix_pin = board.D11
3031

31-
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
32+
display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
3233
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
3334

3435
print('Display: Pass? (you tell me)')

cpython/kbdFeatherWing/lib/pydos_ui_kfw.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import adafruit_ili9341
3131
import displayio
32+
import fourwire
3233

3334
class PyDOS_UI:
3435

@@ -42,7 +43,7 @@ def __init__(self):
4243

4344
_tft_cs = board.D9
4445
_tft_dc = board.D10
45-
_display_bus = displayio.FourWire(Pydos_hw.SPI(), command=_tft_dc, chip_select=_tft_cs)
46+
_display_bus = fourwire.FourWire(Pydos_hw.SPI(), command=_tft_dc, chip_select=_tft_cs)
4647
_display = adafruit_ili9341.ILI9341(_display_bus, width=320, height=240)
4748

4849
self.kbd = BBQ10Keyboard(Pydos_hw.I2C(),BBQI2CDevice=Pydos_hw.I2CbbqDevice)

cpython/playimage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
import adafruit_imageload
88
import bitmaptools
99
import displayio
10+
try:
11+
import fourwire
12+
except
13+
pass
1014
from os import getenv
1115
from supervisor import runtime
1216
try:
@@ -79,7 +83,7 @@
7983
spi = board.SPI()
8084
else:
8185
spi = busio.SPI(clock=board.SCK,MOSI=board.MOSI,MISO=board.MISO)
82-
disp_bus=displayio.FourWire(spi,command=board.D10,chip_select=board.D9, \
86+
disp_bus=fourwire.FourWire(spi,command=board.D10,chip_select=board.D9, \
8387
reset=board.D6)
8488
display=adafruit_ili9341.ILI9341(disp_bus,width=320,height=240)
8589
except:

edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pye_gen import pye
1+
from pye_pydos import pye
22

33
if __name__ != "PyDOS":
44
passedIn = ""

fileview.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from sys import implementation
44
try:
55
from pydos_ui import Pydos_ui
6+
readkbd = Pydos_ui.read_keyboard
67
except:
78
Pydos_ui = None
89
from sys import stdin
10+
readkbd = stdin.read
911
try:
1012
from pydos_ui import input
1113
except:
@@ -131,11 +133,7 @@ def absolutePath(argPath,currDir):
131133
seqCnt = 0
132134
strtCol = 0
133135
while cmnd.upper() != "Q":
134-
#cmnd = kbdInterrupt()
135-
if Pydos_ui:
136-
cmnd = Pydos_ui.read_keyboard(1)
137-
else:
138-
cmnd = stdin.read(1)
136+
cmnd = readkbd(1)
139137

140138
if ord(cmnd) == 27 and seqCnt == 0:
141139
seqCnt = 1

pye_gen.py renamed to pye_pydos.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
except:
77
import sys
88

9+
try:
10+
from pydos_ui import Pydos_ui
11+
except:
12+
Pydos_ui = False
13+
914
class IO_DEVICE:
1015
def __init__(self):
1116
try:
@@ -22,10 +27,13 @@ def wr(self, s):
2227
sys.stdout.write(s)
2328

2429
def rd(self):
25-
return sys.stdin.read(1)
30+
if Pydos_ui:
31+
return Pydos_ui.read_keyboard(1)
32+
else:
33+
return sys.stdin.read(1)
2634

2735
def rd_raw(self):
28-
return self.rd_raw_fct(1)
36+
return self.rd(1)
2937

3038
def deinit_tty(self):
3139
try:
@@ -35,13 +43,16 @@ def deinit_tty(self):
3543
pass
3644

3745
def get_screen_size(self):
38-
self.wr('\x1b[999;999H\x1b[6n')
39-
pos = ''
40-
char = self.rd() ## expect ESC[yyy;xxxR
41-
while char != 'R':
42-
pos += char
43-
char = self.rd()
44-
return [int(i, 10) for i in pos.lstrip("\n\x1b[").split(';')]
46+
if Pydos_ui:
47+
return [i for i in Pydos_ui.get_screensize()]
48+
else:
49+
self.wr('\x1b[999;999H\x1b[6n')
50+
pos = ''
51+
char = self.rd() ## expect ESC[yyy;xxxR
52+
while char != 'R':
53+
pos += char
54+
char = self.rd()
55+
return [int(i, 10) for i in pos.lstrip("\n\x1b[").split(';')]
4556

4657
## test, if the Editor class is already present
4758
if "pye_edit" not in globals().keys():

0 commit comments

Comments
 (0)