Browse Source

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

pull/1/head
Tanguy Pruvot 5 years ago
committed by Scott Lahteine
parent
commit
108d0df565
  1. 4
      Marlin/src/HAL/HAL_ESP32/persistent_store_spiffs.cpp
  2. 2
      Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp
  3. 17
      Marlin/src/Marlin.cpp
  4. 4
      Marlin/src/inc/Conditionals_post.h
  5. 11
      Marlin/src/lcd/ultralcd.cpp
  6. 8
      Marlin/src/sd/cardreader.cpp

4
Marlin/src/HAL/HAL_ESP32/persistent_store_spiffs.cpp

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

2
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp

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

17
Marlin/src/Marlin.cpp

@ -941,7 +941,9 @@ void setup() {
// Load data from EEPROM if available (or use defaults)
// This also updates variables in the planner, elsewhere
(void)settings.load();
#if DISABLED(SD_EEPROM_EMULATION)
(void)settings.load();
#endif
#if HAS_M206_COMMAND
// Initialize current position based on home_offset
@ -1094,8 +1096,17 @@ void setup() {
init_closedloop();
#endif
#if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
card.beginautostart();
#if !HAS_SPI_LCD
#if ENABLED(SD_EEPROM_EMULATION)
SERIAL_ECHOLNPGM("Loading settings from SD");
(void)settings.load();
#endif
#if ENABLED(INIT_SDCARD_ON_BOOT)
card.beginautostart();
#endif
#endif
#if HAS_TRINAMIC && DISABLED(PS_DEFAULT_OFF)

4
Marlin/src/inc/Conditionals_post.h

@ -1734,3 +1734,7 @@
#define INIT_SDCARD_ON_BOOT
#endif
#endif
#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
#define SD_EEPROM_EMULATION
#endif

11
Marlin/src/lcd/ultralcd.cpp

@ -81,6 +81,10 @@
#include "../Marlin.h"
#if ENABLED(SD_EEPROM_EMULATION)
#include "../module/configuration_store.h"
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../feature/power_loss_recovery.h"
#endif
@ -783,8 +787,13 @@ void MarlinUI::update() {
if (sd_status) {
safe_delay(500); // Some boards need a delay to get settled
card.initsd();
if (old_sd_status == 2)
if (old_sd_status == 2) {
#if ENABLED(SD_EEPROM_EMULATION)
SERIAL_ECHOLNPGM("Loading settings from SD");
(void)settings.load();
#endif
card.beginautostart(); // Initial boot
}
else
set_status_P(PSTR(MSG_SD_INSERTED));
}

8
Marlin/src/sd/cardreader.cpp

@ -353,9 +353,6 @@ void CardReader::initsd() {
else {
flag.detected = true;
SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
(void)settings.load();
#endif
}
setroot();
@ -561,11 +558,6 @@ void CardReader::checkautostart() {
if (!isDetected()) initsd();
#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
SERIAL_ECHOLNPGM("Loading settings from SD");
(void)settings.load();
#endif
if (isDetected()
#if ENABLED(POWER_LOSS_RECOVERY)
&& !recovery.valid() // Don't run auto#.g when a resume file exists

Loading…
Cancel
Save