This commit is contained in:
Vovodroid 2026-02-28 21:33:17 -08:00 committed by GitHub
commit 13a424a64f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View file

@ -1886,6 +1886,10 @@
#if ENABLED(POWER_LOSS_RECOVER_ZHOME)
//#define POWER_LOSS_ZHOME_POS { 0, 0 } // Safe XY position to home Z while avoiding objects on the bed
#endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
//#define POWER_LOSS_SAVE_BILINEAR_MESH // Save bilinear mesh in resume data
#endif
#endif
/**

View file

@ -270,6 +270,12 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
info.flag.dryrun = !!(marlin_debug_flags & MARLIN_DEBUG_DRYRUN);
info.flag.allow_cold_extrusion = TERN0(PREVENT_COLD_EXTRUSION, thermalManager.allow_cold_extrude);
#if ENABLED(POWER_LOSS_SAVE_BILINEAR_MESH)
info.grid_spacing = bedlevel.grid_spacing;
info.grid_start = bedlevel.grid_start;
memcpy(info.z_values, bedlevel.z_values, sizeof(bed_mesh_t));
#endif
write();
}
}
@ -493,6 +499,13 @@ void PrintJobRecovery::resume() {
motion.set_all_homed();
#if HAS_LEVELING
#if ENABLED(POWER_LOSS_SAVE_BILINEAR_MESH)
bedlevel.set_grid(info.grid_spacing, info.grid_start);
memcpy(bedlevel.z_values, info.z_values, sizeof(bed_mesh_t));
TERN_(EXTENSIBLE_UI, GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, bedlevel.z_values[x][y]));
#endif
// Restore Z fade and possibly re-enable bed leveling compensation.
// Leveling may already be enabled due to the ENABLE_LEVELING_AFTER_G28 option.
// TODO: Add a G28 parameter to leave leveling disabled.

View file

@ -42,6 +42,10 @@
#include "mixing.h"
#endif
#if ENABLED(POWER_LOSS_SAVE_BILINEAR_MESH)
#include "bedlevel/bedlevel.h"
#endif
#if !defined(POWER_LOSS_STATE) && PIN_EXISTS(POWER_LOSS)
#define POWER_LOSS_STATE HIGH
#endif
@ -145,6 +149,12 @@ typedef struct {
#endif
} flag;
#if ENABLED(POWER_LOSS_SAVE_BILINEAR_MESH)
xy_pos_t grid_spacing;
xy_pos_t grid_start;
bed_mesh_t z_values;
#endif
uint8_t valid_foot;
bool valid() { return valid_head && valid_head == valid_foot; }