From 5b9476fe78bc14080b0b50bed7112dccd24c549c Mon Sep 17 00:00:00 2001 From: james94jeans2 Date: Tue, 21 Feb 2017 13:49:31 +0100 Subject: [PATCH] Added z_fade_height to EEPROM-Settings Firmware was forgetting the z_fade_height in Planner, set by M420 Z, after each reset or loading settings from EEPROM. Added the float z_fade_height to EEPROM-Storage, now remembers the value. --- Marlin/Marlin.h | 4 + Marlin/configuration_store.cpp | 114 +++++++++++++----- .../delta/kossel_pro/Configuration.h | 2 +- Marlin/planner.cpp | 4 +- 4 files changed, 90 insertions(+), 34 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 5e4a27834..122a3547a 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -307,6 +307,10 @@ float code_value_temp_diff(); void reset_bed_level(); #endif +#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + void set_z_fade_height(const float zfh); +#endif + #if ENABLED(Z_DUAL_ENDSTOPS) extern float z_endstop_adj; #endif diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index f83057bed..2eda9ae47 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -36,13 +36,13 @@ * */ -#define EEPROM_VERSION "V32" +#define EEPROM_VERSION "V33" // Change EEPROM version if these are changed: #define EEPROM_OFFSET 100 /** - * V32 EEPROM Layout: + * V33 EEPROM Layout: * * 100 Version (char x4) * 104 EEPROM Checksum (uint16_t) @@ -64,25 +64,28 @@ * 195 M206 XYZ home_offset (float x3) * 207 M218 XYZ hotend_offset (float x3 per additional hotend) * + * Global Leveling: + * 219 z_fade_height (float) + * * Mesh bed leveling: 43 bytes - * 219 M420 S from mbl.status (bool) - * 220 mbl.z_offset (float) - * 224 GRID_MAX_POINTS_X (uint8_t) - * 225 GRID_MAX_POINTS_Y (uint8_t) - * 226 G29 S3 XYZ z_values[][] (float x9, up to float x 81) +288 + * 223 M420 S from mbl.status (bool) + * 224 mbl.z_offset (float) + * 228 GRID_MAX_POINTS_X (uint8_t) + * 229 GRID_MAX_POINTS_Y (uint8_t) + * 230 G29 S3 XYZ z_values[][] (float x9, up to float x 81) +288 * * AUTO BED LEVELING 4 bytes - * 262 M851 zprobe_zoffset (float) + * 266 M851 zprobe_zoffset (float) * * ABL_PLANAR (or placeholder): 36 bytes - * 266 planner.bed_level_matrix (matrix_3x3 = float x9) + * 270 planner.bed_level_matrix (matrix_3x3 = float x9) * * AUTO_BED_LEVELING_BILINEAR (or placeholder): 47 bytes - * 302 GRID_MAX_POINTS_X (uint8_t) - * 303 GRID_MAX_POINTS_Y (uint8_t) - * 304 bilinear_grid_spacing (int x2) - * 308 G29 L F bilinear_start (int x2) - * 312 bed_level_grid[][] (float x9, up to float x256) +988 + * 306 GRID_MAX_POINTS_X (uint8_t) + * 307 GRID_MAX_POINTS_Y (uint8_t) + * 308 bilinear_grid_spacing (int x2) + * 312 G29 L F bilinear_start (int x2) + * 316 bed_level_grid[][] (float x9, up to float x256) +988 * * DELTA (if deltabot): 48 bytes * 348 M666 XYZ endstop_adj (float x3) @@ -144,10 +147,10 @@ * 568 M906 E1 stepperE1 current (uint16_t) * 570 M906 E2 stepperE2 current (uint16_t) * 572 M906 E3 stepperE3 current (uint16_t) - * 572 M906 E4 stepperE4 current (uint16_t) + * 576 M906 E4 stepperE4 current (uint16_t) * - * 576 Minimum end-point - * 1897 (576 + 36 + 9 + 288 + 988) Maximum end-point + * 580 Minimum end-point + * 1901 (580 + 36 + 9 + 288 + 988) Maximum end-point */ #include "Marlin.h" #include "language.h" @@ -200,6 +203,16 @@ void Config_Postprocess() { // Software endstops depend on home_offset LOOP_XYZ(i) update_software_endstops((AxisEnum)i); #endif + + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + set_z_fade_height( + //#if ENABLED(AUTO_BED_LEVELING_UBL) + // ubl.state.g29_correction_fade_height + //#else + planner.z_fade_height + //#endif + ); + #endif } #if ENABLED(EEPROM_SETTINGS) @@ -289,6 +302,17 @@ void Config_Postprocess() { LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]); #endif + // + // General Leveling + // + + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + EEPROM_WRITE(planner.z_fade_height); + #else + dummy = 10.0; + EEPROM_WRITE(dummy); + #endif + // // Mesh Bed Leveling // @@ -618,6 +642,16 @@ void Config_Postprocess() { LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]); #endif + // + // General Leveling + // + + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + EEPROM_READ(planner.z_fade_height); + #else + EEPROM_READ(dummy); + #endif + // // Mesh (Manual) Bed Leveling // @@ -927,6 +961,11 @@ void Config_ResetDefault() { planner.max_jerk[Y_AXIS] = DEFAULT_YJERK; planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK; planner.max_jerk[E_AXIS] = DEFAULT_EJERK; + + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + planner.z_fade_height = 0.0; + #endif + #if DISABLED(NO_WORKSPACE_OFFSETS) ZERO(home_offset); #endif @@ -968,11 +1007,13 @@ void Config_ResetDefault() { COPY(delta_diagonal_rod_trim, drt); COPY(delta_tower_angle_trim, dta); #elif ENABLED(Z_DUAL_ENDSTOPS) - #if defined(Z_DUAL_ENDSTOPS_ADJUSTMENT) - float z_endstop_adj = Z_DUAL_ENDSTOPS_ADJUSTMENT; - #else - float z_endstop_adj = 0; - #endif + float z_endstop_adj = + #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT + Z_DUAL_ENDSTOPS_ADJUSTMENT + #else + 0 + #endif + ; #endif #if ENABLED(ULTIPANEL) @@ -1027,11 +1068,11 @@ void Config_ResetDefault() { #endif volumetric_enabled = - #if ENABLED(VOLUMETRIC_DEFAULT_ON) - true - #else - false - #endif + #if ENABLED(VOLUMETRIC_DEFAULT_ON) + true + #else + false + #endif ; for (uint8_t q = 0; q < COUNT(filament_size); q++) filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA; @@ -1211,7 +1252,11 @@ void Config_ResetDefault() { SERIAL_ECHOLNPGM("Mesh Bed Leveling:"); CONFIG_ECHO_START; } - SERIAL_ECHOLNPAIR(" M420 S", mbl.has_mesh() ? 1 : 0); + SERIAL_ECHOPAIR(" M420 S", mbl.has_mesh() ? 1 : 0); + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height); + #endif + SERIAL_EOL; for (uint8_t py = 1; py <= GRID_MAX_POINTS_Y; py++) { for (uint8_t px = 1; px <= GRID_MAX_POINTS_X; px++) { CONFIG_ECHO_START; @@ -1229,8 +1274,11 @@ void Config_ResetDefault() { SERIAL_ECHOLNPGM("Unified Bed Leveling:"); CONFIG_ECHO_START; } - - SERIAL_ECHOLNPAIR(" M420 S", ubl.state.active ? 1 : 0); + SERIAL_ECHOPAIR(" M420 S", ubl.state.active ? 1 : 0); + //#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + // SERIAL_ECHOLNPAIR(" Z", ubl.state.g29_correction_fade_height); + //#endif + SERIAL_EOL; if (!forReplay) { SERIAL_ECHOPGM("\nUBL is "); @@ -1264,7 +1312,11 @@ void Config_ResetDefault() { SERIAL_ECHOLNPGM("Auto Bed Leveling:"); CONFIG_ECHO_START; } - SERIAL_ECHOLNPAIR(" M420 S", planner.abl_enabled ? 1 : 0); + SERIAL_ECHOPAIR(" M420 S", planner.abl_enabled ? 1 : 0); + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height); + #endif + SERIAL_EOL; #endif diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 42efb89d1..113db63bb 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -819,7 +819,7 @@ */ #define Z_CLEARANCE_DEPLOY_PROBE 100 // Z Clearance for Deploy/Stow #define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points - + // For M851 give a range for adjusting the Z probe offset #define Z_PROBE_OFFSET_RANGE_MIN -15 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 22da7a3de..bb7578db3 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -109,8 +109,8 @@ float Planner::min_feedrate_mm_s, #endif #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - float Planner::z_fade_height = 0.0, - Planner::inverse_z_fade_height = 0.0; + float Planner::z_fade_height, + Planner::inverse_z_fade_height; #endif #if ENABLED(AUTOTEMP)