Skip to content

Commit

Permalink
SSD1306 prefs start-up optimisation
Browse files Browse the repository at this point in the history
Avoid
[ 137][E][Preferences.cpp:483] getString(): nvs_get_str len fail: SSD1306Config NOT_FOUND
error during start-up when no save preferences have been found
  • Loading branch information
DigiH committed Mar 27, 2023
1 parent 0ece563 commit 1e16248
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main/ZdisplaySSD1306.ino
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ void SSD1306Config_init() {
bool SSD1306Config_load() {
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
preferences.begin(Gateway_Short_Name, true);
String exists = preferences.getString("SSD1306Config", "{}");
if (exists != "{}") {
bool exists = preferences.isKey("SSD1306Config");
if (exists) {
auto error = deserializeJson(jsonBuffer, preferences.getString("SSD1306Config", "{}"));
preferences.end();
if (error) {
Expand All @@ -258,6 +258,7 @@ bool SSD1306Config_load() {
displayMetric = jo["displaymetric"].as<bool>();
idlelogo = jo["idlelogo"].as<bool>();
displayFlip = jo["display-flip"].as<bool>();
Log.notice(F("Saved SSD1306 config loaded" CR));
return true;
} else {
preferences.end();
Expand Down

0 comments on commit 1e16248

Please sign in to comment.