Browse Source
Fix double claim, eliminate dead code at compile time
pull/1608/head
Wessel Nieboer
4 months ago
No known key found for this signature in database
GPG Key ID: 929C8E45E33B5FD2
1 changed files with
6 additions and
6 deletions
-
src/helpers/ui/SSD1306Display.cpp
|
|
|
@ -19,11 +19,9 @@ bool SSD1306Display::begin() { |
|
|
|
|
|
|
|
void SSD1306Display::turnOn() { |
|
|
|
if (!_isOn) { |
|
|
|
if (_peripher_power) { |
|
|
|
_peripher_power->claim(); |
|
|
|
begin(); |
|
|
|
} |
|
|
|
_isOn = true; |
|
|
|
if (_peripher_power) _peripher_power->claim(); |
|
|
|
_isOn = true; // set before begin() to prevent double claim
|
|
|
|
if (_peripher_power) begin(); // re-init display after power was cut
|
|
|
|
} |
|
|
|
display.ssd1306_command(SSD1306_DISPLAYON); |
|
|
|
} |
|
|
|
@ -32,7 +30,9 @@ void SSD1306Display::turnOff() { |
|
|
|
display.ssd1306_command(SSD1306_DISPLAYOFF); |
|
|
|
if (_isOn) { |
|
|
|
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(); |
|
|
|
} |
|
|
|
_isOn = false; |
|
|
|
|