Standardize LCD interface code for UBL a little
This commit is contained in:
parent
7b6ad28a5d
commit
ff26b7446c
@ -181,9 +181,8 @@
|
|||||||
// If the button is suddenly pressed again,
|
// If the button is suddenly pressed again,
|
||||||
// ask the user to resolve the issue
|
// ask the user to resolve the issue
|
||||||
lcd_setstatusPGM(PSTR("Release button"), 99); // will never appear...
|
lcd_setstatusPGM(PSTR("Release button"), 99); // will never appear...
|
||||||
while (is_lcd_clicked()) idle(); // unless this loop happens
|
wait_for_release();
|
||||||
lcd_reset_status();
|
lcd_reset_status();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -191,7 +190,7 @@
|
|||||||
#if ENABLED(NEWPANEL)
|
#if ENABLED(NEWPANEL)
|
||||||
bool exit_from_g26() {
|
bool exit_from_g26() {
|
||||||
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
|
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
|
||||||
while (is_lcd_clicked()) idle();
|
wait_for_release();
|
||||||
return G26_ERR;
|
return G26_ERR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -291,7 +290,7 @@
|
|||||||
idle();
|
idle();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (is_lcd_clicked()) idle(); // Debounce Encoder Wheel
|
wait_for_release();
|
||||||
|
|
||||||
#if ENABLED(ULTRA_LCD)
|
#if ENABLED(ULTRA_LCD)
|
||||||
strcpy_P(lcd_status_message, PSTR("Done Priming")); // We can't do lcd_setstatusPGM() without having it continue;
|
strcpy_P(lcd_status_message, PSTR("Done Priming")); // We can't do lcd_setstatusPGM() without having it continue;
|
||||||
|
12
Marlin/ubl.h
12
Marlin/ubl.h
@ -81,19 +81,23 @@
|
|||||||
static int g29_grid_size;
|
static int g29_grid_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static float measure_point_with_encoder();
|
#if ENABLED(NEWPANEL)
|
||||||
static float measure_business_card_thickness(float);
|
static void move_z_with_encoder(const float &multiplier);
|
||||||
|
static float measure_point_with_encoder();
|
||||||
|
static float measure_business_card_thickness(float);
|
||||||
|
static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
|
||||||
|
static void fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map);
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool g29_parameter_parsing();
|
static bool g29_parameter_parsing();
|
||||||
static void find_mean_mesh_height();
|
static void find_mean_mesh_height();
|
||||||
static void shift_mesh_height();
|
static void shift_mesh_height();
|
||||||
static void probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
|
static void probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
|
||||||
static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
|
|
||||||
static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
|
static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
|
||||||
static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
|
static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
|
||||||
static void g29_what_command();
|
static void g29_what_command();
|
||||||
static void g29_eeprom_dump();
|
static void g29_eeprom_dump();
|
||||||
static void g29_compare_current_mesh_to_stored_mesh();
|
static void g29_compare_current_mesh_to_stored_mesh();
|
||||||
static void fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map);
|
|
||||||
static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
|
static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
|
||||||
static void smart_fill_mesh();
|
static void smart_fill_mesh();
|
||||||
|
|
||||||
|
@ -730,6 +730,30 @@
|
|||||||
z_values[x][y] += g29_constant;
|
z_values[x][y] += g29_constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLED(NEWPANEL)
|
||||||
|
|
||||||
|
typedef void (*clickFunc_t)();
|
||||||
|
|
||||||
|
bool click_and_hold(const clickFunc_t func=NULL) {
|
||||||
|
if (is_lcd_clicked()) {
|
||||||
|
lcd_quick_feedback();
|
||||||
|
const millis_t nxt = millis() + 1500UL;
|
||||||
|
while (is_lcd_clicked()) { // Loop while the encoder is pressed. Uses hardware flag!
|
||||||
|
idle(); // idle, of course
|
||||||
|
if (ELAPSED(millis(), nxt)) { // After 1.5 seconds
|
||||||
|
lcd_quick_feedback();
|
||||||
|
if (func) (*func)();
|
||||||
|
wait_for_release();
|
||||||
|
safe_delay(50); // Debounce the Encoder wheel
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NEWPANEL
|
||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
/**
|
/**
|
||||||
* Probe all invalidated locations of the mesh that can be reached by the probe.
|
* Probe all invalidated locations of the mesh that can be reached by the probe.
|
||||||
@ -755,10 +779,9 @@
|
|||||||
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
|
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
|
||||||
lcd_quick_feedback();
|
lcd_quick_feedback();
|
||||||
STOW_PROBE();
|
STOW_PROBE();
|
||||||
while (is_lcd_clicked()) idle();
|
wait_for_release();
|
||||||
lcd_external_control = false;
|
lcd_external_control = false;
|
||||||
restore_ubl_active_state_and_leave();
|
restore_ubl_active_state_and_leave();
|
||||||
safe_delay(50); // Debounce the Encoder wheel
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -895,19 +918,20 @@
|
|||||||
|
|
||||||
#if ENABLED(NEWPANEL)
|
#if ENABLED(NEWPANEL)
|
||||||
|
|
||||||
float unified_bed_leveling::measure_point_with_encoder() {
|
void unified_bed_leveling::move_z_with_encoder(const float &multiplier) {
|
||||||
|
wait_for_release();
|
||||||
while (is_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
while (!is_lcd_clicked()) {
|
||||||
delay(50); // debounce
|
|
||||||
|
|
||||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
||||||
while (!is_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
|
||||||
idle();
|
idle();
|
||||||
if (encoder_diff) {
|
if (encoder_diff) {
|
||||||
do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(encoder_diff));
|
do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * multiplier);
|
||||||
encoder_diff = 0;
|
encoder_diff = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float unified_bed_leveling::measure_point_with_encoder() {
|
||||||
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||||
|
move_z_with_encoder(0.01);
|
||||||
KEEPALIVE_STATE(IN_HANDLER);
|
KEEPALIVE_STATE(IN_HANDLER);
|
||||||
return current_position[Z_AXIS];
|
return current_position[Z_AXIS];
|
||||||
}
|
}
|
||||||
@ -956,6 +980,14 @@
|
|||||||
return thickness;
|
return thickness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void abort_manual_probe_remaining_mesh() {
|
||||||
|
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
||||||
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
||||||
|
lcd_external_control = false;
|
||||||
|
KEEPALIVE_STATE(IN_HANDLER);
|
||||||
|
ubl.restore_ubl_active_state_and_leave();
|
||||||
|
}
|
||||||
|
|
||||||
void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
|
void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
|
||||||
|
|
||||||
lcd_external_control = true;
|
lcd_external_control = true;
|
||||||
@ -991,36 +1023,15 @@
|
|||||||
const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step
|
const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step
|
||||||
//const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS]; // approx one step each click
|
//const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS]; // approx one step each click
|
||||||
|
|
||||||
while (is_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
move_z_with_encoder(z_step);
|
||||||
delay(50); // debounce
|
|
||||||
while (!is_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
|
||||||
idle();
|
|
||||||
if (encoder_diff) {
|
|
||||||
do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * z_step);
|
|
||||||
encoder_diff = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
if (click_and_hold()) {
|
||||||
// a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
||||||
// should be redone and compressed.
|
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
||||||
const millis_t nxt = millis() + 1500L;
|
lcd_external_control = false;
|
||||||
while (is_lcd_clicked()) { // debounce and watch for abort
|
KEEPALIVE_STATE(IN_HANDLER);
|
||||||
idle();
|
restore_ubl_active_state_and_leave();
|
||||||
if (ELAPSED(millis(), nxt)) {
|
return;
|
||||||
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
|
||||||
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
|
||||||
|
|
||||||
#if ENABLED(NEWPANEL)
|
|
||||||
lcd_quick_feedback();
|
|
||||||
while (is_lcd_clicked()) idle();
|
|
||||||
lcd_external_control = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
KEEPALIVE_STATE(IN_HANDLER);
|
|
||||||
restore_ubl_active_state_and_leave();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
|
z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
|
||||||
@ -1177,16 +1188,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
void unified_bed_leveling::restore_ubl_active_state_and_leave() {
|
void unified_bed_leveling::restore_ubl_active_state_and_leave() {
|
||||||
if (--ubl_state_recursion_chk) {
|
#ifdef UBL_DEVEL_DEBUGGING
|
||||||
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
|
if (--ubl_state_recursion_chk) {
|
||||||
|
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
|
||||||
#if ENABLED(NEWPANEL)
|
#if ENABLED(NEWPANEL)
|
||||||
LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
|
LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
|
||||||
lcd_quick_feedback();
|
lcd_quick_feedback();
|
||||||
#endif
|
#endif
|
||||||
|
return;
|
||||||
return;
|
}
|
||||||
}
|
#endif
|
||||||
set_bed_leveling_enabled(ubl_state_at_invocation);
|
set_bed_leveling_enabled(ubl_state_at_invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1468,6 +1479,12 @@
|
|||||||
|
|
||||||
#if ENABLED(NEWPANEL)
|
#if ENABLED(NEWPANEL)
|
||||||
|
|
||||||
|
void abort_fine_tune() {
|
||||||
|
lcd_return_to_status();
|
||||||
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
||||||
|
LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
|
||||||
|
}
|
||||||
|
|
||||||
void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
|
void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
|
||||||
if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
|
if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
|
||||||
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
|
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
|
||||||
@ -1543,19 +1560,8 @@
|
|||||||
// this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
// this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
||||||
// a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
// a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
||||||
// should be redone and compressed.
|
// should be redone and compressed.
|
||||||
const millis_t nxt = millis() + 1500UL;
|
if (click_and_hold(abort_fine_tune))
|
||||||
while (is_lcd_clicked()) { // debounce and watch for abort
|
goto FINE_TUNE_EXIT;
|
||||||
idle();
|
|
||||||
if (ELAPSED(millis(), nxt)) {
|
|
||||||
lcd_return_to_status();
|
|
||||||
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
|
||||||
LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
|
|
||||||
|
|
||||||
while (is_lcd_clicked()) idle();
|
|
||||||
|
|
||||||
goto FINE_TUNE_EXIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delay(20); // We don't want any switch noise.
|
safe_delay(20); // We don't want any switch noise.
|
||||||
|
|
||||||
|
@ -5112,6 +5112,10 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
|||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
||||||
bool is_lcd_clicked() { return LCD_CLICKED; }
|
bool is_lcd_clicked() { return LCD_CLICKED; }
|
||||||
|
void wait_for_release() {
|
||||||
|
while (is_lcd_clicked()) safe_delay(50);
|
||||||
|
safe_delay(50);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // ULTIPANEL
|
#endif // ULTIPANEL
|
||||||
|
@ -176,6 +176,7 @@
|
|||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
||||||
bool is_lcd_clicked();
|
bool is_lcd_clicked();
|
||||||
|
void wait_for_release();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD))
|
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD))
|
||||||
|
Loading…
Reference in New Issue
Block a user