|
|
|
@ -314,7 +314,7 @@
|
|
|
|
|
|
|
|
|
|
void __attribute__((optimize("O0"))) gcode_G29() {
|
|
|
|
|
|
|
|
|
|
if (ubl.eeprom_start < 0) {
|
|
|
|
|
if (!settings.calc_num_meshes()) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?You need to enable your EEPROM and initialize it");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("with M502, M500, M501 in that order.\n");
|
|
|
|
|
return;
|
|
|
|
@ -419,9 +419,9 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (code_seen('P')) {
|
|
|
|
|
if (WITHIN(phase_value, 0, 1) && ubl.state.eeprom_storage_slot == -1) {
|
|
|
|
|
ubl.state.eeprom_storage_slot = 0;
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Default storage slot 0 selected.\n");
|
|
|
|
|
if (WITHIN(phase_value, 0, 1) && ubl.state.storage_slot == -1) {
|
|
|
|
|
ubl.state.storage_slot = 0;
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Default storage slot 0 selected.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (phase_value) {
|
|
|
|
@ -430,7 +430,7 @@
|
|
|
|
|
// Zero Mesh Data
|
|
|
|
|
//
|
|
|
|
|
ubl.reset();
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh zeroed.\n");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh zeroed.");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
@ -439,7 +439,7 @@
|
|
|
|
|
//
|
|
|
|
|
if (!code_seen('C')) {
|
|
|
|
|
ubl.invalidate();
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh invalidated. Probing mesh.\n");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh invalidated. Probing mesh.");
|
|
|
|
|
}
|
|
|
|
|
if (g29_verbose_level > 1) {
|
|
|
|
|
SERIAL_PROTOCOLPAIR("Probing Mesh Points Closest to (", x_pos);
|
|
|
|
@ -455,7 +455,7 @@
|
|
|
|
|
//
|
|
|
|
|
// Manually Probe Mesh in areas that can't be reached by the probe
|
|
|
|
|
//
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Manually probing unreachable mesh locations.\n");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Manually probing unreachable mesh locations.");
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
|
|
|
|
if (!x_flag && !y_flag) {
|
|
|
|
|
/**
|
|
|
|
@ -485,7 +485,7 @@
|
|
|
|
|
card_thickness = code_has_value() ? code_value_float() : measure_business_card_thickness(height);
|
|
|
|
|
|
|
|
|
|
if (fabs(card_thickness) > 1.5) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.\n");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -561,17 +561,25 @@
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
if (code_seen('L')) { // Load Current Mesh Data
|
|
|
|
|
storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
|
|
|
|
|
storage_slot = code_has_value() ? code_value_int() : ubl.state.storage_slot;
|
|
|
|
|
|
|
|
|
|
const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
|
|
|
|
int16_t a = settings.calc_num_meshes();
|
|
|
|
|
|
|
|
|
|
if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
|
|
|
|
if (!a) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ubl.load_mesh(storage_slot);
|
|
|
|
|
ubl.state.eeprom_storage_slot = storage_slot;
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Done.\n");
|
|
|
|
|
|
|
|
|
|
if (!WITHIN(storage_slot, 0, a - 1)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings.load_mesh(storage_slot);
|
|
|
|
|
ubl.state.storage_slot = storage_slot;
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Done.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
@ -579,7 +587,7 @@
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
if (code_seen('S')) { // Store (or Save) Current Mesh Data
|
|
|
|
|
storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
|
|
|
|
|
storage_slot = code_has_value() ? code_value_int() : ubl.state.storage_slot;
|
|
|
|
|
|
|
|
|
|
if (storage_slot == -1) { // Special case, we are going to 'Export' the mesh to the
|
|
|
|
|
SERIAL_ECHOLNPGM("G29 I 999"); // host in a form it can be reconstructed on a different machine
|
|
|
|
@ -597,17 +605,23 @@
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
|
|
|
|
int16_t a = settings.calc_num_meshes();
|
|
|
|
|
|
|
|
|
|
if (!a) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
|
|
|
|
|
goto LEAVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", j - 1);
|
|
|
|
|
if (!WITHIN(storage_slot, 0, a - 1)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
|
|
|
|
|
goto LEAVE;
|
|
|
|
|
}
|
|
|
|
|
ubl.store_mesh(storage_slot);
|
|
|
|
|
ubl.state.eeprom_storage_slot = storage_slot;
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Done.\n");
|
|
|
|
|
settings.store_mesh(storage_slot);
|
|
|
|
|
ubl.state.storage_slot = storage_slot;
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Done.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (code_seen('T'))
|
|
|
|
@ -654,7 +668,7 @@
|
|
|
|
|
if (ELAPSED(millis(), nxt)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("\nZ-Offset Adjustment Stopped.");
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
|
|
|
|
LCD_MESSAGEPGM("Z-Offset Stopped");
|
|
|
|
|
LCD_MESSAGEPGM("Z-Offset Stopped"); // TODO: Make translatable string
|
|
|
|
|
ubl.restore_ubl_active_state_and_leave();
|
|
|
|
|
goto LEAVE;
|
|
|
|
|
}
|
|
|
|
@ -892,7 +906,7 @@
|
|
|
|
|
return current_position[Z_AXIS];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void say_and_take_a_measurement() {
|
|
|
|
|
static void echo_and_take_a_measurement() {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM(" and take a measurement.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -906,17 +920,17 @@
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("Place shim under nozzle");
|
|
|
|
|
LCD_MESSAGEPGM("Place shim & measure");
|
|
|
|
|
LCD_MESSAGEPGM("Place shim & measure"); // TODO: Make translatable string
|
|
|
|
|
lcd_goto_screen(lcd_status_screen);
|
|
|
|
|
say_and_take_a_measurement();
|
|
|
|
|
echo_and_take_a_measurement();
|
|
|
|
|
|
|
|
|
|
const float z1 = use_encoder_wheel_to_measure_point();
|
|
|
|
|
do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("Remove shim");
|
|
|
|
|
LCD_MESSAGEPGM("Remove & measure bed");
|
|
|
|
|
say_and_take_a_measurement();
|
|
|
|
|
LCD_MESSAGEPGM("Remove & measure bed"); // TODO: Make translatable string
|
|
|
|
|
echo_and_take_a_measurement();
|
|
|
|
|
|
|
|
|
|
const float z2 = use_encoder_wheel_to_measure_point();
|
|
|
|
|
|
|
|
|
@ -962,7 +976,7 @@
|
|
|
|
|
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
|
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Moving to next");
|
|
|
|
|
LCD_MESSAGEPGM("Moving to next"); // TODO: Make translatable string
|
|
|
|
|
|
|
|
|
|
do_blocking_move_to_xy(xProbe, yProbe);
|
|
|
|
|
do_blocking_move_to_z(z_clearance);
|
|
|
|
@ -972,8 +986,10 @@
|
|
|
|
|
|
|
|
|
|
if (do_ubl_mesh_map) ubl.display_map(map_type); // show user where we're probing
|
|
|
|
|
|
|
|
|
|
if (code_seen('B')) {LCD_MESSAGEPGM("Place shim & measure");}
|
|
|
|
|
else {LCD_MESSAGEPGM("Measure");}
|
|
|
|
|
if (code_seen('B'))
|
|
|
|
|
LCD_MESSAGEPGM("Place shim & measure"); // TODO: Make translatable string
|
|
|
|
|
else
|
|
|
|
|
LCD_MESSAGEPGM("Measure"); // TODO: Make translatable string
|
|
|
|
|
|
|
|
|
|
while (ubl_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
|
|
|
|
delay(50); // debounce
|
|
|
|
@ -1017,21 +1033,10 @@
|
|
|
|
|
do_blocking_move_to_xy(lx, ly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void say_ubl_name() {
|
|
|
|
|
SERIAL_PROTOCOLPGM("Unified Bed Leveling ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void report_ubl_state() {
|
|
|
|
|
say_ubl_name();
|
|
|
|
|
SERIAL_PROTOCOLPGM("System ");
|
|
|
|
|
if (!ubl.state.active) SERIAL_PROTOCOLPGM("de");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("activated.\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool g29_parameter_parsing() {
|
|
|
|
|
bool err_flag = false;
|
|
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Doing G29 UBL!");
|
|
|
|
|
LCD_MESSAGEPGM("Doing G29 UBL!"); // TODO: Make translatable string
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
|
|
|
|
|
ubl_constant = 0.0;
|
|
|
|
@ -1096,12 +1101,12 @@
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Can't activate and deactivate at the same time.\n");
|
|
|
|
|
return UBL_ERR;
|
|
|
|
|
}
|
|
|
|
|
ubl.state.active = 1;
|
|
|
|
|
report_ubl_state();
|
|
|
|
|
ubl.state.active = true;
|
|
|
|
|
ubl.report_state();
|
|
|
|
|
}
|
|
|
|
|
else if (code_seen('D')) {
|
|
|
|
|
ubl.state.active = 0;
|
|
|
|
|
report_ubl_state();
|
|
|
|
|
ubl.state.active = false;
|
|
|
|
|
ubl.report_state();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set global 'C' flag and its value
|
|
|
|
@ -1134,7 +1139,7 @@
|
|
|
|
|
ubl_state_recursion_chk++;
|
|
|
|
|
if (ubl_state_recursion_chk != 1) {
|
|
|
|
|
SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
|
|
|
|
|
LCD_MESSAGEPGM("save_UBL_active() error");
|
|
|
|
|
LCD_MESSAGEPGM("save_UBL_active() error"); // TODO: Make translatable string
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -1145,7 +1150,7 @@
|
|
|
|
|
void unified_bed_leveling::restore_ubl_active_state_and_leave() {
|
|
|
|
|
if (--ubl_state_recursion_chk) {
|
|
|
|
|
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
|
|
|
|
|
LCD_MESSAGEPGM("restore_UBL_active() error");
|
|
|
|
|
LCD_MESSAGEPGM("restore_UBL_active() error"); // TODO: Make translatable string
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -1157,21 +1162,12 @@
|
|
|
|
|
* good to have the extra information. Soon... we prune this to just a few items
|
|
|
|
|
*/
|
|
|
|
|
void unified_bed_leveling::g29_what_command() {
|
|
|
|
|
const uint16_t k = E2END - ubl.eeprom_start;
|
|
|
|
|
|
|
|
|
|
say_ubl_name();
|
|
|
|
|
SERIAL_PROTOCOLPGM("System Version " UBL_VERSION " ");
|
|
|
|
|
if (state.active)
|
|
|
|
|
SERIAL_PROTOCOLCHAR('A');
|
|
|
|
|
else
|
|
|
|
|
SERIAL_PROTOCOLPGM("Ina");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("ctive.\n");
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
report_state();
|
|
|
|
|
|
|
|
|
|
if (state.eeprom_storage_slot == -1)
|
|
|
|
|
if (state.storage_slot == -1)
|
|
|
|
|
SERIAL_PROTOCOLPGM("No Mesh Loaded.");
|
|
|
|
|
else {
|
|
|
|
|
SERIAL_PROTOCOLPAIR("Mesh ", state.eeprom_storage_slot);
|
|
|
|
|
SERIAL_PROTOCOLPAIR("Mesh ", state.storage_slot);
|
|
|
|
|
SERIAL_PROTOCOLPGM(" Loaded.");
|
|
|
|
|
}
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
@ -1188,12 +1184,15 @@
|
|
|
|
|
SERIAL_PROTOCOL_F(zprobe_zoffset, 7);
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("ubl.eeprom_start=", hex_address((void*)eeprom_start));
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPAIR("UBL_MESH_MIN_X " STRINGIFY(UBL_MESH_MIN_X) "=", UBL_MESH_MIN_X);
|
|
|
|
|
SERIAL_ECHOLNPAIR("UBL_MESH_MIN_Y " STRINGIFY(UBL_MESH_MIN_Y) "=", UBL_MESH_MIN_Y);
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
SERIAL_ECHOLNPAIR("UBL_MESH_MAX_X " STRINGIFY(UBL_MESH_MAX_X) "=", UBL_MESH_MAX_X);
|
|
|
|
|
SERIAL_ECHOLNPAIR("UBL_MESH_MAX_Y " STRINGIFY(UBL_MESH_MAX_Y) "=", UBL_MESH_MAX_Y);
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
SERIAL_ECHOLNPAIR("GRID_MAX_POINTS_X ", GRID_MAX_POINTS_X);
|
|
|
|
|
SERIAL_ECHOLNPAIR("GRID_MAX_POINTS_Y ", GRID_MAX_POINTS_Y);
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPAIR("MESH_X_DIST ", MESH_X_DIST);
|
|
|
|
|
SERIAL_ECHOLNPAIR("MESH_Y_DIST ", MESH_Y_DIST);
|
|
|
|
|
safe_delay(25);
|
|
|
|
@ -1214,42 +1213,38 @@
|
|
|
|
|
}
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("Free EEPROM space starts at: ", hex_address((void*)eeprom_start));
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("end of EEPROM: ", hex_address((void*)E2END));
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
#if HAS_KILL
|
|
|
|
|
SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR(" state:", READ(KILL_PIN));
|
|
|
|
|
#endif
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPAIR("sizeof(ubl.state) : ", (int)sizeof(state));
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)k));
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPAIR("EEPROM can hold ", k / sizeof(z_values));
|
|
|
|
|
SERIAL_PROTOCOLLNPGM(" meshes.\n");
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPAIR("\nGRID_MAX_POINTS_X ", GRID_MAX_POINTS_X);
|
|
|
|
|
SERIAL_PROTOCOLPAIR("\nGRID_MAX_POINTS_Y ", GRID_MAX_POINTS_Y);
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
|
|
|
|
|
SERIAL_EOL;
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("UBL_MESH_MIN_X " STRINGIFY(UBL_MESH_MIN_X));
|
|
|
|
|
SERIAL_ECHOLNPAIR("=", UBL_MESH_MIN_X );
|
|
|
|
|
SERIAL_ECHOPGM("UBL_MESH_MIN_Y " STRINGIFY(UBL_MESH_MIN_Y));
|
|
|
|
|
SERIAL_ECHOLNPAIR("=", UBL_MESH_MIN_Y );
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("UBL_MESH_MAX_X " STRINGIFY(UBL_MESH_MAX_X));
|
|
|
|
|
SERIAL_ECHOLNPAIR("=", UBL_MESH_MAX_X);
|
|
|
|
|
SERIAL_ECHOPGM("UBL_MESH_MAX_Y " STRINGIFY(UBL_MESH_MAX_Y));
|
|
|
|
|
SERIAL_ECHOLNPAIR("=", UBL_MESH_MAX_Y);
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
|
|
|
|
|
SERIAL_PROTOCOLLNPGM(" meshes.\n");
|
|
|
|
|
safe_delay(25);
|
|
|
|
|
|
|
|
|
|
if (!sanity_check()) {
|
|
|
|
|
say_ubl_name();
|
|
|
|
|
echo_name();
|
|
|
|
|
SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1284,27 +1279,32 @@
|
|
|
|
|
* use cases for the users. So we can wait and see what to do with it.
|
|
|
|
|
*/
|
|
|
|
|
void g29_compare_current_mesh_to_stored_mesh() {
|
|
|
|
|
float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
|
|
|
|
int16_t a = settings.calc_num_meshes();
|
|
|
|
|
|
|
|
|
|
if (!a) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!code_has_value()) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Mesh # required.\n");
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Storage slot # required.");
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
storage_slot = code_value_int();
|
|
|
|
|
|
|
|
|
|
int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(tmp_z_values);
|
|
|
|
|
storage_slot = code_value_int();
|
|
|
|
|
|
|
|
|
|
if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
|
|
|
|
if (!WITHIN(storage_slot, 0, a - 1)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
j = UBL_LAST_EEPROM_INDEX - (storage_slot + 1) * sizeof(tmp_z_values);
|
|
|
|
|
eeprom_read_block((void *)&tmp_z_values, (void *)j, sizeof(tmp_z_values));
|
|
|
|
|
float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
|
|
|
|
settings.load_mesh(storage_slot, &tmp_z_values);
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOPAIR("Subtracting Mesh ", storage_slot);
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR(" loaded from EEPROM address ", hex_address((void*)j)); // Soon, we can remove the extra clutter of printing
|
|
|
|
|
// the address in the EEPROM where the Mesh is stored.
|
|
|
|
|
SERIAL_PROTOCOLPAIR("Subtracting mesh in slot ", storage_slot);
|
|
|
|
|
SERIAL_PROTOCOLLNPGM(" from current mesh.");
|
|
|
|
|
|
|
|
|
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
|
|
|
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
|
|
@ -1396,7 +1396,7 @@
|
|
|
|
|
|
|
|
|
|
memset(not_done, 0xFF, sizeof(not_done));
|
|
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Fine Tuning Mesh");
|
|
|
|
|
LCD_MESSAGEPGM("Fine Tuning Mesh"); // TODO: Make translatable string
|
|
|
|
|
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
|
|
|
|
do_blocking_move_to_xy(lx, ly);
|
|
|
|
@ -1454,7 +1454,7 @@
|
|
|
|
|
lcd_return_to_status();
|
|
|
|
|
//SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped.");
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
|
|
|
|
LCD_MESSAGEPGM("Mesh Editing Stopped");
|
|
|
|
|
LCD_MESSAGEPGM("Mesh Editing Stopped"); // TODO: Make translatable string
|
|
|
|
|
|
|
|
|
|
while (ubl_lcd_clicked()) idle();
|
|
|
|
|
|
|
|
|
@ -1481,7 +1481,7 @@
|
|
|
|
|
|
|
|
|
|
do_blocking_move_to_xy(lx, ly);
|
|
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Done Editing Mesh");
|
|
|
|
|
LCD_MESSAGEPGM("Done Editing Mesh"); // TODO: Make translatable string
|
|
|
|
|
SERIAL_ECHOLNPGM("Done Editing Mesh");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|