Browse Source

Prevent extra settings.load on boot (#14499)

Tanguy Pruvot 5 years ago
parent
commit
8873c583d3
3 changed files with 13 additions and 9 deletions
  1. 1
    1
      Marlin/src/Marlin.cpp
  2. 8
    2
      Marlin/src/module/configuration_store.h
  3. 4
    6
      Marlin/src/sd/cardreader.cpp

+ 1
- 1
Marlin/src/Marlin.cpp View File

@@ -941,7 +941,7 @@ void setup() {
941 941
 
942 942
   // Load data from EEPROM if available (or use defaults)
943 943
   // This also updates variables in the planner, elsewhere
944
-  (void)settings.load();
944
+  settings.first_load();
945 945
 
946 946
   #if HAS_M206_COMMAND
947 947
     // Initialize current position based on home_offset

+ 8
- 2
Marlin/src/module/configuration_store.h View File

@@ -29,8 +29,6 @@
29 29
 
30 30
 class MarlinSettings {
31 31
   public:
32
-    MarlinSettings() { }
33
-
34 32
     static uint16_t datasize();
35 33
 
36 34
     static void reset();
@@ -55,9 +53,15 @@ class MarlinSettings {
55 53
     #endif
56 54
 
57 55
     #if ENABLED(EEPROM_SETTINGS)
56
+
58 57
       static bool load();      // Return 'true' if data was loaded ok
59 58
       static bool validate();  // Return 'true' if EEPROM data is ok
60 59
 
60
+      static inline void first_load() {
61
+        static bool loaded = false;
62
+        if (!loaded && load()) loaded = true;
63
+      }
64
+
61 65
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
62 66
                                          // That can store is enabled
63 67
         static uint16_t meshes_start_index();
@@ -73,6 +77,8 @@ class MarlinSettings {
73 77
     #else
74 78
       FORCE_INLINE
75 79
       static bool load() { reset(); report(); return true; }
80
+      FORCE_INLINE
81
+      static void first_load() { (void)load(); }
76 82
     #endif
77 83
 
78 84
     #if DISABLED(DISABLE_M503)

+ 4
- 6
Marlin/src/sd/cardreader.cpp View File

@@ -353,8 +353,8 @@ void CardReader::initsd() {
353 353
   else {
354 354
     flag.detected = true;
355 355
     SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
356
-    #if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
357
-      (void)settings.load();
356
+    #if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
357
+      settings.first_load();
358 358
     #endif
359 359
   }
360 360
   setroot();
@@ -560,10 +560,8 @@ void CardReader::checkautostart() {
560 560
   if (autostart_index < 0 || flag.sdprinting) return;
561 561
 
562 562
   if (!isDetected()) initsd();
563
-
564
-  #if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
565
-    SERIAL_ECHOLNPGM("Loading settings from SD");
566
-    (void)settings.load();
563
+  #if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
564
+    else settings.first_load();
567 565
   #endif
568 566
 
569 567
   if (isDetected()

Loading…
Cancel
Save