Skip to content

Add OLED display support for Heltec WiFi LoRa 32 V3#1

Merged
dbwg2009 merged 1 commit into
mainfrom
claude/fix-wled-heltec-memory-cT0D1
May 16, 2026
Merged

Add OLED display support for Heltec WiFi LoRa 32 V3#1
dbwg2009 merged 1 commit into
mainfrom
claude/fix-wled-heltec-memory-cT0D1

Conversation

@dbwg2009
Copy link
Copy Markdown
Owner

@dbwg2009 dbwg2009 commented May 16, 2026

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

    • Configured for SSD1306 128x64 I2C display (GPIO17: SDA, GPIO18: SCL)
    • Added GPIO36 Vext power pin initialization
    • Integrated four_line_display_ALT usermod
  • usermod_v2_four_line_display_ALT.cpp: Added GPIO36 power control

    • Automatically initializes GPIO36 and pulls LOW on startup
    • Enables OLED power supply without manual hardware modifications

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

  • Build succeeds with no errors
  • Memory usage: RAM 23.6%, Flash 58.0%
  • Released as v17.1.1-heltec-oled on GitHub

Related Releases

  • v17.0.0-dev-heltec-nopsram: Initial no-PSRAM build
  • v17.1.0-heltec-oled: OLED display support
  • v17.1.1-heltec-oled: With automatic GPIO36 power control

Summary by CodeRabbit

  • Bug Fixes
    • Improved hardware initialization for display modules to ensure compatibility across different device configurations by conditionally activating hardware-specific features when available.

Review Change Stack

- 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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Walkthrough

The 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.

Changes

HELTEC VEXT GPIO Setup

Layer / File(s) Summary
Conditional HELTEC_VEXT_PIN initialization
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp
When HELTEC_VEXT_PIN is defined, the setup method now configures it as an OUTPUT and drives it LOW within a preprocessor guard.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 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 describes adding OLED display support for a specific board, which aligns with the main objective of enabling the onboard display on Heltec WiFi LoRa 32 V3.
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.

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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.

🧹 Nitpick comments (2)
usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp (2)

218-221: 💤 Low value

Consider 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 win

Consider 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, using PinManager::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

📥 Commits

Reviewing files that changed from the base of the PR and between d337c8a and 89b267b.

📒 Files selected for processing (1)
  • usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.cpp

@dbwg2009 dbwg2009 merged commit 7a0d259 into main May 16, 2026
3 checks passed
@dbwg2009 dbwg2009 deleted the claude/fix-wled-heltec-memory-cT0D1 branch May 16, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants