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

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

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

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

353
   else {
353
   else {
354
     flag.detected = true;
354
     flag.detected = true;
355
     SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
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
     #endif
358
     #endif
359
   }
359
   }
360
   setroot();
360
   setroot();
560
   if (autostart_index < 0 || flag.sdprinting) return;
560
   if (autostart_index < 0 || flag.sdprinting) return;
561
 
561
 
562
   if (!isDetected()) initsd();
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
   #endif
565
   #endif
568
 
566
 
569
   if (isDetected()
567
   if (isDetected()

Loading…
Cancel
Save