settings: store runout sensor on/off (#13876)

This commit is contained in:
Tanguy Pruvot 2019-05-02 07:47:26 +02:00 committed by Scott Lahteine
parent e7682eea42
commit e5438a9a03

View File

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V64"
#define EEPROM_VERSION "V65"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -90,6 +90,10 @@
#include "../feature/pause.h"
#if HAS_FILAMENT_SENSOR
#include "../feature/runout.h"
#endif
#if ENABLED(EXTRA_LIN_ADVANCE_K)
extern float saved_extruder_advance_K[EXTRUDERS];
#endif
@ -141,6 +145,11 @@ typedef struct SettingsDataStruct {
float hotend_offset[XYZ][HOTENDS - 1]; // M218 XYZ
#endif
//
// FILAMENT_RUNOUT_SENSOR
//
bool runout_sensor_enabled; // M412 S
//
// ENABLE_LEVELING_FADE_HEIGHT
//
@ -291,6 +300,8 @@ typedef struct SettingsDataStruct {
} SettingsData;
//static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!");
MarlinSettings settings;
uint16_t MarlinSettings::datasize() { return sizeof(SettingsData); }
@ -512,6 +523,18 @@ void MarlinSettings::postprocess() {
#endif
}
//
// Filament Runout Sensor
//
{
#if HAS_FILAMENT_SENSOR
EEPROM_WRITE(runout.enabled);
#else
const bool runout_sensor_enabled = true;
EEPROM_WRITE(runout_sensor_enabled);
#endif
}
//
// Global Leveling
//
@ -1237,6 +1260,19 @@ void MarlinSettings::postprocess() {
#endif
}
//
// Filament Runout Sensor
//
{
_FIELD_TEST(runout_sensor_enabled);
#if HAS_FILAMENT_SENSOR
EEPROM_READ(runout.enabled);
#else
bool runout_sensor_enabled;
EEPROM_READ(runout_sensor_enabled);
#endif
}
//
// Global Leveling
//
@ -2047,6 +2083,19 @@ void MarlinSettings::reset() {
reset_hotend_offsets();
#endif
//
// Filament Runout Sensor
//
#if HAS_FILAMENT_SENSOR
runout.enabled = true;
runout.reset();
#endif
//
// Tool-change Settings
//
#if EXTRUDERS > 1
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
toolchange_settings.swap_length = TOOLCHANGE_FIL_SWAP_LENGTH;
@ -2059,6 +2108,10 @@ void MarlinSettings::reset() {
toolchange_settings.z_raise = TOOLCHANGE_ZRAISE;
#endif
//
// Magnetic Parking Extruder
//
#if ENABLED(MAGNETIC_PARKING_EXTRUDER)
mpe_settings_init();
#endif
@ -2540,6 +2593,12 @@ void MarlinSettings::reset() {
}
#endif
#if HAS_FILAMENT_SENSOR
CONFIG_ECHO_HEADING("Filament Runout Sensor:");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M412 S", int(runout.enabled));
#endif
/**
* Bed Leveling
*/