Presto display driver - #22
Open
djthorpe wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 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 unlikedev_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 valuesdev_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_tbuffers and one transfer count per frame for everybits_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 callsspi_read_blocking()whenctx->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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
dev_st7701backend, 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]CMakeLists.txt) so it is compiled and included in the device library. [1] [2]Device I/O and SPI Interface Improvements:
hw_deviceio_xfr()to clarify the meaning of "word" size, especially for SPI devices withbits_per_word > 8, and updated parameter descriptions for clarity.hw_spi_config_t) and initialization APIs thatbits_per_wordcan be 4–16, and that a missing MISO line is supported for write-only devices like some display panels. [1] [2]bits_per_wordfield to the Pico SPI context, ensuring correct handling of non-8-bit SPI transfers.Build System Robustness:
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.