The Cardputer's lane chips are laid out as the PicoCalc's

Key caption, nine cells a chip, two between, at the same columns (JP); only the
captions, F4-F8 in both banks, and the colours are the Cardputer's own.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5.5 committed 2026-09-30 21:34:13 -04:00
1 parent a5b53122ad
commit a62bf9ffdb
3 files changed
+24 -37

No files matched your search

+4 -3
View File
@@ -656,9 +656,10 @@ branch on the platform per frame, and never `from meshterm.platforms import PLAT
assuming F1–F5. Both decks having five slots is a coincidence, not a rule. The
Cardputer's lane is **Fn+4…8** (F4–F8), never the bare digits, since a digit must stay a
digit where the app takes typing; Shift with them arrives as F16–F20 (xterm's encoding,
which the console host copies). Each chip is centred over its key, eight cells of label,
white on the fn key's orange-red (a step darker than the print, same hue, so the white
holds 4:1), and white on dark blue while Shift is held.
which the console host copies). Its chips are laid out exactly as the PicoCalc's — key
caption, 9-cell chip, 2-cell gaps — captioned F4–F8 in both banks, white on the fn key's
orange-red (a step darker than the print, same hue, so the white holds 4:1), and white on
dark blue while Shift is held.
- **The Cardputer draws its own pixels** (`meshterm/host/`): the stock image leaves an app
no text console, only the framebuffer and the keyboard's event device. The console host
runs the ordinary TUI in-process — prompt_toolkit's app session pointed at a fixed 53×14
+8 -13
View File
@@ -266,11 +266,6 @@ class LaneDeck:
return f"{text:^{self.chip_width}}"
def _centred_columns(centres_px: tuple[int, ...], *, cell_px: int, width: int) -> tuple[int, ...]:
"""The start column of a ``width``-cell chip centred on each pixel position."""
return tuple(round((centre - width * cell_px / 2) / cell_px) for centre in centres_px)
#: The PicoCalc's five dedicated function keys. Its keyboard MCU sends Shift+F1..F5 as
#: plain F6-F10, so the Shift bank is keys of its own. Every chip is a 2-cell key caption,
#: a space and a 6-cell label; five chips and four 2-cell gaps sum to exactly 53, the
@@ -294,20 +289,20 @@ PICOCALC_DECK = LaneDeck(
#: typing (JP, 2026-09-30). The keyboard driver sends Shift as a key of its own, and the
#: console host encodes Shift+Fn+4..8 the way xterm encodes Shift+F4..F8, which
#: prompt_toolkit reads as F16-F20 — so a desktop terminal with ``--platform cardputer``
#: drives the same bank. Each chip is centred over its key: M5's own screen-key drawing puts
#: the five at x = 48, 104, 160, 216 and 272 of the 320-pixel panel, 56 px apart, which in
#: 6-pixel cells is too tight a pitch for a 9-cell chip to keep a gap, so a chip is its
#: label alone, centred in eight cells — the key under it needs no naming. It reads the
#: PicoCalc's lanes for now (see :meth:`~meshterm.ui.tui.screen.Screen.cardputer_lane`).
#: drives the same bank. The chips are laid out exactly as the PicoCalc's — the key's
#: caption leading a 6-cell label, nine cells a chip, two between (JP, 2026-09-30) — and
#: the Shift bank keeps the same captions, since it is the same keys with Shift held; its
#: blue fill is what says so. It reads the PicoCalc's lanes for now (see
#: :meth:`~meshterm.ui.tui.screen.Screen.cardputer_lane`).
CARDPUTER_DECK = LaneDeck(
name="cardputer",
keys=(4, 5, 6, 7, 8),
shift_keys=(16, 17, 18, 19, 20),
captions=("F4", "F5", "F6", "F7", "F8"),
shift_captions=("F4", "F5", "F6", "F7", "F8"),
columns=_centred_columns((48, 104, 160, 216, 272), cell_px=6, width=8),
chip_width=8,
captioned=False,
columns=PICOCALC_DECK.columns,
chip_width=PICOCALC_DECK.chip_width,
captioned=True,
fill="fkey.chip.cardputer",
shift_fill="fkey.chip.cardputer.shift",
read_lane=attrgetter("cardputer_lane"),
+12 -21
View File
@@ -20,9 +20,6 @@ from meshterm.ui.tui.fkeys import (
)
from meshterm.ui.tui.screen import ScrollScreen
#: Where M5's own screen-key drawing centres the labels for keys 4-8, in panel pixels.
_KEY_CENTRES_PX = (48, 104, 160, 216, 272)
class _OwnCardputerLane(ScrollScreen):
"""A screen that has decided its Cardputer lane for itself."""
@@ -85,32 +82,26 @@ def test_the_session_binds_every_key_a_deck_can_use() -> None:
assert session._KEY_ACTIONS[getattr(Keys, f"F{number}")] == f"f{number}"
def test_cardputer_chips_sit_over_their_keys() -> None:
"""Each chip is centred on its key's label position, a label alone in eight cells."""
def test_cardputer_chips_are_laid_out_as_the_picocalcs() -> None:
"""The PicoCalc's chips — caption, 9-cell width, 2-cell gaps — under the Cardputer's keys."""
assert CARDPUTER_DECK.columns == PICOCALC_DECK.columns
assert CARDPUTER_DECK.chip_width == PICOCALC_DECK.chip_width
lane = (FPair("Region", "home"), FPair("You", "locate", enabled=False), None, *DEFAULT_LANE[3:])
row = CARDPUTER_DECK.lane_text(lane)
for column, centre_px in zip(CARDPUTER_DECK.columns, _KEY_CENTRES_PX, strict=True):
chip_centre_px = (column + CARDPUTER_DECK.chip_width / 2) * 6
assert abs(chip_centre_px - centre_px) <= 2 # within a third of a cell
starts = CARDPUTER_DECK.columns
assert all(
b - a > CARDPUTER_DECK.chip_width for a, b in zip(starts, starts[1:], strict=False)
), "a gap"
assert cell_len(row.plain) <= CARDPUTER.readable_cols
chips = [row.plain[c : c + CARDPUTER_DECK.chip_width] for c in starts]
assert chips[0] == " Region " and chips[3] == " Page ↓ "
assert chips[2].strip() == "F6" # an unassigned slot shows its key, unfilled
assert cell_len(row.plain) == CARDPUTER.readable_cols
chips = [row.plain[c : c + CARDPUTER_DECK.chip_width] for c in CARDPUTER_DECK.columns]
assert chips == ["F4 Region", "F5 You ", "F6 ", "F7 Page ↓", "F8 Page ↑"]
styles = {row.plain[s.start : s.end].strip(): str(s.style) for s in row.spans}
assert styles["Region"] == "fkey.chip.cardputer"
assert styles["You"] == "muted" and styles["F6"] == "muted"
assert styles["F4 Region"] == "fkey.chip.cardputer"
assert styles["F5 You"] == "muted" and styles["F6"] == "muted"
def test_cardputer_shift_bank_draws_in_its_own_fill() -> None:
"""Shifted, the companions show in the Shift fill; a lone slot shows its bare key."""
"""Shifted, the companions show in the Shift fill under the same keys' captions."""
row = CARDPUTER_DECK.lane_text(DEFAULT_LANE, shifted=True)
styles = {row.plain[s.start : s.end].strip(): str(s.style) for s in row.spans}
assert styles["Bottom"] == "fkey.chip.cardputer.shift"
assert styles["Top"] == "fkey.chip.cardputer.shift"
assert styles["F7 Bottom"] == "fkey.chip.cardputer.shift"
assert styles["F8 Top"] == "fkey.chip.cardputer.shift"
assert styles["F4"] == "muted"