Browse Source

Sort out settings.load with SD EEPROM emulation (#14458)

Tanguy Pruvot 5 years ago
parent
commit
108d0df565

+ 2
- 2
Marlin/src/HAL/HAL_ESP32/persistent_store_spiffs.cpp View File

@@ -24,7 +24,7 @@
24 24
 
25 25
 #include "../../inc/MarlinConfig.h"
26 26
 
27
-#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
27
+#if ENABLED(SD_EEPROM_EMULATION)
28 28
 
29 29
 #include "../shared/persistent_store_api.h"
30 30
 
@@ -102,5 +102,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
102 102
 
103 103
 size_t PersistentStore::capacity() { return HAL_ESP32_EEPROM_SIZE; }
104 104
 
105
-#endif // EEPROM_SETTINGS
105
+#endif // SD_EEPROM_EMULATION
106 106
 #endif // ARDUINO_ARCH_ESP32

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #include "../../inc/MarlinConfig.h"
30 30
 
31
-#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
31
+#if ENABLED(SD_EEPROM_EMULATION)
32 32
 
33 33
 #include "../shared/persistent_store_api.h"
34 34
 

+ 14
- 3
Marlin/src/Marlin.cpp View File

@@ -941,7 +941,9 @@ 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
+  #if DISABLED(SD_EEPROM_EMULATION)
945
+    (void)settings.load();
946
+  #endif
945 947
 
946 948
   #if HAS_M206_COMMAND
947 949
     // Initialize current position based on home_offset
@@ -1094,8 +1096,17 @@ void setup() {
1094 1096
     init_closedloop();
1095 1097
   #endif
1096 1098
 
1097
-  #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
1098
-    card.beginautostart();
1099
+  #if !HAS_SPI_LCD
1100
+
1101
+    #if ENABLED(SD_EEPROM_EMULATION)
1102
+      SERIAL_ECHOLNPGM("Loading settings from SD");
1103
+      (void)settings.load();
1104
+    #endif
1105
+
1106
+    #if ENABLED(INIT_SDCARD_ON_BOOT)
1107
+      card.beginautostart();
1108
+    #endif
1109
+
1099 1110
   #endif
1100 1111
 
1101 1112
   #if HAS_TRINAMIC && DISABLED(PS_DEFAULT_OFF)

+ 4
- 0
Marlin/src/inc/Conditionals_post.h View File

@@ -1734,3 +1734,7 @@
1734 1734
     #define INIT_SDCARD_ON_BOOT
1735 1735
   #endif
1736 1736
 #endif
1737
+
1738
+#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
1739
+  #define SD_EEPROM_EMULATION
1740
+#endif

+ 10
- 1
Marlin/src/lcd/ultralcd.cpp View File

@@ -81,6 +81,10 @@
81 81
 
82 82
 #include "../Marlin.h"
83 83
 
84
+#if ENABLED(SD_EEPROM_EMULATION)
85
+  #include "../module/configuration_store.h"
86
+#endif
87
+
84 88
 #if ENABLED(POWER_LOSS_RECOVERY)
85 89
   #include "../feature/power_loss_recovery.h"
86 90
 #endif
@@ -783,8 +787,13 @@ void MarlinUI::update() {
783 787
       if (sd_status) {
784 788
         safe_delay(500); // Some boards need a delay to get settled
785 789
         card.initsd();
786
-        if (old_sd_status == 2)
790
+        if (old_sd_status == 2) {
791
+          #if ENABLED(SD_EEPROM_EMULATION)
792
+            SERIAL_ECHOLNPGM("Loading settings from SD");
793
+            (void)settings.load();
794
+          #endif
787 795
           card.beginautostart();  // Initial boot
796
+        }
788 797
         else
789 798
           set_status_P(PSTR(MSG_SD_INSERTED));
790 799
       }

+ 0
- 8
Marlin/src/sd/cardreader.cpp View File

@@ -353,9 +353,6 @@ 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();
358
-    #endif
359 356
   }
360 357
   setroot();
361 358
 
@@ -561,11 +558,6 @@ void CardReader::checkautostart() {
561 558
 
562 559
   if (!isDetected()) initsd();
563 560
 
564
-  #if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
565
-    SERIAL_ECHOLNPGM("Loading settings from SD");
566
-    (void)settings.load();
567
-  #endif
568
-
569 561
   if (isDetected()
570 562
     #if ENABLED(POWER_LOSS_RECOVERY)
571 563
       && !recovery.valid() // Don't run auto#.g when a resume file exists

Loading…
Cancel
Save