Add OLED display support for Heltec WiFi LoRa 32 V3#1
Conversation
- 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
WalkthroughThe four-line display usermod's setup method now conditionally initializes the HELTEC_VEXT_PIN GPIO when defined, configuring it as an output and driving it low. ChangesHELTEC VEXT GPIO Setup
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp (2)
218-221: 💤 Low valueConsider disabling Vext if display initialization fails.
If display allocation or initialization fails (lines 253-260), the Vext pin remains powered LOW. For better power management and cleanliness, consider turning off Vext when the display is set to
NONE.♻️ Suggested enhancement for power management
In the failure path around line 259, add:
if (nullptr == u8x8) { DEBUG_PRINTLN(F("Display init failed.")); if (isSPI) { PinManager::deallocateMultiplePins((const uint8_t*)ioPin, 3, PinOwner::UM_FourLineDisplay); } +#ifdef HELTEC_VEXT_PIN + digitalWrite(HELTEC_VEXT_PIN, HIGH); // Disable Vext power + PinManager::deallocatePin(HELTEC_VEXT_PIN, PinOwner::UM_FourLineDisplay); +#endif type = NONE; return; }🤖 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 - 221, Display power (HELTEC_VEXT_PIN) is left enabled (digitalWrite(HELTEC_VEXT_PIN, LOW)) even when display allocation/initialization fails; update the failure path where the display is set to NONE or init fails (the block around the display allocation/initialization at lines ~253-260) to disable Vext by calling digitalWrite(HELTEC_VEXT_PIN, HIGH) (inside the existing `#ifdef` HELTEC_VEXT_PIN) so the pin is turned off when you set the display to NONE or when initialization fails.
218-221: ⚡ Quick winConsider using PinManager for HELTEC_VEXT_PIN to maintain consistent resource tracking.
This usermod allocates SPI pins via
PinManager::allocateMultiplePins()(line 230) but bypasses PinManager for the Vext power control pin. While GPIO36 is dedicated to external power on Heltec boards and has no conflicting usage elsewhere, usingPinManager::allocatePin()would make resource tracking uniform across the usermod and follow the pattern established for display pins. This also provides proper cleanup semantics if the usermod is disabled.Suggested improvement
`#ifdef` HELTEC_VEXT_PIN - pinMode(HELTEC_VEXT_PIN, OUTPUT); - digitalWrite(HELTEC_VEXT_PIN, LOW); + if (PinManager::allocatePin(HELTEC_VEXT_PIN, true, PinOwner::UM_FourLineDisplay)) { + pinMode(HELTEC_VEXT_PIN, OUTPUT); + digitalWrite(HELTEC_VEXT_PIN, LOW); + } `#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 - 221, The HELTEC_VEXT_PIN is configured directly with pinMode/digitalWrite instead of using PinManager, causing inconsistent resource tracking; replace the direct pin setup with PinManager::allocatePin(HELTEC_VEXT_PIN, PinOwner::Usermod) (matching the existing allocateMultiplePins usage) then set the pin mode and initial state via the allocated pin, and ensure you release it on disable/cleanup (e.g., in the usermod disable/shutdown path) so allocation and cleanup match the display pins managed by PinManager.
🤖 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.
Nitpick comments:
In
`@usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp`:
- Around line 218-221: Display power (HELTEC_VEXT_PIN) is left enabled
(digitalWrite(HELTEC_VEXT_PIN, LOW)) even when display allocation/initialization
fails; update the failure path where the display is set to NONE or init fails
(the block around the display allocation/initialization at lines ~253-260) to
disable Vext by calling digitalWrite(HELTEC_VEXT_PIN, HIGH) (inside the existing
`#ifdef` HELTEC_VEXT_PIN) so the pin is turned off when you set the display to
NONE or when initialization fails.
- Around line 218-221: The HELTEC_VEXT_PIN is configured directly with
pinMode/digitalWrite instead of using PinManager, causing inconsistent resource
tracking; replace the direct pin setup with
PinManager::allocatePin(HELTEC_VEXT_PIN, PinOwner::Usermod) (matching the
existing allocateMultiplePins usage) then set the pin mode and initial state via
the allocated pin, and ensure you release it on disable/cleanup (e.g., in the
usermod disable/shutdown path) so allocation and cleanup match the display pins
managed by PinManager.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f4c60a26-bcfc-43ec-806a-400ffcd44db7
📒 Files selected for processing (1)
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp
Summary
Added complete OLED display support for the Heltec WiFi LoRa 32 V3 board with automatic GPIO36 (Vext) power control. This includes the four_line_display_ALT usermod with GPIO36 initialization to enable the onboard 0.96" SSD1306 display without manual wiring.
Changes
platformio_override.ini: Created custom environment for Heltec V3 with OLED support
usermod_v2_four_line_display_ALT.cpp: Added GPIO36 power control
Features
✅ No PSRAM required (fixed Error 8 memory issue)
✅ Integrated SSD1306 OLED display support
✅ Automatic Vext power control (GPIO36)
✅ I2C display on GPIO17/GPIO18
✅ Memory optimized for ESP32-S3
Testing
Related Releases
Summary by CodeRabbit