From 73794b56cf532cb4193a6c80082652351509677a Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Fri, 2 Nov 2018 23:03:14 +0100 Subject: [PATCH] MeshBed Leveling Fail Z-leveling after MeshBed leveling failing --- Firmware/Marlin_main.cpp | 23 +++++++++++++++++++++-- Firmware/sound.cpp | 21 +++++++++++++++++++++ Firmware/ultralcd.cpp | 18 +++++++++++++++--- Firmware/ultralcd.h | 1 + 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index da18ee3d..44c75fb0 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -332,6 +332,9 @@ bool wizard_active = false; //autoload temporarily disabled during wizard //=========================================================================== //=============================Private Variables============================= //=========================================================================== +#define MSG_BED_LEVELING_FAILED "Some problem encountered, Z-leveling enforced ..." +#define MSG_BED_LEVELING_FAILED_TIMEOUT 30 + const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0}; @@ -4491,8 +4494,24 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder); st_synchronize(); if (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) { - kill(kill_message); - SERIAL_ECHOLNPGM("killed"); + Sound_MakeSound(e_SOUND_TYPE_StandardAlert); + lcd_display_message_fullscreen_P(_i(MSG_BED_LEVELING_FAILED)); + lcd_wait_for_click_delay(MSG_BED_LEVELING_FAILED_TIMEOUT); +#ifdef TMC2130 + calibrate_z_auto(); // Z-leveling (X-assembly stay up!!!) +#else // TMC2130 + lcd_calibrate_z_end_stop_manual(true); // Z-leveling (X-assembly stay up!!!) +#endif // TMC2130 + // ~ Z-homing (can not be used "G28", because X & Y-homing would have been done before (Z-homing)) + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder); + st_synchronize(); + // + custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery + lcd_update_enable(true); // display / status-line recovery + gcode_G28(true, true, false); // X & Y-homing (must be after Z-homing (problem with spool-holder)!) + repeatcommand_front(); // re-run (i.e. of "G80") + break; } clean_up_after_endstop_move(l_feedmultiply); // SERIAL_ECHOLNPGM("clean up finished "); diff --git a/Firmware/sound.cpp b/Firmware/sound.cpp index 6e41d252..ba6ea726 100644 --- a/Firmware/sound.cpp +++ b/Firmware/sound.cpp @@ -16,6 +16,7 @@ eSOUND_MODE eSoundMode; //=e_SOUND_MODE_DEFAULT; static void Sound_SaveMode(void); static void Sound_DoSound_Echo(void); static void Sound_DoSound_Prompt(void); +static void Sound_DoSound_Alert(bool bOnce); void Sound_Init(void) @@ -68,14 +69,20 @@ switch(eSoundMode) Sound_DoSound_Echo(); if(eSoundType==e_SOUND_TYPE_StandardPrompt) Sound_DoSound_Prompt(); + if(eSoundType==e_SOUND_TYPE_StandardAlert) + Sound_DoSound_Alert(false); break; case e_SOUND_MODE_ONCE: if(eSoundType==e_SOUND_TYPE_ButtonEcho) Sound_DoSound_Echo(); if(eSoundType==e_SOUND_TYPE_StandardPrompt) Sound_DoSound_Prompt(); + if(eSoundType==e_SOUND_TYPE_StandardAlert) + Sound_DoSound_Alert(true); break; case e_SOUND_MODE_SILENT: + if(eSoundType==e_SOUND_TYPE_StandardAlert) + Sound_DoSound_Alert(true); break; case e_SOUND_MODE_MUTE: break; @@ -104,3 +111,17 @@ WRITE(BEEPER,HIGH); delay_keep_alive(500); WRITE(BEEPER,LOW); } + +static void Sound_DoSound_Alert(bool bOnce) +{ +uint8_t nI,nMax; + +nMax=bOnce?1:3; +for(nI=0;nI nDelay); + bDelayed = (bDelayed && (nDelay != 0)); // 0 ~ no timeout, always waiting for click + if (lcd_clicked() || bDelayed) { KEEPALIVE_STATE(IN_HANDLER); - return; + return(!bDelayed); } } } +void lcd_wait_for_click() +{ +lcd_wait_for_click_delay(0); +} + //! @brief Show multiple screen message with yes and no possible choices and wait with possible timeout //! @param msg Message to show //! @param allow_timeouting if true, allows time outing of the screen diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index d2d4d0a2..aeb29c28 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -49,6 +49,7 @@ extern const char* lcd_display_message_fullscreen_P(const char *msg); extern void lcd_return_to_status(); extern void lcd_wait_for_click(); +extern bool lcd_wait_for_click_delay(uint16_t nDelay); extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); // 0: no, 1: yes, -1: timeouted extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);