Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions platformio.ini
Comment thread
dbwg2009 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,28 @@ board_build.partitions = ${esp32.default_partitions}
board_build.f_flash = 80000000L
board_build.flash_mode = qio

[env:heltec_wifi_lora_32_v3]
Comment thread
softhack007 marked this conversation as resolved.
Outdated
;; Heltec WiFi LoRa 32 V3 - ESP32-S3FN8, 8MB flash, NO PSRAM
;; IMPORTANT: BOARD_HAS_PSRAM must NOT be set on this board.
;; This board has no PSRAM. Setting BOARD_HAS_PSRAM causes the DMA/memory allocation
;; libraries to reserve memory only in SPIRAM (which doesn't exist on this board),
;; resulting in Error 8 (memory depleted) at boot. See: esp32s3dev_4MB_qspi_hub75 for
;; a similar pattern of handling ESP32-S3 boards without PSRAM.
;; Display: onboard 0.96" SSD1306 128x64 I2C OLED (SDA=GPIO17, SCL=GPIO18, RST=GPIO21)
;; Vext power rail for OLED: set GPIO36 LOW in display usermod via -D HELTEC_VEXT_PIN=36
extends = esp32s3
board = heltec_wifi_lora_32_V3
build_flags = ${common.build_flags} ${esp32s3.build_flags}
-D WLED_RELEASE_NAME=\"Heltec_WiFi_LoRa_32_V3\"
-D WLED_WATCHDOG_TIMEOUT=0
-D ARDUINO_USB_CDC_ON_BOOT=0
-D ARDUINO_USB_MODE=1
board_build.partitions = ${esp32.large_partitions}
board_upload.flash_size = 8MB
board_upload.maximum_size = 8388608
board_build.f_flash = 80000000L
board_build.flash_mode = qio

[env:esp32s3_4M_none]
;; ESP32-S3 with 4MB FLASH, no PSRAM
extends = esp32s3
Expand Down
14 changes: 14 additions & 0 deletions usermods/usermod_v2_four_line_display_ALT/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ These options are configurable in Config > Usermods

Note: the Four Line Display usermod requires the libraries `U8g2` and `Wire`.

### Board-specific Build Flags

Some boards require special initialization for I2C displays. Set these flags in your `platformio_override.ini` (do not edit the main `platformio.ini`):

* `FLD_PIN_RST` - GPIO pin for display hardware reset (optional)
* 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)
* Pulls the pin LOW before display init to enable power
* Required on boards where the OLED is powered via a switchable rail rather than always-on VCC
* Example: `-D HELTEC_VEXT_PIN=36` for Heltec WiFi LoRa 32 V3

## Change Log

2021-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ void FourLineDisplayUsermod::sleepOrClock(bool enabled) {
// gets called once at boot. Do all initialization that doesn't depend on
// network here
void FourLineDisplayUsermod::setup() {
#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
Comment on lines +218 to +227

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.

#ifdef FLD_PIN_RST
Comment thread
softhack007 marked this conversation as resolved.
Outdated
// 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);
}
#endif
bool isSPI = (type == SSD1306_SPI || type == SSD1306_SPI64 || type == SSD1309_SPI64);

// check if pins are -1 and disable usermod as PinManager::allocateMultiplePins() will accept -1 as a valid pin
Expand Down