Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: store runout sensor on/off #13876

Merged
merged 2 commits into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion Marlin/src/module/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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); }
Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down