Skip to content

Presto display driver - #22

Open
djthorpe wants to merge 2 commits into
mainfrom
djt/0911/presto
Open

Presto display driver#22
djthorpe wants to merge 2 commits into
mainfrom
djt/0911/presto

Conversation

@djthorpe

Copy link
Copy Markdown
Member

This pull request adds support for the ST7701 TFT LCD controller, including its initialization, configuration, and backlight control, and improves documentation and robustness for SPI and device I/O interfaces. It also ensures that the SDL display backend is only enabled for host builds, preventing incorrect linkage on Pico targets.

ST7701 Display Controller Support:

  • Added the dev_st7701 backend, including header (st7701.h) and implementation (st7701.c) files, with functions for initialization, configuration, and backlight control of ST7701-based displays. This includes a bring-up sequence tailored for a specific 480x480 panel, support for 0°/180° rotation, and PWM-controlled backlight brightness. [1] [2]
  • Registered the new backend in the build system (CMakeLists.txt) so it is compiled and included in the device library. [1] [2]

Device I/O and SPI Interface Improvements:

  • Improved documentation for hw_deviceio_xfr() to clarify the meaning of "word" size, especially for SPI devices with bits_per_word > 8, and updated parameter descriptions for clarity.
  • Clarified in the SPI configuration (hw_spi_config_t) and initialization APIs that bits_per_word can be 4–16, and that a missing MISO line is supported for write-only devices like some display panels. [1] [2]
  • Added a bits_per_word field to the Pico SPI context, ensuring correct handling of non-8-bit SPI transfers.

Build System Robustness:

  • Modified the build system to only enable the SDL display backend on host builds, preventing accidental linkage against incompatible host libraries during cross-compilation for Pico.

These changes collectively add a new display backend, improve hardware abstraction for advanced SPI use cases, and make the build system more robust for embedded targets.

@djthorpe djthorpe self-assigned this Sep 11, 2026
Copilot AI lite review requested due to automatic review settings September 11, 2026 07:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved moderate issues affect SPI correctness, ST7701 initialization reliability, and test cleanup.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds ST7701/Presto display support, enhanced Pico SPI handling, and host-only SDL build integration.

Changes:

  • Adds ST7701 initialization, rotation, and PWM backlight APIs.
  • Supports optional MISO and wider SPI frames.
  • Updates build configuration, documentation, and hardware tests.
File summaries
File Summary
test/dev_st7701/main.c Presto display and backlight hardware test
test/CMakeLists.txt Registers the display test
src/picofuse/hw/pico/spi.c Pico SPI transfer and optional-MISO handling
src/picofuse/dev/st7701/st7701.c ST7701 initialization and backlight implementation
src/picofuse/dev/CMakeLists.txt Backend registration and SDL build gating
include/picofuse/hw/spi.h SPI configuration documentation
include/picofuse/hw/deviceio.h Device I/O word-size documentation
include/picofuse/dev/st7701.h Public ST7701 API
include/picofuse/dev.h Public device API integration
.gitignore Additional ignored artifacts
Review details

Suppressed comments (4)

include/picofuse/dev/st7701.h:22

  • The public config exposes rotation, but unlike dev_ili9341_config_t (include/picofuse/dev/ili9341.h:55-59), it does not document that only 0 and 180 are accepted. Callers must read the implementation to know which values dev_st7701_init() rejects.
  uint16_t rotation;

include/picofuse/hw/deviceio.h:123

  • The SPI configuration now explicitly supports 4–7-bit frames, but this paragraph only defines the one-byte representation for the default value 8. The Pico implementation also uses uint8_t buffers and one transfer count per frame for every bits_per_word <= 8, so the documentation should describe that full range.
 * A "word" here is 1 byte for every I2C device (no framing concept
 * applies) and for an SPI device left at its default `hw_spi_config_t::
 * bits_per_word` (8) - `data` is `uint8_t*`, and `tx`/`rx` count bytes
 * exactly as before. For an SPI device configured with `bits_per_word`

src/picofuse/hw/pico/spi.c:81

  • The new no-MISO check covers only hw_deviceio_xfr(). _hw_spi_ops_read_reg() below still calls spi_read_blocking() when ctx->rx_pin == NULL, so a write-only handle can report a successful register read with floating or unconnected input instead of rejecting it. Apply the same capability check to the read-register path.
  if ((tx == 0 && rx == 0) || ((tx > 0 || rx > 0) && data == NULL) ||
      (rx > 0 && ctx->rx_pin == NULL)) {

test/dev_st7701/main.c:57

  • The new hardware test ignores the boolean result from dev_st7701_set_backlight(), so every PWM update can fail without failing the test. Assert the return value so this test actually verifies the new backlight API.
    dev_st7701_set_backlight(display, levels[i]);
  • Files reviewed: 9/11 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread include/picofuse/hw/deviceio.h
Comment thread src/picofuse/dev/st7701/st7701.c Outdated
Comment thread src/picofuse/dev/st7701/st7701.c Outdated
Comment thread test/dev_st7701/main.c
Comment thread src/picofuse/dev/st7701/st7701.c
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.

2 participants