File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 33#include " Themes.h"
44#include " Menu.h"
55#include < LittleFS.h>
6+ #include " nvs_flash.h"
67
78// Time of inactivity to start writing preferences
89#define STORE_TIME 10000
@@ -345,3 +346,11 @@ bool diskInit(bool force)
345346 // Serial.println("Mounted LittleFS!");
346347 return (true );
347348}
349+
350+ bool nvsErase ()
351+ {
352+ return (nvs_flash_erase () == ESP_OK &&
353+ nvs_flash_init () == ESP_OK &&
354+ nvs_flash_erase_partition (STORAGE_PARTITION) == ESP_OK &&
355+ nvs_flash_init_partition (STORAGE_PARTITION) == ESP_OK);
356+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ extern Preferences prefs;
1717void prefsTickTime ();
1818void prefsInvalidate ();
1919bool prefsAreWritten ();
20+ bool nvsErase ();
2021
2122bool diskInit (bool force = false);
2223
Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ void setup()
108108 // Enable serial port
109109 Serial.begin (115200 );
110110
111- // Initialize flash file system
112- diskInit ();
113-
114111 // Encoder pins. Enable internal pull-ups
115112 pinMode (ENCODER_PUSH_BUTTON, INPUT_PULLUP);
116113 pinMode (ENCODER_PIN_A, INPUT_PULLUP);
@@ -157,7 +154,7 @@ void setup()
157154 // Note: preferences reset is recommended after firmware updates
158155 if (digitalRead (ENCODER_PUSH_BUTTON)==LOW)
159156 {
160- prefsInvalidate ();
157+ nvsErase ();
161158 diskInit (true );
162159
163160 ledcWrite (PIN_LCD_BL, 255 ); // Default value 255 = 100%
@@ -170,6 +167,9 @@ void setup()
170167 while (digitalRead (ENCODER_PUSH_BUTTON) == LOW) delay (100 );
171168 }
172169
170+ // Initialize flash file system
171+ diskInit ();
172+
173173 // Check for SI4732 connected on I2C interface
174174 // If the SI4732 is not detected, then halt with no further processing
175175 rx.setI2CFastModeCustom (100000 );
You can’t perform that action at this time.
0 commit comments