[SSD1306] prefs start-up optimisation (#1579)
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
This commit is contained in:
1 parent
b2411e3566
commit
08279baf65
1 file changed
+3
-2
@@ -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) {
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user