UBL name/state methods

master
Scott Lahteine 7 years ago
parent 7852369987
commit 7f4e4b1212

@ -3940,7 +3940,7 @@ void home_all_axes() { gcode_G28(true); }
#if ENABLED(MESH_BED_LEVELING)
// Save 130 bytes with non-duplication of PSTR
void say_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
void mbl_mesh_report() {
SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
@ -4071,7 +4071,7 @@ void home_all_axes() { gcode_G28(true); }
}
}
else {
SERIAL_CHAR('X'); say_not_entered();
SERIAL_CHAR('X'); echo_not_entered();
return;
}
@ -4083,7 +4083,7 @@ void home_all_axes() { gcode_G28(true); }
}
}
else {
SERIAL_CHAR('Y'); say_not_entered();
SERIAL_CHAR('Y'); echo_not_entered();
return;
}
@ -4091,7 +4091,7 @@ void home_all_axes() { gcode_G28(true); }
mbl.z_values[px][py] = code_value_linear_units();
}
else {
SERIAL_CHAR('Z'); say_not_entered();
SERIAL_CHAR('Z'); echo_not_entered();
return;
}
break;
@ -4101,7 +4101,7 @@ void home_all_axes() { gcode_G28(true); }
mbl.z_offset = code_value_linear_units();
}
else {
SERIAL_CHAR('Z'); say_not_entered();
SERIAL_CHAR('Z'); echo_not_entered();
return;
}
break;

@ -425,7 +425,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(ubl.state.z_offset);
EEPROM_WRITE(ubl.state.storage_slot);
#else
const bool ubl_active = 0;
const bool ubl_active = false;
dummy = 0.0f;
const int8_t storage_slot = -1;
EEPROM_WRITE(ubl_active);
@ -991,18 +991,20 @@ void MarlinSettings::postprocess() {
}
#if ENABLED(AUTO_BED_LEVELING_UBL)
meshes_begin = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it
// can float up or down a little bit without
// disrupting the mesh data
SERIAL_ECHOPGM(" UBL ");
if (!ubl.state.active) SERIAL_ECHO("not ");
SERIAL_ECHOLNPGM("active!");
meshes_begin = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it
// can float up or down a little bit without
// disrupting the mesh data
ubl.report_state();
if (!ubl.sanity_check()) {
SERIAL_ECHOLNPGM("\nUnified Bed Leveling system initialized.\n");
SERIAL_EOL;
ubl.echo_name();
SERIAL_ECHOLNPGM(" initialized.\n");
}
else {
SERIAL_PROTOCOLPGM("?Unable to enable Unified Bed Leveling system.\n");
SERIAL_PROTOCOLPGM("?Can't enable ");
ubl.echo_name();
SERIAL_PROTOCOLLNPGM(".");
ubl.reset();
}
@ -1028,6 +1030,12 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
void ubl_invalid_slot(const int s) {
SERIAL_PROTOCOLLNPGM("?Invalid slot.");
SERIAL_PROTOCOL(s);
SERIAL_PROTOCOLLNPGM(" mesh slots available.");
}
int MarlinSettings::calc_num_meshes() {
//obviously this will get more sophisticated once we've added an actual MAT
@ -1041,12 +1049,10 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
const int a = calc_num_meshes();
if (!WITHIN(slot, 0, a - 1)) {
SERIAL_PROTOCOLLNPGM("?Invalid slot.");
SERIAL_PROTOCOL(a);
SERIAL_PROTOCOLLNPGM(" mesh slots available.");
SERIAL_PROTOCOLLNPAIR("E2END : ", E2END);
SERIAL_PROTOCOLLNPAIR("meshes_end : ", (int)meshes_end);
SERIAL_PROTOCOLLNPAIR("slot : ", slot);
ubl_invalid_slot(a);
SERIAL_PROTOCOLPAIR("E2END=", E2END);
SERIAL_PROTOCOLPAIR(" meshes_end=", (int)meshes_end);
SERIAL_PROTOCOLLNPAIR(" slot=", slot);
SERIAL_EOL;
return;
}
@ -1074,9 +1080,7 @@ void MarlinSettings::postprocess() {
const int16_t a = settings.calc_num_meshes();
if (!WITHIN(slot, 0, a - 1)) {
SERIAL_PROTOCOLLNPGM("?Invalid Slot.");
SERIAL_PROTOCOL(a);
SERIAL_PROTOCOLLNPGM(" mesh slots available.");
ubl_invalid_slot(a);
return;
}
@ -1538,7 +1542,8 @@ void MarlinSettings::reset() {
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM("Unified Bed Leveling:");
ubl.echo_name();
SERIAL_ECHOLNPGM(":");
}
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M420 S", ubl.state.active ? 1 : 0);
@ -1548,9 +1553,10 @@ void MarlinSettings::reset() {
SERIAL_EOL;
if (!forReplay) {
SERIAL_ECHOPGM("\nUBL is ");
ubl.state.active ? SERIAL_CHAR('A') : SERIAL_ECHOPGM("Ina");
SERIAL_ECHOLNPAIR("ctive\n\nActive Mesh Slot: ", ubl.state.storage_slot);
SERIAL_EOL;
ubl.report_state();
SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
SERIAL_ECHOPGM("z_offset: ");
SERIAL_ECHO_F(ubl.state.z_offset, 6);

@ -41,6 +41,16 @@
uint8_t ubl_cnt = 0;
void unified_bed_leveling::echo_name() { SERIAL_PROTOCOLPGM("Unified Bed Leveling"); }
void unified_bed_leveling::report_state() {
echo_name();
SERIAL_PROTOCOLPGM(" System v" UBL_VERSION " ");
if (!state.active) SERIAL_PROTOCOLPGM("in");
SERIAL_PROTOCOLLNPGM("active.");
safe_delay(50);
}
static void serial_echo_xy(const int16_t x, const int16_t y) {
SERIAL_CHAR('(');
SERIAL_ECHO(x);

@ -103,6 +103,8 @@
public:
void echo_name();
void report_state();
void find_mean_mesh_height();
void shift_mesh_height();
void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);

@ -906,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.");
}
@ -922,15 +922,15 @@
SERIAL_PROTOCOLPGM("Place shim under nozzle");
LCD_MESSAGEPGM("Place shim & measure");
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();
@ -1031,17 +1031,6 @@
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;
@ -1110,12 +1099,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
@ -1171,14 +1160,7 @@
* good to have the extra information. Soon... we prune this to just a few items
*/
void unified_bed_leveling::g29_what_command() {
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.storage_slot == -1)
SERIAL_PROTOCOLPGM("No Mesh Loaded.");
@ -1260,8 +1242,8 @@
safe_delay(25);
if (!sanity_check()) {
say_ubl_name();
SERIAL_PROTOCOLLNPGM("sanity checks passed.");
echo_name();
SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
}
}
@ -1319,7 +1301,8 @@
float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
settings.load_mesh(storage_slot, &tmp_z_values);
SERIAL_ECHOPAIR("Subtracting current mesh from mesh loaded from slot ", storage_slot);
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++)

Loading…
Cancel
Save