UBL name/state methods

This commit is contained in:
Scott Lahteine 2017-05-16 02:34:36 -05:00
parent 7852369987
commit 7f4e4b1212
5 changed files with 58 additions and 57 deletions

View File

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

View File

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

View File

@ -41,6 +41,16 @@
uint8_t ubl_cnt = 0; 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) { static void serial_echo_xy(const int16_t x, const int16_t y) {
SERIAL_CHAR('('); SERIAL_CHAR('(');
SERIAL_ECHO(x); SERIAL_ECHO(x);

View File

@ -103,6 +103,8 @@
public: public:
void echo_name();
void report_state();
void find_mean_mesh_height(); void find_mean_mesh_height();
void shift_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); void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);

View File

@ -906,7 +906,7 @@
return current_position[Z_AXIS]; 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."); SERIAL_PROTOCOLLNPGM(" and take a measurement.");
} }
@ -922,15 +922,15 @@
SERIAL_PROTOCOLPGM("Place shim under nozzle"); SERIAL_PROTOCOLPGM("Place shim under nozzle");
LCD_MESSAGEPGM("Place shim & measure"); LCD_MESSAGEPGM("Place shim & measure");
lcd_goto_screen(lcd_status_screen); 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(); const float z1 = use_encoder_wheel_to_measure_point();
do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE); do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
stepper.synchronize(); stepper.synchronize();
SERIAL_PROTOCOLPGM("Remove shim"); SERIAL_PROTOCOLPGM("Remove shim");
LCD_MESSAGEPGM("Remove & measure bed"); LCD_MESSAGEPGM("Remove & measure bed"); // TODO: Make translatable string
say_and_take_a_measurement(); echo_and_take_a_measurement();
const float z2 = use_encoder_wheel_to_measure_point(); const float z2 = use_encoder_wheel_to_measure_point();
@ -1031,17 +1031,6 @@
do_blocking_move_to_xy(lx, ly); 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 g29_parameter_parsing() {
bool err_flag = false; bool err_flag = false;
@ -1110,12 +1099,12 @@
SERIAL_PROTOCOLLNPGM("?Can't activate and deactivate at the same time.\n"); SERIAL_PROTOCOLLNPGM("?Can't activate and deactivate at the same time.\n");
return UBL_ERR; return UBL_ERR;
} }
ubl.state.active = 1; ubl.state.active = true;
report_ubl_state(); ubl.report_state();
} }
else if (code_seen('D')) { else if (code_seen('D')) {
ubl.state.active = 0; ubl.state.active = false;
report_ubl_state(); ubl.report_state();
} }
// Set global 'C' flag and its value // 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 * good to have the extra information. Soon... we prune this to just a few items
*/ */
void unified_bed_leveling::g29_what_command() { void unified_bed_leveling::g29_what_command() {
say_ubl_name(); report_state();
SERIAL_PROTOCOLPGM("System Version " UBL_VERSION " ");
if (state.active)
SERIAL_PROTOCOLCHAR('A');
else
SERIAL_PROTOCOLPGM("Ina");
SERIAL_PROTOCOLLNPGM("ctive.\n");
safe_delay(50);
if (state.storage_slot == -1) if (state.storage_slot == -1)
SERIAL_PROTOCOLPGM("No Mesh Loaded."); SERIAL_PROTOCOLPGM("No Mesh Loaded.");
@ -1260,8 +1242,8 @@
safe_delay(25); safe_delay(25);
if (!sanity_check()) { if (!sanity_check()) {
say_ubl_name(); echo_name();
SERIAL_PROTOCOLLNPGM("sanity checks passed."); SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
} }
} }
@ -1319,7 +1301,8 @@
float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
settings.load_mesh(storage_slot, &tmp_z_values); 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 x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)