Skip to content

feat: GC9A01 round TFT display support#113

Merged
sjordan0228 merged 1 commit into
devfrom
feature/gc9a01-tft
Apr 5, 2026
Merged

feat: GC9A01 round TFT display support#113
sjordan0228 merged 1 commit into
devfrom
feature/gc9a01-tft

Conversation

@sjordan0228
Copy link
Copy Markdown
Contributor

@sjordan0228 sjordan0228 commented Apr 5, 2026

Summary

  • GC9A01 round TFT (240x240) support as an alternative to the ST7789 square TFT
  • Same pins, same SPI bus, same resolution — runtime selectable via config page
  • TFT Driver dropdown (ST7789 square / GC9A01 round) appears when TFT Display is enabled
  • Both panel types compiled into a single binary, selected at boot from NVS
  • Centered "SpoolSense" header text (was left-aligned on spool scan view)

Test plan

  • GC9A01 wired to WROOM, boots and displays correctly
  • Config page shows TFT Driver dropdown when TFT enabled
  • Tag scan displays spool data on round screen
  • ST7789 still works after this change (swap screen back and change config)
  • S3-Zero builds clean

Summary by CodeRabbit

  • New Features
    • Added runtime support for multiple TFT display drivers: ST7789 and GC9A01.
    • Configuration interface now includes a TFT Driver dropdown for hardware selection.
    • TFT driver selection persists across device restarts.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

📝 Walkthrough

Walkthrough

The PR adds runtime-selectable TFT driver configuration, replacing compile-time panel selection. A UI control for driver choice (ST7789/GC9A01) is added, the selection is persisted via NVS, and TFTManager is initialized with the configured driver at application startup.

Changes

Cohort / File(s) Summary
Configuration UI and Web API
src/ConfigHTML.h, src/WebServerManager.cpp
Added TFT driver dropdown UI (ST7789/GC9A01) that becomes visible when TFT is enabled; extended API to serialize/deserialize the selected driver in JSON config payloads.
Configuration Manager
src/ConfigurationManager.h, src/ConfigurationManager.cpp
Added persistent tft_driver field (string, 8-byte buffer) to ConfigUpdate struct; extended loadFromNVS(), saveToNVS(), and getCurrentConfig() to handle the new field; exposed public accessor getTftDriver().
TFT Hardware Layer
src/TFTConfig.h
Introduced enum class TFTDriver with ST7789 and GC9A01 values; changed LGFX constructor from parameterless to accepting TFTDriver parameter; replaced single compile-time panel instance with runtime panel selection based on driver parameter.
TFT Manager
src/TFTManager.h, src/TFTManager.cpp
Updated constructor to accept TFTDriver parameter (default ST7789); added _driver member for runtime driver tracking; adjusted SpoolSense header text layout to use centered datum instead of left-aligned positioning.
Application Initialization
src/main.cpp
Replaced static TFTManager with lazy-allocated pointer initialized in setup() when TFT is enabled; TFTManager now constructed with driver selected from persisted config via config.getTftDriver(); all TFT display calls guarded by null-check.

Sequence Diagram

sequenceDiagram
    actor User
    User->>WebServerManager: POST /api/config with tft_driver
    WebServerManager->>ConfigurationManager: saveToNVS(update)
    ConfigurationManager->>NVS: write tft_driver key
    User->>Device: Power cycle / Reset
    Device->>main.cpp: setup()
    main.cpp->>ConfigurationManager: loadFromNVS()
    ConfigurationManager->>NVS: read tft_driver
    ConfigurationManager->>main.cpp: return config
    main.cpp->>ConfigurationManager: getTftDriver()
    ConfigurationManager->>main.cpp: return "st7789" or "gc9a01"
    main.cpp->>main.cpp: determine TFTDriver enum value
    main.cpp->>TFTManager: new TFTManager(selected_driver)
    TFTManager->>TFTConfig: LGFX(driver)
    TFTConfig->>TFTConfig: select panel_st7789 or panel_gc9a01
    TFTConfig->>LGFXLibrary: setPanel(selected_panel)
    TFTManager->>main.cpp: initialization complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers summary, changes, and test plan, but lacks explicit 'How to Test' and 'Checklist' sections as specified in the repository template. Reorganize the description to follow the exact template structure with distinct 'How to Test' and 'Checklist' sections; move test plan items into these sections appropriately.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature added: GC9A01 round TFT display support. It accurately reflects the primary change across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/gc9a01-tft

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/M Medium change (50-200 lines) label Apr 5, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.cpp`:
- Line 351: The single-line guarded call "if (tftManagerPtr)
tftManagerPtr->showReady();" should be changed to use braces for consistency and
safety; locate the conditional that calls tftManagerPtr->showReady() and replace
it with a braced block (if (tftManagerPtr) { tftManagerPtr->showReady(); }) so
future additions won't introduce bugs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c14e02c7-4598-4512-9888-8f0ce6f9934f

📥 Commits

Reviewing files that changed from the base of the PR and between 8b95a1a and 20a381e.

📒 Files selected for processing (8)
  • src/ConfigHTML.h
  • src/ConfigurationManager.cpp
  • src/ConfigurationManager.h
  • src/TFTConfig.h
  • src/TFTManager.cpp
  • src/TFTManager.h
  • src/WebServerManager.cpp
  • src/main.cpp

Comment thread src/main.cpp

if (config.isTftEnabled()) {
tftManager.showReady();
if (tftManagerPtr) tftManagerPtr->showReady();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Add braces around single-line statement for consistency.

The guarded showReady() call should use braces for consistency with the rest of the codebase and to prevent future maintenance errors.

🔧 Suggested fix
     if (config.isTftEnabled()) {
-    if (tftManagerPtr) tftManagerPtr->showReady();
+    if (tftManagerPtr) {
+      tftManagerPtr->showReady();
+    }
   } else if (config.isLcdEnabled()) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (tftManagerPtr) tftManagerPtr->showReady();
if (tftManagerPtr) {
tftManagerPtr->showReady();
}
🧰 Tools
🪛 Clang (14.0.6)

[note] 351-351: +2, including nesting penalty of 1, nesting level increased to 2

(clang)


[warning] 351-351: implicit conversion 'TFTManager *' -> bool

(readability-implicit-bool-conversion)


[warning] 351-351: statement should be inside braces

(readability-braces-around-statements)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.cpp` at line 351, The single-line guarded call "if (tftManagerPtr)
tftManagerPtr->showReady();" should be changed to use braces for consistency and
safety; locate the conditional that calls tftManagerPtr->showReady() and replace
it with a braced block (if (tftManagerPtr) { tftManagerPtr->showReady(); }) so
future additions won't introduce bugs.

@sjordan0228 sjordan0228 merged commit df6c6fa into dev Apr 5, 2026
3 checks passed
@sjordan0228 sjordan0228 deleted the feature/gc9a01-tft branch April 5, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium change (50-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant