Remove obsolete UBL z_offset

This commit is contained in:
Scott Lahteine
2017-10-12 22:20:02 -05:00
parent cc01a36363
commit 1adb5a6a48
6 changed files with 27 additions and 104 deletions

View File

@ -36,13 +36,13 @@
*
*/
#define EEPROM_VERSION "V41"
#define EEPROM_VERSION "V42"
// Change EEPROM version if these are changed:
#define EEPROM_OFFSET 100
/**
* V41 EEPROM Layout:
* V42 EEPROM Layout:
*
* 100 Version (char x4)
* 104 EEPROM CRC16 (uint16_t)
@ -87,13 +87,12 @@
* 312 G29 L F bilinear_start (int x2)
* 316 z_values[][] (float x9, up to float x256) +988
*
* AUTO_BED_LEVELING_UBL: 6 bytes
* AUTO_BED_LEVELING_UBL: 2 bytes
* 324 G29 A ubl.state.active (bool)
* 325 G29 Z ubl.state.z_offset (float)
* 329 G29 S ubl.state.storage_slot (int8_t)
* 325 G29 S ubl.state.storage_slot (int8_t)
*
* DELTA: 48 bytes
* 348 M666 XYZ delta_endstop_adj (float x3)
* 344 M666 XYZ delta_endstop_adj (float x3)
* 360 M665 R delta_radius (float)
* 364 M665 L delta_diagonal_rod (float)
* 368 M665 S delta_segments_per_second (float)
@ -408,14 +407,11 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
EEPROM_WRITE(ubl.state.active);
EEPROM_WRITE(ubl.state.z_offset);
EEPROM_WRITE(ubl.state.storage_slot);
#else
const bool ubl_active = false;
dummy = 0.0f;
const int8_t storage_slot = -1;
EEPROM_WRITE(ubl_active);
EEPROM_WRITE(dummy);
EEPROM_WRITE(storage_slot);
#endif // AUTO_BED_LEVELING_UBL
@ -798,12 +794,10 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
EEPROM_READ(ubl.state.active);
EEPROM_READ(ubl.state.z_offset);
EEPROM_READ(ubl.state.storage_slot);
#else
uint8_t dummyui8;
EEPROM_READ(dummyb);
EEPROM_READ(dummy);
EEPROM_READ(dummyui8);
#endif // AUTO_BED_LEVELING_UBL
@ -1573,11 +1567,6 @@ void MarlinSettings::reset() {
ubl.report_state();
SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
SERIAL_ECHOPGM("z_offset: ");
SERIAL_ECHO_F(ubl.state.z_offset, 6);
SERIAL_EOL();
SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
SERIAL_ECHOLNPGM(" meshes.\n");
}

View File

@ -560,9 +560,9 @@ void Planner::calculate_volumetric_multipliers() {
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
// if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return;
lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
lz += ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
#else // no fade
lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly);
lz += ubl.get_z_correction(lx, ly);
#endif // FADE
#endif // UBL
@ -625,22 +625,22 @@ void Planner::calculate_volumetric_multipliers() {
const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
z_virtual = z_physical - ubl.state.z_offset - z_correct;
z_virtual = z_physical - z_correct;
float z_logical = LOGICAL_Z_POSITION(z_virtual);
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
// for P=physical_z, L=logical_z, M=mesh_z, O=z_offset, H=fade_height,
// Given P=L+O+M(1-L/H) (faded mesh correction formula for L<H)
// then L=P-O-M(1-L/H)
// so L=P-O-M+ML/H
// so L-ML/H=P-O-M
// so L(1-M/H)=P-O-M
// so L=(P-O-M)/(1-M/H) for L<H
// for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
// Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
// then L=P-M(1-L/H)
// so L=P-M+ML/H
// so L-ML/H=P-M
// so L(1-M/H)=P-M
// so L=(P-M)/(1-M/H) for L<H
if (planner.z_fade_height) {
if (z_logical >= planner.z_fade_height)
z_logical = LOGICAL_Z_POSITION(z_physical - ubl.state.z_offset);
z_logical = LOGICAL_Z_POSITION(z_physical);
else
z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
}