Skip to content

Add Heltec WiFi LoRa 32 V3 support and generic display reset#5633

Open
dbwg2009 wants to merge 14 commits into
wled:mainfrom
dbwg2009:main
Open

Add Heltec WiFi LoRa 32 V3 support and generic display reset#5633
dbwg2009 wants to merge 14 commits into
wled:mainfrom
dbwg2009:main

Conversation

@dbwg2009
Copy link
Copy Markdown

@dbwg2009 dbwg2009 commented May 19, 2026

Summary

Add official support for Heltec WiFi LoRa 32 V3 board and improve display initialization with generic build flags for board-specific requirements.

Problem

The Heltec WiFi LoRa 32 V3 (ESP32-S3FN8, 8MB flash, NO PSRAM) fails to boot with standard ESP32-S3 WLED builds because:

  • Standard builds set -DBOARD_HAS_PSRAM by default
  • This causes WLED to fail with Error 8 (memory depleted) at boot
  • The board has no PSRAM; the flag must not be set

Additionally, the onboard 0.96" SSD1306 OLED display requires:

  • GPIO36 (Vext) pulled LOW to enable the switchable power rail
  • GPIO21 reset pulse before I2C initialization

Solution

1. New Board Environment: heltec_wifi_lora_32_v3

Added to platformio.ini following the established pattern for boards without PSRAM.

Key features:

  • Does NOT set -DBOARD_HAS_PSRAM (resolves Error 8)
  • 8MB flash, QIO mode, proper partition settings
  • No opinionated usermods baked in (clean base)
  • Matches board definition in PlatformIO ecosystem

2. Generic Display Reset Support: FLD_PIN_RST

Added optional FLD_PIN_RST build flag to four_line_display_ALT usermod to support boards that require a hardware reset pulse on the display RST pin before I2C initialization.

Benefits:

  • Not hardcoded for one board
  • Any board with an I2C display reset pin can use it
  • Zero impact if not defined
  • Enables Heltec V3 OLED to boot reliably

3. Switchable Power Rail Support: HELTEC_VEXT_PIN

Added optional HELTEC_VEXT_PIN flag to four_line_display_ALT to allow boards with switchable display power rails to enable them reliably.

Testing

✅ Tested on actual Heltec WiFi LoRa 32 V3 hardware:

  • Board boots without Error 8
  • OLED display initializes and displays status
  • Clock shows correctly in sleep mode
  • All WLED features work (brightness, effects, WiFi, etc.)

Documentation

Code Quality

  • Follows WLED coding style (spaces, comments, blocks)
  • Both new flags are optional and conditional
  • Zero impact on existing builds that don't use the flags
  • Clear comments explaining why these changes are needed
  • Pattern matches existing board entries in platformio.ini

⚠️ Important Notes

  1. Display usermod changes: The FLD_PIN_RST and HELTEC_VEXT_PIN flags are purely optional (no effect unless explicitly defined) and generic (not Heltec-specific).

  2. Hardware tested: This change has been validated on actual Heltec V3 boards with the onboard OLED display working correctly.

Related Changes

Fixes WLED operation on Heltec WiFi LoRa 32 V3 boards (resolves Error 8, enables optional OLED support).

Files Changed

  • platformio.ini: New [env:heltec_wifi_lora_32_v3] board environment
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp: Add FLD_PIN_RST and HELTEC_VEXT_PIN support
  • usermods/usermod_v2_four_line_display_ALT/readme.md: Document the new build flags

Summary by CodeRabbit

  • Documentation

    • Extended documentation with board-specific configuration options for display initialization, including reset and power control macros
  • New Features

    • Added support for Heltec WiFi LoRa 32 V3 board with pre-configured display settings and PlatformIO environment profile
    • Enabled optional display reset and power pin configuration through build-time flags for enhanced hardware compatibility

Review Change Stack

claude and others added 7 commits May 16, 2026 22:20
- Automatically initialize GPIO36 and pull LOW on startup
- Enables OLED power supply (Vext) without manual wiring
- Checks for HELTEC_VEXT_PIN build flag before initialization
- Supports WLED 17.1.1 release with integrated display support

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S
- Automatically initialize GPIO36 and pull LOW on startup
- Enables OLED power supply (Vext) without manual wiring
- Checks for HELTEC_VEXT_PIN build flag before initialization
- Supports WLED 17.1.1 release with integrated display support

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S

Co-authored-by: Claude <noreply@anthropic.com>
- Added GPIO21 reset pulse sequence (HIGH → LOW → HIGH)
- Added 100ms stabilization delay after GPIO36 Vext enable
- Improves display initialization reliability on Heltec V3
- Released as v17.1.2

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S
- Add [env:heltec_wifi_lora_32_v3] to platformio.ini for ESP32-S3FN8 (8MB
  flash, NO PSRAM). BOARD_HAS_PSRAM is intentionally absent: the board has
  no PSRAM and setting that flag causes Error 8 (memory depleted) at boot.
- Clean up four_line_display_ALT: remove hardcoded GPIO21 reset that was
  specific to this one board and had no place in a generic usermod. Retain
  the conditional HELTEC_VEXT_PIN path (disabled unless explicitly defined
  in a build environment) with a brief settle delay and an explanatory
  comment.

Tested on Heltec WiFi LoRa 32 V3 hardware; firmware boots and LEDs work.
OLED support can be added via the four_line_display_ALT usermod with
HELTEC_VEXT_PIN=36 and I2C pins SDA=17 SCL=18 in platformio_override.ini.

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S
Some boards require a reset pulse on the display RST pin before I2C
initialises (the Heltec WiFi LoRa 32 V3 is the known case, GPIO21).
Hard-coding GPIO21 in a generic usermod is wrong; this adds an optional
FLD_PIN_RST build flag that any board can set in its platformio entry or
platformio_override.ini.

Nothing changes for existing builds that don't define FLD_PIN_RST.

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S
… flags

Add section to readme explaining the optional board-specific build flags
that can be set in platformio.ini or platformio_override.ini:
- FLD_PIN_RST: GPIO pin for display hardware reset (Heltec WiFi LoRa 32 V3)
- HELTEC_VEXT_PIN: GPIO pin to enable switchable OLED power rail

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c0a1c8a7-fabf-4c4e-b2bb-cd8b0341f894

📥 Commits

Reviewing files that changed from the base of the PR and between 9989873 and 86f8a08.

📒 Files selected for processing (2)
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display.h
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display.h
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp

Walkthrough

This pull request adds board-specific display initialization support for the Heltec WiFi LoRa 32 V3 by conditionalizing reset pin defaults, implementing pre-init GPIO handling in the Four Line Display usermod, creating a dedicated PlatformIO build environment, and documenting the new compile-time configuration flags.

Changes

Heltec WiFi LoRa 32 V3 Display Support

Layer / File(s) Summary
FLD_PIN_RESET default configuration
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display.h
FLD_PIN_RESET preprocessor defaults now branch on FLD_SPI_DEFAULT: SPI builds use a concrete reset pin (26 on ESP32, 16 otherwise), while I2C builds default to U8X8_PIN_NONE to omit reset-on-init unless explicitly provided.
Display power and reset initialization
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp
FourLineDisplayUsermod::setup() conditionally allocates HELTEC_VEXT_PIN as OUTPUT, drives it LOW, and delays 5ms to initialize display power; allocates and reserves FLD_PIN_RESET for I2C displays (disabling the usermod on failure); and passes the reset pin into U8X8_*_HW_I2C constructors.
Build environment and documentation
platformio_override.sample.ini, usermods/usermod_v2_four_line_display_ALT/readme.md
New [env:heltec_wifi_lora_32_v3] PlatformIO environment extends esp32s3, sets 8MB flash with QIO mode, defines I2C pins, SSD1306 display type, and board-specific macros. README documents FLD_PIN_RESET and HELTEC_VEXT_PIN macros with example values for Heltec V3.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • softhack007
  • willmmiles
  • netmindz
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main changes: adding Heltec WiFi LoRa 32 V3 support and implementing generic display reset functionality, which aligns with the primary objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

Copy link
Copy Markdown
Contributor

@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

🧹 Nitpick comments (3)
usermods/usermod_v2_four_line_display_ALT/readme.md (1)

66-66: 💤 Low value

Minor: Inconsistent guidance on where to set build flags.

Line 66 mentions "your platformio.ini or platformio_override.ini" while line 72 only mentions "platformio.ini".

For consistency and best practices (avoiding direct edits to tracked platformio.ini), consider recommending platformio_override.ini in both places.

📝 Suggested consistency fix
 * `FLD_PIN_RST` - GPIO pin for display hardware reset (optional)
-  * Set in your `platformio.ini` or `platformio_override.ini`: `-D FLD_PIN_RST=<pin>`
+  * Set in your `platformio_override.ini` (or `platformio.ini`): `-D FLD_PIN_RST=<pin>`
   * Performs a reset pulse before I2C initialization
   * Required on boards like Heltec WiFi LoRa 32 V3 (GPIO21)
   * Example: `-D FLD_PIN_RST=21`
 
 * `HELTEC_VEXT_PIN` - GPIO pin to enable switchable OLED power rail (optional)
-  * Set in your `platformio.ini`: `-D HELTEC_VEXT_PIN=<pin>`
+  * Set in your `platformio_override.ini` (or `platformio.ini`): `-D HELTEC_VEXT_PIN=<pin>`

Also applies to: 72-72

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@usermods/usermod_v2_four_line_display_ALT/readme.md` at line 66, The readme
mentions setting build flags in "platformio.ini or platformio_override.ini" for
FLD_PIN_RST at one place but later only references "platformio.ini"; update the
latter occurrence so both lines consistently recommend setting flags in
"platformio_override.ini" (or "platformio.ini / platformio_override.ini") and
explicitly suggest using platformio_override.ini to avoid editing tracked files
(refer to the FLD_PIN_RST build flag and the existing
platformio.ini/platformio_override.ini guidance).
platformio.ini (1)

666-683: ⚡ Quick win

Consider adding an inline comment explaining the no-PSRAM configuration.

While the PR objectives clearly state that BOARD_HAS_PSRAM must NOT be set to avoid Error 8, adding a brief inline comment would help future maintainers understand why this board differs from other 8MB S3 environments (lines 577-601) that do enable PSRAM.

📝 Suggested inline comment
 [env:heltec_wifi_lora_32_v3]
 ;; Heltec WiFi LoRa 32 V3 - ESP32-S3FN8, 8MB flash, NO PSRAM
+;; NOTE: Do NOT set BOARD_HAS_PSRAM - this board has no PSRAM and setting it causes boot Error 8
 ;; BOARD_HAS_PSRAM must NOT be set - this board has no PSRAM and setting it causes Error 8 (memory depleted)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@platformio.ini` around lines 666 - 683, Add a concise inline comment in the
[env:heltec_wifi_lora_32_v3] block explaining that BOARD_HAS_PSRAM must NOT be
set for this board because the Heltec WiFi LoRa 32 V3 (board =
heltec_wifi_lora_32_V3) does not have PSRAM and enabling it causes "Error 8
(memory depleted)"; place the comment near the existing note or next to the
build_flags/board_build settings (referencing BOARD_HAS_PSRAM) so future
maintainers see why this S3 8MB variant differs from other S3 8MB configs that
enable PSRAM.
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp (1)

226-237: ⚡ Quick win

Allocate FLD_PIN_RST via PinManager to prevent accidental pin reuse.

FLD_PIN_RST is correctly documented as I2C-only (reset before I2C initialization on boards like Heltec V3), and ioPin[2] is used exclusively for SPI display reset—the two are mutually exclusive by design. However, the current implementation doesn't allocate FLD_PIN_RST via PinManager, leaving room for misconfiguration: if a user sets both FLD_PIN_RST=21 and ioPin[2]=21 in different scenarios, the firmware won't detect the conflict.

Allocating FLD_PIN_RST via PinManager (following the pattern used for SPI pins on line 245) would provide defensive validation:

🔧 Suggested refactor
 `#ifdef` FLD_PIN_RST
   // Some boards require a hardware reset pulse on the display RST pin before
   // I2C init (e.g. Heltec WiFi LoRa 32 V3 uses GPIO21). Set FLD_PIN_RST in
   // your platformio_override.ini to enable this.
+  if (PinManager::allocatePin(FLD_PIN_RST, true, PinOwner::UM_FourLineDisplay)) {
   pinMode(FLD_PIN_RST, OUTPUT);
   digitalWrite(FLD_PIN_RST, HIGH);
   delay(1);
   digitalWrite(FLD_PIN_RST, LOW);
   delay(10);
   digitalWrite(FLD_PIN_RST, HIGH);
   delay(10);
+  } else {
+    DEBUG_PRINTLN(F("4LD: RST pin allocation failed"));
+  }
 `#endif`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp`
around lines 226 - 237, The FLD_PIN_RST reset pin is used without reserving it
in the PinManager, allowing accidental reuse/conflict with ioPin[2]; update the
initialization to allocate FLD_PIN_RST through the PinManager (same pattern used
for SPI/reset pins around the SPI allocation code) before calling
pinMode/digitalWrite/delay, i.e. call the PinManager reserve/allocate routine
for FLD_PIN_RST (the same API used for ioPin[] allocations) and check for
allocation failure/conflict, then proceed with the hardware reset sequence for
FLD_PIN_RST; ensure you reference FLD_PIN_RST, the PinManager allocation method,
and ioPin[2] in the change so conflicts are detected and logged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp`:
- Around line 218-225: Register the HELTEC_VEXT_PIN with the PinManager before
manipulating it: call PinManager::allocatePin(HELTEC_VEXT_PIN,
PinOwner::Usermod) (and handle a failed allocation if desired) immediately
before the existing pinMode/digitalWrite/delay block that references
HELTEC_VEXT_PIN, and optionally release it with
PinManager::releasePin(HELTEC_VEXT_PIN) during usermod cleanup. This keeps pin
ownership consistent with how the display I2C/SPI pins are allocated and
prevents conflicts with other code.

---

Nitpick comments:
In `@platformio.ini`:
- Around line 666-683: Add a concise inline comment in the
[env:heltec_wifi_lora_32_v3] block explaining that BOARD_HAS_PSRAM must NOT be
set for this board because the Heltec WiFi LoRa 32 V3 (board =
heltec_wifi_lora_32_V3) does not have PSRAM and enabling it causes "Error 8
(memory depleted)"; place the comment near the existing note or next to the
build_flags/board_build settings (referencing BOARD_HAS_PSRAM) so future
maintainers see why this S3 8MB variant differs from other S3 8MB configs that
enable PSRAM.

In `@usermods/usermod_v2_four_line_display_ALT/readme.md`:
- Line 66: The readme mentions setting build flags in "platformio.ini or
platformio_override.ini" for FLD_PIN_RST at one place but later only references
"platformio.ini"; update the latter occurrence so both lines consistently
recommend setting flags in "platformio_override.ini" (or "platformio.ini /
platformio_override.ini") and explicitly suggest using platformio_override.ini
to avoid editing tracked files (refer to the FLD_PIN_RST build flag and the
existing platformio.ini/platformio_override.ini guidance).

In
`@usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp`:
- Around line 226-237: The FLD_PIN_RST reset pin is used without reserving it in
the PinManager, allowing accidental reuse/conflict with ioPin[2]; update the
initialization to allocate FLD_PIN_RST through the PinManager (same pattern used
for SPI/reset pins around the SPI allocation code) before calling
pinMode/digitalWrite/delay, i.e. call the PinManager reserve/allocate routine
for FLD_PIN_RST (the same API used for ioPin[] allocations) and check for
allocation failure/conflict, then proceed with the hardware reset sequence for
FLD_PIN_RST; ensure you reference FLD_PIN_RST, the PinManager allocation method,
and ioPin[2] in the change so conflicts are detected and logged.
🪄 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: CHILL

Plan: Pro

Run ID: 023ba96c-f928-4b30-bbf1-0a40624636ae

📥 Commits

Reviewing files that changed from the base of the PR and between f68f91d and b974b9e.

📒 Files selected for processing (3)
  • platformio.ini
  • usermods/usermod_v2_four_line_display_ALT/readme.md
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp

Comment thread usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp Outdated
claude added 2 commits May 19, 2026 22:16
1. Pin Manager Registration: Wrap HELTEC_VEXT_PIN and FLD_PIN_RST GPIO
   operations with PinManager::allocatePin() to prevent conflicts with other
   code that might use GPIO36 or GPIO21. Pins are now properly reserved and
   will fail gracefully if allocation fails (e.g., already in use).

2. Documentation Consistency: Updated readme to consistently recommend
   platformio_override.ini for all build flags (avoids editing tracked
   platformio.ini file). Single clear instruction point instead of mixed
   recommendations.

3. Platformio.ini Clarity: Added detailed comment explaining why
   BOARD_HAS_PSRAM is intentionally absent on the Heltec V3. References the
   similar pattern used by esp32s3dev_4MB_qspi_hub75. Prevents future confusion
   about why this board differs from other 8MB ESP32-S3 configurations.

All changes maintain backward compatibility (flags remain optional and
conditional). Build tested and verified.

https://claude.ai/code/session_0177tCiDXsjQyQ86Nu7VYP5S
@dbwg2009
Copy link
Copy Markdown
Author

Addressed CodeRabbit feedback:

1. Pin Manager Registration

Wrapped HELTEC_VEXT_PIN and FLD_PIN_RST GPIO operations with PinManager::allocatePin() to prevent conflicts with other code that might use GPIO36 or GPIO21. Pins are now properly reserved and will fail gracefully if allocation fails (e.g., already in use by another usermod).

2. Documentation Consistency

Updated readme to consistently recommend platformio_override.ini for all build flags (avoids editing tracked platformio.ini file). Single clear instruction point instead of mixed recommendations.

3. Platformio.ini Clarity

Added detailed comment explaining why BOARD_HAS_PSRAM is intentionally absent on the Heltec V3. References the similar pattern used by esp32s3dev_4MB_qspi_hub75. This prevents future confusion about why this board differs from other 8MB ESP32-S3 configurations.

All changes maintain backward compatibility (flags remain optional and conditional). Build tested and verified. Commit: 7f26dba

Comment thread platformio.ini Outdated
Board-specific examples belong in the sample override file rather than
the main platformio.ini. Users can copy this section to their local
platformio_override.ini and customize as needed.
@dbwg2009
Copy link
Copy Markdown
Author

dbwg2009 commented May 19, 2026

Updated: Moved the Heltec WiFi LoRa 32 V3 board configuration from platformio.ini to platformio_override.sample.ini as per feedback.

The configuration now includes:

  • Proper I2C pins (GPIO17/18)
  • Display reset pin (GPIO21)
  • Vext power control pin (GPIO36)
  • Correct memory configuration for 8MB flash with NO PSRAM
  • Custom usermod configuration for the four_line_display_ALT

All changes have been committed to the fork and are ready for review.

Comment thread usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp Outdated
Use the existing FLD_PIN_RESET flag for I2C display reset pulse to maintain
consistency with the SPI display configuration. This flag is already defined
in the display usermod headers and avoids introducing a new naming variant.
@softhack007
Copy link
Copy Markdown
Member

@dbwg2009 please ensure that we don't add duplicate PIN macros that are already supported by the standard drivers. Especially

  • FLD_PIN_RESET is "reset", managed by the driver already
  • FLD_PIN_DC seems to be "power", also managed by the driver already.

@softhack007 softhack007 added board request PR adding support for a specific board. and removed enhancement labels May 19, 2026
@softhack007
Copy link
Copy Markdown
Member

softhack007 commented May 19, 2026

claude added 2 commits

@dbwg2009 in case you took help from an AI for the description or for coding, please be transparent and state it.

We usually need to heavily scrutinise AI-generated software and docs, as AI still makes a lot more mistakes than any human developer.

@softhack007 softhack007 added the AI Partly generated by an AI. Make sure that the contributor fully understands the code! label May 19, 2026
Comment thread platformio.ini
The U8x8 driver already performs the reset pulse during init when given a
reset pin. Pass FLD_PIN_RESET to the I2C constructors and remove the
duplicate manual pinMode/digitalWrite reset block.

The I2C default for FLD_PIN_RESET is now U8X8_PIN_NONE so existing I2C
boards are unaffected; only boards that explicitly set a reset pin get a
driver-managed reset. SPI defaults are unchanged.
@dbwg2009
Copy link
Copy Markdown
Author

@dbwg2009 in case you took help from an AI for the description or for your code, please be transparent and state it.

We usually need to heavily scrutinise AI-generated software and docs, as AI still makes a lot more mistakes than any human developer.

Hey @softhack007 yes, I have. This is due to the fact that i am not that experienced in programming and had modified WLED slightly to work with my board and wanted to share. I apologise if it's causing problems. I didn't realise that the U8g2/U8x8 driver already performs the reset pulse itself. Hopefully I've updated it correctly. Thank you for your patience with me

Copy link
Copy Markdown
Contributor

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp`:
- Around line 218-227: The PinManager::allocatePin(HELTEC_VEXT_PIN, true,
PinOwner::UM_FourLineDisplay) call can fail silently; add an else branch that
logs the allocation failure (include HELTEC_VEXT_PIN and that
PinOwner::UM_FourLineDisplay was requested) and set the display init control
variable (type) to NONE to skip display setup deterministically; modify the
block around allocatePin/HELTEC_VEXT_PIN to handle the failure path by logging
and assigning type = NONE before continuing.
🪄 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: CHILL

Plan: Pro

Run ID: 33fd9250-59b9-49e3-81f9-0c1352c1cd2e

📥 Commits

Reviewing files that changed from the base of the PR and between 9989873 and 50238cc.

📒 Files selected for processing (2)
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display.h
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp

Comment on lines +218 to +227
#ifdef HELTEC_VEXT_PIN
// Pull the Vext power rail enable pin LOW before display init.
// Required on boards like the Heltec WiFi LoRa 32 V3 where the OLED is
// powered via a switchable rail (GPIO36) rather than always-on VCC.
if (PinManager::allocatePin(HELTEC_VEXT_PIN, true, PinOwner::UM_FourLineDisplay)) {
pinMode(HELTEC_VEXT_PIN, OUTPUT);
digitalWrite(HELTEC_VEXT_PIN, LOW);
delay(5);
}
#endif
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Handle HELTEC_VEXT_PIN allocation failure explicitly.

If PinManager::allocatePin() fails here, setup silently continues and can attempt display init with Vext still off. Add an else branch to log and disable display init (type = NONE) for a deterministic failure mode.

Suggested patch
 `#ifdef` HELTEC_VEXT_PIN
   // Pull the Vext power rail enable pin LOW before display init.
   // Required on boards like the Heltec WiFi LoRa 32 V3 where the OLED is
   // powered via a switchable rail (GPIO36) rather than always-on VCC.
   if (PinManager::allocatePin(HELTEC_VEXT_PIN, true, PinOwner::UM_FourLineDisplay)) {
     pinMode(HELTEC_VEXT_PIN, OUTPUT);
     digitalWrite(HELTEC_VEXT_PIN, LOW);
     delay(5);
+  } else {
+    DEBUG_PRINTLN(F("4LD: HELTEC_VEXT_PIN allocation failed"));
+    type = NONE;
   }
 `#endif`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp`
around lines 218 - 227, The PinManager::allocatePin(HELTEC_VEXT_PIN, true,
PinOwner::UM_FourLineDisplay) call can fail silently; add an else branch that
logs the allocation failure (include HELTEC_VEXT_PIN and that
PinOwner::UM_FourLineDisplay was requested) and set the display init control
variable (type) to NONE to skip display setup deterministically; modify the
block around allocatePin/HELTEC_VEXT_PIN to handle the failure path by logging
and assigning type = NONE before continuing.

@softhack007
Copy link
Copy Markdown
Member

softhack007 commented May 19, 2026

@dbwg2009 in case you took help from an AI for the description or for your code, please be transparent and state it.
We usually need to heavily scrutinise AI-generated software and docs, as AI still makes a lot more mistakes than any human developer.

Hey @softhack007 yes, I have. This is due to the fact that i am not that experienced in programming and had modified WLED slightly to work with my board and wanted to share. I apologise if it's causing problems. I didn't realise that the U8g2/U8x8 driver already performs the reset pulse itself. Hopefully I've updated it correctly. Thank you for your patience with me

Hi @dbwg2009 generally no problem, just - for the next PR - add a statement in the description when most your code was written by an AI (coding agent). I don't want to deduce that myself from description styles and commit details 😅

@dbwg2009
Copy link
Copy Markdown
Author

@dbwg2009 in case you took help from an AI for the description or for your code, please be transparent and state it.
We usually need to heavily scrutinise AI-generated software and docs, as AI still makes a lot more mistakes than any human developer.

Hey @softhack007 yes, I have. This is due to the fact that i am not that experienced in programming and had modified WLED slightly to work with my board and wanted to share. I apologise if it's causing problems. I didn't realise that the U8g2/U8x8 driver already performs the reset pulse itself. Hopefully I've updated it correctly. Thank you for your patience with me

Hi @dbwg2009 generally no problem, just - for the next PR - add a statement in the description when most your code was written by an AI (coding agent). I don't want to deduce that myself from description styles and commit descriptions 😅

Sorry about that @softhack007, I will in future 🥲

@softhack007
Copy link
Copy Markdown
Member

@dbwg2009 !!! tip about usage of AI - it's really dangerous to allow the bot to make source code commits on its own. Code gets lost without noticing, comments vanish, completely untreated files might get garbled. I'm talking from experience.

Not sure how to change your AI agent settings. Best practice is to let it do the coding for you locally, then YOU would test the changes on your board (still working locally), and then make the commit yourself, for example with github desktop.

This won't make any difference for our review of your PR, so just take it as my tip on good practice.

@dbwg2009
Copy link
Copy Markdown
Author

@dbwg2009 !!! tip about usage of AI - it's really dangerous to allow the bot to make source code commits on its own. Code gets lost without noticing, comments vanish, completely untreated files might get garbled. I'm talking from experience.

Not sure how to change your AI agent settings. Best practice is to let it do the coding for you locally, then YOU would test the changes on your board (still working locally), and then make the commit yourself, for example with github desktop.

This won't make any difference for our review of your PR, so just take it as my tip on good practice.

Ahhh, I see. That makes sense, I'll have a look at the settings and I'll do that from now on. Thank you @softhack007 !

@softhack007
Copy link
Copy Markdown
Member

softhack007 commented May 19, 2026

@dbwg2009 the problem with BOARD_HAS_PSRAM just surfaced yesterday for 16.0.0. We have a new buildenv esp32s3dev_8MB_none. Can you try if that one works for your MCU?

I was also wondering if adding the build flags -D FLD_PIN_RESET=21 -D FLD_PIN_DC=36 would already be sufficient to make your display work? If "not working with vanilla source code", then we'd already get a clearer picture about the minimal changes to make your display work with the U8g2 library.

@dbwg2009
Copy link
Copy Markdown
Author

@dbwg2009 the problem with BOARD_HAS_PSRAM just surfaced yesterday for 16.0.0. We have a new buildenv esp32s3dev_8MB_none. Can you try if that one works for your MCU?

I was also wondering if adding the build flags -D FLD_PIN_RESET=21 -D FLD_PIN_DC=36 would already be sufficient to make your display work? If "not working with vanilla source code", then we'd already get a clearer picture about the minimal changes to get it working with your display.

@softhack007 I'll test it now. Good point with the build flags, I'll also test that out and let you know how it goes!

board_build.f_flash = 80000000L
board_build.flash_mode = qio
lib_deps = ${esp32s3.lib_deps}
olikraus/U8g2 @ ^2.28.8 ;; for four_line_display_ALT usermod
Copy link
Copy Markdown
Member

@softhack007 softhack007 May 19, 2026

Choose a reason for hiding this comment

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

This line should not be necessary any more, the library.json in the usermod folder should take care of pulling in the U8g2 driver.

@dbwg2009
Copy link
Copy Markdown
Author

@softhack007 Just compiled and tested. Compiles fine with the build flags.
When testing on my Heltec V3 it all runs ok, however, there is no display output...

@blazoncek
Copy link
Copy Markdown
Contributor

@dbwg2009 as someone who has invested a lot of time into this usermod to make it runtime configurable I would encourage you to avoid compile-time options and implement user selectable runtime choices in the same way as every other option in this usermod.

Otherwise this looks like low-effort one-user solution.

@softhack007
Copy link
Copy Markdown
Member

softhack007 commented May 20, 2026

@dbwg2009 please ensure that we don't add duplicate PIN macros that are already supported by the standard drivers. Especially

  • FLD_PIN_RESET is "reset", managed by the driver already
  • FLD_PIN_DC seems to be "power", also managed by the driver already.

After some research, the story seems more complicated. I've initially mixed up I2C and SPI based displays in my recommendation, sorry about that.

To clean up the mess a bit:

  • FLD_PIN_CS (SPI chip select), FLD_PIN_DC (SPI DC), FLD_PIN_RESET (SPI reset) are currently only used for SPI-based displays, and we should not accidentally create breaking changes that render SPI-based OLEDs unusable
  • The U8x8 driver for I2C displays also supports a RESET pin (in addition to the standard I2C two-wire pins). It would be ok for me if we "recycle" the same FLD_PIN_RESET entry for I2C and add this to the driver initialization.
  • I did not (yet) find a mentioning of some kind of power-on PIN for I2C displays - maybe ask in the author of U8x8 if this feature is supported by the driver. https://github.com/olikraus/u8g2
  • The need for an addition "Backlight on" PIN seems not too uncommon to me, maybe U8x8 already supports that
  • If the power-on (or "backlight on") feature is not supported inside U8x8,it might need an explicit implementation in the 4LD usermod

I agree with the comment made by @blazoncek that both additional PINs must be configurable via Usermod settings, in addition to (optionally) providing build_flags for hardware integrators.

Functions that need adjustment for supporting settings by UI:

void FourLineDisplayUsermod::appendConfigData() {

void FourLineDisplayUsermod::addToConfig(JsonObject& root) {

bool FourLineDisplayUsermod::readFromConfig(JsonObject& root) {

Display initializion / re-initializion

pin registration (not sure I found everything)

int8_t ioPin[3] = {-1, -1, -1}; // I2C pins: SCL, SDA

PinManagerPinType cspins[3] = { { ioPin[0], true }, { ioPin[1], true }, { ioPin[2], true } };
if (!PinManager::allocateMultiplePins(cspins, 3, PinOwner::UM_FourLineDisplay)) { type = NONE; }

for (unsigned i=0; i<3; i++) ioPin[i] = top["pin"][i] | ioPin[i];

if (pinsChanged || !newSPI) PinManager::deallocateMultiplePins((const uint8_t*)oldPin, 3, PinOwner::UM_FourLineDisplay);

@softhack007 softhack007 added the needs_rework PR needs improvements before merging (RED FLAG) label May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Partly generated by an AI. Make sure that the contributor fully understands the code! board request PR adding support for a specific board. enhancement needs_rework PR needs improvements before merging (RED FLAG)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants