Skip to content

Port mkfont.py to python3 - #34

Open
hansfbaier wants to merge 17 commits into
jamesbowman:masterfrom
hansfbaier:master
Open

Port mkfont.py to python3#34
hansfbaier wants to merge 17 commits into
jamesbowman:masterfrom
hansfbaier:master

Conversation

@hansfbaier

@hansfbaier hansfbaier commented Aug 19, 2022

Copy link
Copy Markdown

Hi,
this now runs again with current python3.

hansfbaier and others added 15 commits August 16, 2022 11:13
RP2040 first target. Portable core (src/) behind HAL table: protocol
engine, CCITT-16 CRC, EMA measurements, ST7735S waveform display.
Drop-in compatible with existing host drivers (80-byte status line,
echo, sel/unsel, A/B, detach, read/write commands).

- pico/: RP2040 HAL (SPI0 target, SPI1 LCD, USB CDC, ADC) + pinout
- host/: POSIX test HAL for PC-side functional checks
- tools/: font and pinout generators
Display now sits on physical pins 4-7 (GP2 SCK, GP3 MOSI, GP4 DC/RS,
GP5 CS, SPI0) and the target on SPI1 (GP8 MISO, GP9 CS, GP10 SCK,
GP11 MOSI). A/B move to GP6/GP7. LCD reset pin dropped; tie RST to 3V3.

Target MOSI is on pin 15: RP2040 hardware-SPI pins come in fixed sets,
so no complete SPI set fits inside pins 9-13. Both buses hardware SPI.
- pack 12-bit pixels 2-per-3-bytes (was 16 bits/pixel: every other
  pixel shifted 4 bits, scrambling colors)
- config descriptor bNumInterfaces 1 -> 2: host now probes the CDC
  data interface, bulk endpoints present
- explicit tud_cdc_write_flush(): this TinyUSB version only
  auto-flushes at >= 64 queued bytes, small replies sat forever
- 1200-baud BOOTSEL reset for buttonless reflashing
- boot colorbar self-test (1.5 s)
- readings clear exactly their text extent (fixed clear rect was
  clipping the V/mA labels)
The 14 px B label at the original y=148 descends to row 162,
clipping the bottom half on a 160-row panel.  Move every
waveform label/annotation row up by 4 px so B and the bottom
trace strip are fully visible.
Python harness exercising the SPIDriver CDC protocol: status, echo
(incl. XON/XOFF), CS/A/B control, duplex + write-only transfers,
stress rounds.  Full-raw tty is essential: IXON left on makes the
line discipline swallow 0x11/0x13 bytes.  Auto-detects MOSI-MISO
loopback and checks data integrity.

Also enable TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX: RP2040 USB errata
E5/E15 can leave an armed bulk-IN buffer unresponsive to IN tokens.
The port only drew write-only ('b') entries on the MOSI row.
The original matches entry-type bit 1, which is set for both
'b' (write-only) and 'c' (duplex), so duplex traffic left the
MOSI row blank.  Match 'b' or 'c' in render_row and annotate.
- entry_width: 'c' duplex entries get 18 cols (was 8, causing overlap)
- draw_byte_wave: 2 px/bit always, fill trailing cols, inter-byte
  transition edges via prev_level tracking
- genfonts: crop glyphs from draw_y+5 (was y+0, cutting off digit
  bottoms and padding labels with blank rows)
- numbers: draw at y=12 to align with V/mA labels, clear 14 px
- annotate: move hex 2 px below waveform strips (74/95)
- CS/A/B boxes: 15 px tall, centered on 9 px labels
- TOP=0/BOT=8: waveform spans full 9px strip (was 5px, half label
  height)
- strip ytop = label.y (was +4): waveform bottom aligns with label
  bottom
- trailing fill returns to idle (BOT) with falling edge after last
  high bit
- annotate positions adjusted for new strip offsets
- SCK: draw 8 clock pulses per byte (was single spike)
- CS/A/B: track port state backward through history via hist_port,
  so waveforms show actual signal levels during transfers
- test: interleave A/B toggles with SPI traffic so all signals
  appear in the same waveform window
Interleave A/B signal toggles with duplex, write-only and stress
transfers so the A/B outputs are exercised whenever MISO/MOSI data
is on the bus.
- docs/rp2040-overview.tex/.pdf/.md: architecture, pin map,
  USB CDC transport, host protocol, CRC, measurements, display
  rendering, build steps (username and system paths redacted)
- main README: architecture diagram + link to overview
- firmware-c README: Documentation section linking the overview
- linuxgui/main.c: device dropdown (ttyACM/ttyUSB/by-id), status
  readout, MISO/MOSI hex logs, CS/A/B checkboxes, hex-byte-string
  transfer box (both cases, no 0x prefix)
- auto-probes ports until SPIDriver handshake + status line match
- common: read timeout (VTIME) + bounded reads, close port on failed
  handshake, serial buffer 9->17 bytes for RP2040 unique-id serials
  (was truncating the sscanf and zeroing voltage/current)
- builds via CMake (pkg-config gtk4) or Makefile.gtk4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant