Skip to content

Commit cec890c

Browse files
Merge pull request #79 from FrameworkComputer/qtpy-rp2040
Add QT Py Module
2 parents 85fe633 + d50e9e6 commit cec890c

File tree

11 files changed

+370
-39
lines changed

11 files changed

+370
-39
lines changed

.github/workflows/firmware.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,26 @@ jobs:
3232
- run: cargo install cargo-make
3333

3434
- run: cargo install flip-link
35+
# Debug version
3536
- run: cargo make --cwd b1display
3637
- run: cargo make --cwd c1minimal
38+
- run: cargo make --cwd ledmatrix
39+
- run: cargo make --cwd qtpy
40+
# Release version
3741
- run: cargo make --cwd ledmatrix build-release
3842
- run: cargo make --cwd ledmatrix build-release-10k
3943
- run: cargo make --cwd ledmatrix build-release-evt
4044
- run: cargo make --cwd b1display build-release
4145
- run: cargo make --cwd c1minimal build-release
46+
- run: cargo make --cwd qtpy build-release
4247

4348
- name: Convert to UF2 format
4449
run: |
4550
sudo apt-get update
4651
sudo apt-get install -y libudev-dev
4752
cargo make --cwd b1display uf2
4853
cargo make --cwd c1minimal uf2
54+
cargo make --cwd qtpy uf2
4955
cargo make --cwd ledmatrix build-release-10k-uf2
5056
cargo make --cwd ledmatrix build-release-evt-uf2
5157
cargo make --cwd ledmatrix uf2
@@ -55,6 +61,7 @@ jobs:
5561
sudo apt-get update
5662
sudo apt-get install -y llvm
5763
cargo make --cwd b1display bin
64+
cargo make --cwd qtpy bin
5865
cargo make --cwd c1minimal bin
5966
cargo make --cwd ledmatrix bin
6067
@@ -102,6 +109,7 @@ jobs:
102109
sudo apt-get update
103110
sudo apt-get install -y libudev-dev
104111
cargo make clippy --cwd b1display
112+
cargo make clippy --cwd qtpy
105113
cargo make clippy --cwd c1minimal
106114
cargo make clippy --cwd ledmatrix
107115
@@ -113,6 +121,7 @@ jobs:
113121
run: |
114122
cargo pkgid -p fl16-inputmodules | cut -d "#" -f2 >> versions.tmp
115123
cargo pkgid -p b1display | cut -d "#" -f2 >> versions.tmp
124+
cargo pkgid -p qtpy | cut -d "#" -f2 >> versions.tmp
116125
cargo pkgid -p c1minimal | cut -d "#" -f2 >> versions.tmp
117126
cargo pkgid -p ledmatrix | cut -d "#" -f2 >> versions.tmp
118127
uniq -c versions.tmp | [ $(wc -l) -eq 1 ]
@@ -130,4 +139,5 @@ jobs:
130139
cargo fmt -p b1display -- --check
131140
cargo fmt -p c1minimal -- --check
132141
cargo fmt -p ledmatrix -- --check
142+
cargo fmt -p qtpy -- --check
133143
cargo fmt -p fl16-inputmodules -- --check

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"ledmatrix",
1111
"fl16-inputmodules",
1212
"inputmodule-control",
13+
"qtpy",
1314
]
1415
# Don't build all of them by default.
1516
# Because that'll lead to all features enabled in `fl16-inputmodules` and it
@@ -63,6 +64,12 @@ incremental = true
6364
# To allow single-stepping through code use 0. Will cause timing issues, though
6465
opt-level = 3
6566

67+
[profile.dev.package.qtpy]
68+
codegen-units = 1
69+
incremental = true
70+
# To allow single-stepping through code use 0. Will cause timing issues, though
71+
opt-level = 3
72+
6673
# Faster and smaller code but much slower to compile.
6774
# Increase in rebuild time from <1s to 20s
6875
[profile.release]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ See pages of the individual modules for details about how they work and how
1111
they're controlled.
1212

1313
- [LED Matrix](ledmatrix/README.md)
14-
- [2nd Display](b1display/README.md)
1514
- [Minimal C1 Input Module](c1minimal/README.md)
15+
- [2nd Display](b1display/README.md)
16+
- [QT PY RP2040](qtpy/README.md)
1617

1718
## Generic Features
1819

fl16-inputmodules/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ default = []
4747
ledmatrix = ["is31fl3741"]
4848
b1display = ["st7306", "embedded-graphics", "tinybmp"]
4949
c1minimal = ["smart-leds", "ws2812-pio"]
50+
qtpy = ["c1minimal"]

fl16-inputmodules/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod graphics;
2727
#[cfg(feature = "b1display")]
2828
pub mod lcd_hal;
2929

30-
#[cfg(feature = "c1minimal")]
30+
#[cfg(all(feature = "c1minimal", not(feature = "qtpy")))]
3131
pub mod minimal_hal;
3232

3333
pub mod control;

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 = 0x001F
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:

0 commit comments

Comments
 (0)