Merge pull request #2 from weebl2000/pr-1570-fix-heltec-v4-power

Fix double claim, eliminate dead code at compile time
This commit is contained in:
Quency-D
2026-02-09 10:06:59 +08:00
committed by GitHub

View File

@@ -19,11 +19,9 @@ bool SSD1306Display::begin() {
void SSD1306Display::turnOn() { void SSD1306Display::turnOn() {
if (!_isOn) { if (!_isOn) {
if (_peripher_power) { if (_peripher_power) _peripher_power->claim();
_peripher_power->claim(); _isOn = true; // set before begin() to prevent double claim
begin(); if (_peripher_power) begin(); // re-init display after power was cut
}
_isOn = true;
} }
display.ssd1306_command(SSD1306_DISPLAYON); display.ssd1306_command(SSD1306_DISPLAYON);
} }
@@ -32,7 +30,9 @@ void SSD1306Display::turnOff() {
display.ssd1306_command(SSD1306_DISPLAYOFF); display.ssd1306_command(SSD1306_DISPLAYOFF);
if (_isOn) { if (_isOn) {
if (_peripher_power) { if (_peripher_power) {
if (PIN_OLED_RESET >= 0) digitalWrite(PIN_OLED_RESET, LOW); #if PIN_OLED_RESET >= 0
digitalWrite(PIN_OLED_RESET, LOW);
#endif
_peripher_power->release(); _peripher_power->release();
} }
_isOn = false; _isOn = false;