Add GC9A01 round TFT display usermod#4989
Conversation
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@usermods/usermod_v2_gc9a01_display/usermod_v2_gc9a01_display.cpp`:
- Around line 817-821: The code always sets overlayUntil to millis() +
overlayInactivityTimeout, ignoring the requested showHowLong and breaking
overlays like displayNetworkInfo() and short rotary overlays; change the
assignment in the overlay activation path so overlayUntil = millis() +
(showHowLong > 0 ? showHowLong : overlayInactivityTimeout) (keeping the existing
activeOverlayMode, overlayText and lastRedraw updates) so explicit durations
passed in (e.g., from displayNetworkInfo()) are honored while still falling back
to overlayInactivityTimeout when no duration is supplied; updateRedrawTime() can
remain as-is to extend on user input.
- Around line 749-764: wakeDisplayFromSleep currently restores the backlight
even when the display/usermod is disabled; modify
UsermodGC9A01Display::wakeDisplayFromSleep to first check the displayEnabled (or
gc9a01.on) flag and return false if the display is disabled, so it does not call
setBacklight, flip displayTurnedOff, or force known* updates when the usermod is
off; locate the checks and variables displayTurnedOff, displayEnabled (or
gc9a01.on), setBacklight(), knownBrightness/knownMode/knownPowerState and gate
the wake logic behind that enabled flag.
In `@usermods/usermod_v2_gc9a01_display/usermod_v2_gc9a01_display.h`:
- Around line 52-53: The displayTimeout field uses uint16_t which overflows for
millisecond values >65,535; change its type to uint32_t (keeping the same
variable name displayTimeout and default 60000) so it can hold up to 300000 ms
(300s); update any places that read/write/serialize displayTimeout
(constructors, parsers, EEPROM/save/load, or RPCs) to use the 32-bit type to
avoid truncation, and run a quick grep for "displayTimeout" to update all
references and casts accordingly while leaving backlight untouched.
In
`@usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.cpp`:
- Around line 642-669: The GC9A01-specific branch that calls
gc9a01Display->wakeDisplay() and gc9a01Display->redraw() must be wrapped with
`#ifdef` USERMOD_GC9A01_DISPLAY so those member calls are only compiled when the
GC9A01 display type is enabled; locate the block that checks if (newState == 0
&& gc9a01Display != nullptr && display == nullptr) and surround its body (the
wakeDisplay()/redraw() calls and the changedState assignments) with the
USERMOD_GC9A01_DISPLAY preprocessor guard to prevent dereferencing the void*
stub when the feature is disabled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5106a826-f52e-427b-b070-b9ae2914d1fb
📒 Files selected for processing (7)
.gitignoreusermods/usermod_v2_gc9a01_display/library.jsonusermods/usermod_v2_gc9a01_display/logo_data.husermods/usermod_v2_gc9a01_display/readme.mdusermods/usermod_v2_gc9a01_display/usermod_v2_gc9a01_display.cppusermods/usermod_v2_gc9a01_display/usermod_v2_gc9a01_display.husermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.cpp
✅ Files skipped from review due to trivial changes (3)
- .gitignore
- usermods/usermod_v2_gc9a01_display/library.json
- usermods/usermod_v2_gc9a01_display/readme.md
- Honor showHowLong in overlay(): overlayUntil now uses the caller-supplied duration when > 0, falling back to overlayInactivityTimeout — fixes short rotary overlays and displayNetworkInfo() being held too long - Guard wakeDisplayFromSleep() with displayEnabled check so backlight/state are not restored when the usermod is disabled - Change displayTimeout from uint16_t to uint32_t to hold values up to 300 000 ms without overflow - Wrap GC9A01-specific wakeDisplay()/redraw() calls in rotary encoder ALT with #ifdef USERMOD_GC9A01_DISPLAY to prevent void* dereference when the display type is not compiled in ## Bug Fixes (PR review follow-up) - `overlay()`: honor `showHowLong` parameter — overlayUntil now respects explicit durations (e.g. from `displayNetworkInfo()`) instead of always using `overlayInactivityTimeout` - `wakeDisplayFromSleep()`: skip backlight restore and state reset when `displayEnabled` is false - `displayTimeout`: widened from `uint16_t` to `uint32_t` to safely hold values up to 300 000 ms - Rotary encoder ALT: GC9A01 `wakeDisplay()`/`redraw()` calls now guarded by `#ifdef USERMOD_GC9A01_DISPLAY`
I think the reason for the build failure is crazy simple: tasmota has removed SPIFFS 😢 , so the display driver lib fails to compile (even when SPIFFs is not used, the lib needs SPIFFS.h) You can still build this usermod with the original arduino-esp32 framework from espressif. Lines 305 to 308 in bf948fa I hope @willmmiles can find a solution in #5479 🤔 in worst case, we could place a fake "spiffs.h" into the usermod folder, so the compiler finds something. |
Overview
Adds comprehensive support for GC9A01 240x240 round TFT displays with a circular UI layout optimized for round displays.
Features
Hardware Requirements
Additional Changes
This PR also includes a bug fix for the rotary encoder ALT usermod that prevents palette navigation wraparound when decrementing from index 0.
Testing
Thoroughly tested on ESP32-D0WDQ6 with GC9A01 display. All features verified including power management, color synchronization, and rotary encoder integration.
Files Changed
usermods/usermod_v2_gc9a01_display/(5 files)usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.cpp(line 895)Summary by CodeRabbit
New Features
Documentation
Chores