Skip to content

Commit abab058

Browse files
Update OpenFIREcommon.cpp - assign OLED.display pointer to nullptr
By assigning the OLED.display pointer to nullptr, the program works and the micro doesn't crash, even if the OLED display is not connected even if the pins are configured.
1 parent 65f50fc commit abab058

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

OpenFIREmain/OpenFIREcommon.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,14 @@ void FW_Common::FeedbackSet()
9292
// wrapper will manage display validity
9393
// check it's not using the camera's I2C line
9494
if(OF_Prefs::toggles[OF_Const::i2cOLED]) {
95-
if(!OLED.Begin()) { if(OLED.display != nullptr) delete OLED.display; }
95+
if(!OLED.Begin()) {
96+
if(OLED.display != nullptr) {
97+
delete OLED.display;
98+
OLED.display = nullptr;
99+
}
100+
}
96101
}
97-
#endif // USES_DISPLAY
102+
#endif // USES_DISPLAY
98103
}
99104
}
100105

0 commit comments

Comments
 (0)