Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,26 @@ jobs:
- run: cargo install cargo-make

- run: cargo install flip-link
# Debug version
- run: cargo make --cwd b1display
- run: cargo make --cwd c1minimal
- run: cargo make --cwd ledmatrix
- run: cargo make --cwd qtpy
# Release version
- run: cargo make --cwd ledmatrix build-release
- run: cargo make --cwd ledmatrix build-release-10k
- run: cargo make --cwd ledmatrix build-release-evt
- run: cargo make --cwd b1display build-release
- run: cargo make --cwd c1minimal build-release
- run: cargo make --cwd qtpy build-release

- name: Convert to UF2 format
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
cargo make --cwd b1display uf2
cargo make --cwd c1minimal uf2
cargo make --cwd qtpy uf2
cargo make --cwd ledmatrix build-release-10k-uf2
cargo make --cwd ledmatrix build-release-evt-uf2
cargo make --cwd ledmatrix uf2
Expand All @@ -55,6 +61,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y llvm
cargo make --cwd b1display bin
cargo make --cwd qtpy bin
cargo make --cwd c1minimal bin
cargo make --cwd ledmatrix bin

Expand Down Expand Up @@ -102,6 +109,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y libudev-dev
cargo make clippy --cwd b1display
cargo make clippy --cwd qtpy
cargo make clippy --cwd c1minimal
cargo make clippy --cwd ledmatrix

Expand All @@ -113,6 +121,7 @@ jobs:
run: |
cargo pkgid -p fl16-inputmodules | cut -d "#" -f2 >> versions.tmp
cargo pkgid -p b1display | cut -d "#" -f2 >> versions.tmp
cargo pkgid -p qtpy | cut -d "#" -f2 >> versions.tmp
cargo pkgid -p c1minimal | cut -d "#" -f2 >> versions.tmp
cargo pkgid -p ledmatrix | cut -d "#" -f2 >> versions.tmp
uniq -c versions.tmp | [ $(wc -l) -eq 1 ]
Expand All @@ -130,4 +139,5 @@ jobs:
cargo fmt -p b1display -- --check
cargo fmt -p c1minimal -- --check
cargo fmt -p ledmatrix -- --check
cargo fmt -p qtpy -- --check
cargo fmt -p fl16-inputmodules -- --check
52 changes: 48 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"ledmatrix",
"fl16-inputmodules",
"inputmodule-control",
"qtpy",
]
# Don't build all of them by default.
# Because that'll lead to all features enabled in `fl16-inputmodules` and it
Expand Down Expand Up @@ -63,6 +64,12 @@ incremental = true
# To allow single-stepping through code use 0. Will cause timing issues, though
opt-level = 3

[profile.dev.package.qtpy]
codegen-units = 1
incremental = true
# To allow single-stepping through code use 0. Will cause timing issues, though
opt-level = 3

# Faster and smaller code but much slower to compile.
# Increase in rebuild time from <1s to 20s
[profile.release]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ See pages of the individual modules for details about how they work and how
they're controlled.

- [LED Matrix](ledmatrix/README.md)
- [2nd Display](b1display/README.md)
- [Minimal C1 Input Module](c1minimal/README.md)
- [2nd Display](b1display/README.md)
- [QT PY RP2040](qtpy/README.md)

## Generic Features

Expand Down
1 change: 1 addition & 0 deletions fl16-inputmodules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ default = []
ledmatrix = ["is31fl3741"]
b1display = ["st7306", "embedded-graphics", "tinybmp"]
c1minimal = ["smart-leds", "ws2812-pio"]
qtpy = ["c1minimal"]
2 changes: 1 addition & 1 deletion fl16-inputmodules/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod graphics;
#[cfg(feature = "b1display")]
pub mod lcd_hal;

#[cfg(feature = "c1minimal")]
#[cfg(all(feature = "c1minimal", not(feature = "qtpy")))]
pub mod minimal_hal;

pub mod control;
Expand Down
67 changes: 34 additions & 33 deletions ledmatrix_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
FWK_MAGIC = [0x32, 0xAC]
FWK_VID = 0x32AC
LED_MATRIX_PID = 0x20
INPUTMODULE_PIDS = [LED_MATRIX_PID]
QTPY_PID = 0x001F
INPUTMODULE_PIDS = [LED_MATRIX_PID, QTPY_PID]


class CommandVals(IntEnum):
Expand Down Expand Up @@ -614,12 +615,12 @@ def commit_cols(s):
send_serial(s, command)


def get_color():
def get_color(dev):
res = send_command(dev, CommandVals.SetColor, with_response=True)
return (int(res[0]), int(res[1]), int(res[2]))


def set_color(color):
def set_color(dev, color):
rgb = None
if color == 'white':
rgb = [0xFF, 0xFF, 0xFF]
Expand Down Expand Up @@ -825,7 +826,7 @@ def game_over(dev):
time.sleep(0.75)


def pong_embedded():
def pong_embedded(dev):
# Start game
send_command(dev, CommandVals.StartGame, [Game.Pong])

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


def game_of_life_embedded(arg):
def game_of_life_embedded(dev, arg):
# Start game
# TODO: Add a way to stop it
print("Game", int(arg))
send_command(dev, CommandVals.StartGame, [Game.GameOfLife, int(arg)])


def snake_embedded():
def snake_embedded(dev):
# Start game
send_command(dev, CommandVals.StartGame, [Game.Snake])

Expand Down Expand Up @@ -938,7 +939,7 @@ def snake(dev):
render_matrix(dev, matrix)


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


def display_string(disp_str):
def display_string(dev, disp_str):
b = [ord(x) for x in disp_str]
send_command(CommandVals.SetText, [len(disp_str)] + b)
send_command(dev, CommandVals.SetText, [len(disp_str)] + b)


def display_on_cmd(on):
send_command(CommandVals.DisplayOn, [on])
def display_on_cmd(dev, on):
send_command(dev, CommandVals.DisplayOn, [on])


def invert_screen_cmd(invert):
send_command(CommandVals.InvertScreen, [invert])
def invert_screen_cmd(dev, invert):
send_command(dev, CommandVals.InvertScreen, [invert])


def screen_saver_cmd(on):
send_command(CommandVals.ScreenSaver, [on])
def screen_saver_cmd(dev, on):
send_command(dev, CommandVals.ScreenSaver, [on])


def set_fps_cmd(mode):
res = send_command(CommandVals.SetFps, with_response=True)
def set_fps_cmd(dev, mode):
res = send_command(dev, CommandVals.SetFps, with_response=True)
current_fps = res[0]

if mode == 'quarter':
fps = current_fps & ~LOW_FPS_MASK
fps |= 0b000
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('low')
elif mode == 'half':
fps = current_fps & ~LOW_FPS_MASK
fps |= 0b001
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('low')
elif mode == 'one':
fps = current_fps & ~LOW_FPS_MASK
fps |= 0b010
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('low')
elif mode == 'two':
fps = current_fps & ~LOW_FPS_MASK
fps |= 0b011
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('low')
elif mode == 'four':
fps = current_fps & ~LOW_FPS_MASK
fps |= 0b100
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('low')
elif mode == 'eight':
fps = current_fps & ~LOW_FPS_MASK
fps |= 0b101
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('low')
elif mode == 'sixteen':
fps = current_fps & ~HIGH_FPS_MASK
fps |= 0b00000000
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('high')
elif mode == 'thirtytwo':
fps = current_fps & ~HIGH_FPS_MASK
fps |= 0b00010000
send_command(CommandVals.SetFps, [fps])
send_command(dev, CommandVals.SetFps, [fps])
set_power_mode_cmd('high')


def set_power_mode_cmd(mode):
def set_power_mode_cmd(dev, mode):
if mode == 'low':
send_command(CommandVals.SetPowerMode, [0])
send_command(dev, CommandVals.SetPowerMode, [0])
elif mode == 'high':
send_command(CommandVals.SetPowerMode, [1])
send_command(dev, CommandVals.SetPowerMode, [1])
else:
print("Unsupported power mode")
sys.exit(1)


def get_power_mode_cmd():
res = send_command(CommandVals.SetPowerMode, with_response=True)
def get_power_mode_cmd(dev):
res = send_command(dev, CommandVals.SetPowerMode, with_response=True)
current_mode = int(res[0])
if current_mode == 0:
print(f"Current Power Mode: Low Power")
elif current_mode == 1:
print(f"Current Power Mode: High Power")


def get_fps_cmd():
res = send_command(CommandVals.SetFps, with_response=True)
def get_fps_cmd(dev):
res = send_command(dev, CommandVals.SetFps, with_response=True)
current_fps = res[0]
res = send_command(CommandVals.SetPowerMode, with_response=True)
res = send_command(dev, CommandVals.SetPowerMode, with_response=True)
current_mode = int(res[0])

if current_mode == 0:
Expand Down
Loading