Skip to content

Commit 71dfc6e

Browse files
Merge pull request #80 from OctopusET/qtpy-rp2040
Fixes for the qtpy-rp2040 branch
2 parents f2846d9 + 43f3317 commit 71dfc6e

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ usbd-serial = "0.1.1"
3737
usbd-hid = "0.6.1"
3838
fugit = "0.3.7"
3939
# LED Matrix
40-
is31fl3741 = { git = "https://github.com/FrameworkComputer/is31fl3741-rs", branch = "sw-enablement" }
40+
is31fl3741 = "0.2.2"
4141
# B1 Display
4242
st7306 = { git = "https://github.com/FrameworkComputer/st7306-rs", branch = "update-deps" }
4343
embedded-graphics = "0.8"

ledmatrix_control.py

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
FWK_MAGIC = [0x32, 0xAC]
2121
FWK_VID = 0x32AC
2222
LED_MATRIX_PID = 0x20
23-
INPUTMODULE_PIDS = [LED_MATRIX_PID]
23+
QTPY_PID = 0x01AF
24+
INPUTMODULE_PIDS = [LED_MATRIX_PID, QTPY_PID]
2425

2526

2627
class CommandVals(IntEnum):
@@ -614,12 +615,12 @@ def commit_cols(s):
614615
send_serial(s, command)
615616

616617

617-
def get_color():
618+
def get_color(dev):
618619
res = send_command(dev, CommandVals.SetColor, with_response=True)
619620
return (int(res[0]), int(res[1]), int(res[2]))
620621

621622

622-
def set_color(color):
623+
def set_color(dev, color):
623624
rgb = None
624625
if color == 'white':
625626
rgb = [0xFF, 0xFF, 0xFF]
@@ -825,7 +826,7 @@ def game_over(dev):
825826
time.sleep(0.75)
826827

827828

828-
def pong_embedded():
829+
def pong_embedded(dev):
829830
# Start game
830831
send_command(dev, CommandVals.StartGame, [Game.Pong])
831832

@@ -849,14 +850,14 @@ def pong_embedded():
849850
send_command(dev, CommandVals.GameControl, [key_arg])
850851

851852

852-
def game_of_life_embedded(arg):
853+
def game_of_life_embedded(dev, arg):
853854
# Start game
854855
# TODO: Add a way to stop it
855856
print("Game", int(arg))
856857
send_command(dev, CommandVals.StartGame, [Game.GameOfLife, int(arg)])
857858

858859

859-
def snake_embedded():
860+
def snake_embedded(dev):
860861
# Start game
861862
send_command(dev, CommandVals.StartGame, [Game.Snake])
862863

@@ -938,7 +939,7 @@ def snake(dev):
938939
render_matrix(dev, matrix)
939940

940941

941-
def wpm_demo():
942+
def wpm_demo(dev):
942943
"""Capture keypresses and calculate the WPM of the last 10 seconds
943944
TODO: I'm not sure my calculation is right."""
944945
from getkey import getkey, keys
@@ -1363,92 +1364,92 @@ def gui(devices):
13631364
#sg.popup_error_with_traceback(f'An error happened. Here is the info:', e)
13641365

13651366

1366-
def display_string(disp_str):
1367+
def display_string(dev, disp_str):
13671368
b = [ord(x) for x in disp_str]
1368-
send_command(CommandVals.SetText, [len(disp_str)] + b)
1369+
send_command(dev, CommandVals.SetText, [len(disp_str)] + b)
13691370

13701371

1371-
def display_on_cmd(on):
1372-
send_command(CommandVals.DisplayOn, [on])
1372+
def display_on_cmd(dev, on):
1373+
send_command(dev, CommandVals.DisplayOn, [on])
13731374

13741375

1375-
def invert_screen_cmd(invert):
1376-
send_command(CommandVals.InvertScreen, [invert])
1376+
def invert_screen_cmd(dev, invert):
1377+
send_command(dev, CommandVals.InvertScreen, [invert])
13771378

13781379

1379-
def screen_saver_cmd(on):
1380-
send_command(CommandVals.ScreenSaver, [on])
1380+
def screen_saver_cmd(dev, on):
1381+
send_command(dev, CommandVals.ScreenSaver, [on])
13811382

13821383

1383-
def set_fps_cmd(mode):
1384-
res = send_command(CommandVals.SetFps, with_response=True)
1384+
def set_fps_cmd(dev, mode):
1385+
res = send_command(dev, CommandVals.SetFps, with_response=True)
13851386
current_fps = res[0]
13861387

13871388
if mode == 'quarter':
13881389
fps = current_fps & ~LOW_FPS_MASK
13891390
fps |= 0b000
1390-
send_command(CommandVals.SetFps, [fps])
1391+
send_command(dev, CommandVals.SetFps, [fps])
13911392
set_power_mode_cmd('low')
13921393
elif mode == 'half':
13931394
fps = current_fps & ~LOW_FPS_MASK
13941395
fps |= 0b001
1395-
send_command(CommandVals.SetFps, [fps])
1396+
send_command(dev, CommandVals.SetFps, [fps])
13961397
set_power_mode_cmd('low')
13971398
elif mode == 'one':
13981399
fps = current_fps & ~LOW_FPS_MASK
13991400
fps |= 0b010
1400-
send_command(CommandVals.SetFps, [fps])
1401+
send_command(dev, CommandVals.SetFps, [fps])
14011402
set_power_mode_cmd('low')
14021403
elif mode == 'two':
14031404
fps = current_fps & ~LOW_FPS_MASK
14041405
fps |= 0b011
1405-
send_command(CommandVals.SetFps, [fps])
1406+
send_command(dev, CommandVals.SetFps, [fps])
14061407
set_power_mode_cmd('low')
14071408
elif mode == 'four':
14081409
fps = current_fps & ~LOW_FPS_MASK
14091410
fps |= 0b100
1410-
send_command(CommandVals.SetFps, [fps])
1411+
send_command(dev, CommandVals.SetFps, [fps])
14111412
set_power_mode_cmd('low')
14121413
elif mode == 'eight':
14131414
fps = current_fps & ~LOW_FPS_MASK
14141415
fps |= 0b101
1415-
send_command(CommandVals.SetFps, [fps])
1416+
send_command(dev, CommandVals.SetFps, [fps])
14161417
set_power_mode_cmd('low')
14171418
elif mode == 'sixteen':
14181419
fps = current_fps & ~HIGH_FPS_MASK
14191420
fps |= 0b00000000
1420-
send_command(CommandVals.SetFps, [fps])
1421+
send_command(dev, CommandVals.SetFps, [fps])
14211422
set_power_mode_cmd('high')
14221423
elif mode == 'thirtytwo':
14231424
fps = current_fps & ~HIGH_FPS_MASK
14241425
fps |= 0b00010000
1425-
send_command(CommandVals.SetFps, [fps])
1426+
send_command(dev, CommandVals.SetFps, [fps])
14261427
set_power_mode_cmd('high')
14271428

14281429

1429-
def set_power_mode_cmd(mode):
1430+
def set_power_mode_cmd(dev, mode):
14301431
if mode == 'low':
1431-
send_command(CommandVals.SetPowerMode, [0])
1432+
send_command(dev, CommandVals.SetPowerMode, [0])
14321433
elif mode == 'high':
1433-
send_command(CommandVals.SetPowerMode, [1])
1434+
send_command(dev, CommandVals.SetPowerMode, [1])
14341435
else:
14351436
print("Unsupported power mode")
14361437
sys.exit(1)
14371438

14381439

1439-
def get_power_mode_cmd():
1440-
res = send_command(CommandVals.SetPowerMode, with_response=True)
1440+
def get_power_mode_cmd(dev):
1441+
res = send_command(dev, CommandVals.SetPowerMode, with_response=True)
14411442
current_mode = int(res[0])
14421443
if current_mode == 0:
14431444
print(f"Current Power Mode: Low Power")
14441445
elif current_mode == 1:
14451446
print(f"Current Power Mode: High Power")
14461447

14471448

1448-
def get_fps_cmd():
1449-
res = send_command(CommandVals.SetFps, with_response=True)
1449+
def get_fps_cmd(dev):
1450+
res = send_command(dev, CommandVals.SetFps, with_response=True)
14501451
current_fps = res[0]
1451-
res = send_command(CommandVals.SetPowerMode, with_response=True)
1452+
res = send_command(dev, CommandVals.SetPowerMode, with_response=True)
14521453
current_mode = int(res[0])
14531454

14541455
if current_mode == 0:

qtpy/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ fn main() -> ! {
109109
DEFAULT_SERIAL
110110
};
111111

112-
// TODO: Choose other ID
113-
let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x32ac, 0xFFFF))
112+
let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x32ac, 0x01AF))
114113
.manufacturer("Adafruit")
115114
.product("QT PY")
116115
.serial_number(serialnum)

0 commit comments

Comments
 (0)