diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 49b6737289..aeaf198a23 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1486,8 +1486,8 @@ // Manually set the home position. Leave these undefined for automatic settings. // For DELTA this is the top-center of the Cartesian print volume. -#define MANUAL_X_HOME_POS -0.2 -#define MANUAL_Y_HOME_POS -5.7 +#define MANUAL_X_HOME_POS +0.5 +#define MANUAL_Y_HOME_POS -4.2 #define MANUAL_Z_HOME_POS -4 // Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1d3cfbbc4e..ca84c2c85d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -246,7 +246,8 @@ PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C"); PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E"); PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:"); -MarlinState marlin_state = MF_INITIALIZING; +volatile MarlinState marlin_state = MF_INITIALIZING; +volatile HomingState homing_state = NOT_HOMING; // For M109 and M190, this flag may be cleared (by M108) to exit the wait loop bool wait_for_heatup = true; @@ -477,7 +478,9 @@ void startOrResumeJob() { wait_for_heatup = false; TERN_(POWER_LOSS_RECOVERY, recovery.purge()); #ifdef EVENT_GCODE_SD_ABORT - queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT)); + if(MF_KILLED != marlin_state) { + queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT)); + } #endif TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine()); @@ -813,8 +816,11 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { * After this the machine will need to be reset. */ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { + thermalManager.disable_all_heaters(); + caselight.off(); + TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control SERIAL_ERROR_MSG(STR_ERR_KILLED); @@ -834,6 +840,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr host_action_kill(); #endif +// no freeze the machine minkill(steppers_off); } diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 908636e967..ea5333427f 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -72,7 +72,20 @@ enum MarlinState : uint8_t { MF_KILLED = _BV(7) }; -extern MarlinState marlin_state; +// Global State of homing +enum HomingState : uint8_t { + NOT_HOMING = _BV(0), + HOMING_X = _BV(1), + HOMING_Y = _BV(2), + HOMING_Z = _BV(3), + HOMING_FAILED_X = _BV(4), + HOMING_FAILED_Y = _BV(5), + HOMING_FAILED_Z = _BV(6), +}; + +extern volatile MarlinState marlin_state; +extern volatile HomingState homing_state; + inline bool IsRunning() { return marlin_state == MF_RUNNING; } inline bool IsStopped() { return marlin_state != MF_RUNNING; } diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index 0eba102a04..6d5c59def2 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -99,4 +99,9 @@ void CaseLight::update(const bool sflag) { #endif // !CASE_LIGHT_USE_NEOPIXEL } +void CaseLight::off() { + WRITE(CASE_LIGHT_PIN, LOW); +} + + #endif // CASE_LIGHT_ENABLE diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h index 2198c85f2a..7c3d9a9465 100644 --- a/Marlin/src/feature/caselight.h +++ b/Marlin/src/feature/caselight.h @@ -38,6 +38,7 @@ class CaseLight { #endif static bool on; + static void off(); static void update(const bool sflag); static inline void update_brightness() { update(false); } static inline void update_enabled() { update(true); } diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index d65fdd565b..a05f76f40f 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -280,7 +280,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/ return ; } - if(AD_DMA[2] < 2600) { + if(AD_DMA[2] < 2300) { // SERIAL_ECHOLNPAIR("v:", AD_DMA[2]); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 28ffd59edc..3c8793b16f 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -34,6 +34,8 @@ #include "../../../module/planner.h" #include "../../../module/stepper.h" #include "../../../module/probe.h" +#include "../../../module/temperature.h" + #include "../../queue.h" #if ENABLED(PROBE_TEMP_COMPENSATION) @@ -163,6 +165,8 @@ */ G29_TYPE GcodeSuite::G29() { + probe.status = 0; + reset_stepper_timeout(); const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q'); @@ -885,8 +889,23 @@ G29_TYPE GcodeSuite::G29() { #ifdef Z_PROBE_END_SCRIPT if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT); - planner.synchronize(); - process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT)); + + if(probe.status != -1) { + planner.synchronize(); + process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT)); + } else { + thermalManager.setTargetHotend(0, 0); + thermalManager.setTargetBed(0); + + thermalManager.set_fan_speed(0, 0); + thermalManager.set_fan_speed(1, 0); + + wait_for_heatup = wait_for_user = false; + + planner.clear_block_buffer(); + queue.clear(); + } + #endif #if ENABLED(DWIN_CREALITY_LCD) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 2de029a08b..5d38cc67b9 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -206,6 +206,9 @@ * Z Home to the Z endstop */ void GcodeSuite::G28() { + + homing_state = NOT_HOMING; + DEBUG_SECTION(log_G28, "G28", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) log_machine_info(); @@ -367,14 +370,27 @@ void GcodeSuite::G28() { #else + homing_state = HOMING_X; homeaxis(X_AXIS); + if(HOMING_FAILED_X == homing_state) { + return ; + } #endif } // Home Y (after X) - if (DISABLED(HOME_Y_BEFORE_X) && doY) - homeaxis(Y_AXIS); + if (DISABLED(HOME_Y_BEFORE_X) && doY) { + if(HOMING_FAILED_X != homing_state) { + homing_state = HOMING_Y; + homeaxis(Y_AXIS); + if(HOMING_FAILED_Y == homing_state) { + return ; + } + } else { + return ; + } + } TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing)); @@ -387,7 +403,20 @@ void GcodeSuite::G28() { #endif TERN_(BLTOUCH, bltouch.init()); - TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS)); +// TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS)); + #if ENABLED(Z_SAFE_HOMING) + home_z_safely(); + #else + if(HOMING_FAILED_X != homing_state && HOMING_FAILED_Y != homing_state) { + homing_state = HOMING_Z; + homeaxis(Z_AXIS); + if(HOMING_FAILED_Z == homing_state) { + return ; + } + } else { + return ; + } + #endif probe.move_z_after_homing(); } #endif diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 89bc0dc7af..998863b2e4 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -244,7 +244,6 @@ void GcodeSuite::dwell(millis_t time) { */ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { KEEPALIVE_STATE(IN_HANDLER); - /** * Block all Gcodes except M511 Unlock Printer, if printer is locked * Will still block Gcodes if M511 is disabled, in which case the printer should be unlocked via LCD Menu diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 98fe91db40..3960b30b9e 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -123,6 +123,14 @@ void GCodeQueue::clear() { index_r = index_w = length = 0; } +void GCodeQueue::clear_buf() { + index_r = index_w = length = 0; + memset(command_buffer, 0, BUFSIZE * MAX_CMD_SIZE); + memset(injected_commands, 0, 64); + injected_commands_P = nullptr; +} + + /** * Once a new command is in the ring buffer, call this to commit it */ @@ -197,7 +205,10 @@ bool GCodeQueue::process_injected_command_P() { // Execute command if non-blank if (i) { parser.parse(cmd); + SERIAL_ECHOLNPAIR("line: ", __LINE__, " func: ", __FUNCTION__); gcode.process_parsed_command(); + } else { + SERIAL_ECHOLNPAIR("line: ", __LINE__, " func: ", __FUNCTION__); } return true; } @@ -658,23 +669,29 @@ void GCodeQueue::advance() { else { // Write the string from the read buffer to SD card.write_command(command); - if (card.flag.logging) + if (card.flag.logging) { gcode.process_next_command(); // The card is saving because it's logging - else + } else { ok_to_send(); + } } } else gcode.process_next_command(); #else - gcode.process_next_command(); #endif // SDSUPPORT // The queue may be reset by a command handler or by code invoked by idle() within a handler - --length; - if (++index_r >= BUFSIZE) index_r = 0; + +// When kill called, length = index_r = index_w = 0; + if(length) { + --length; + if (++index_r >= BUFSIZE) index_r = 0; + } else { // be sure to keep index_r <= BUFSIZE + if (index_r >= BUFSIZE) index_r = 0; + } } diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 966af2871f..ecae75d0b2 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -69,6 +69,7 @@ class GCodeQueue { * Clear the Marlin command queue */ static void clear(); + static void clear_buf(); /** * Next Injected Command (PROGMEM) pointer. (nullptr == empty) diff --git a/Marlin/src/lcd/extui/anycubic_dgus_lcd.cpp b/Marlin/src/lcd/extui/anycubic_dgus_lcd.cpp index c4acf66a25..146e46a9ae 100644 --- a/Marlin/src/lcd/extui/anycubic_dgus_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_dgus_lcd.cpp @@ -64,8 +64,8 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { Dgus.ConfirmationRequest(msg); } void onStatusChanged(const char * const msg) { Dgus.StatusChange(msg); } - void onHomingStart() {} - void onHomingComplete() {} + void onHomingStart() { Dgus.HomingStart(); } + void onHomingComplete() { Dgus.HomingComplete(); } void onPrintFinished() {} void onFactoryReset() { diff --git a/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.cpp index e99d6a2bb4..c002b36c03 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.cpp @@ -115,6 +115,7 @@ namespace Anycubic { uint8_t DgusTFT::data_buf[64]; uint8_t DgusTFT::data_index; uint32_t DgusTFT::page_index_last; + uint32_t DgusTFT::page_index_last_2; uint32_t DgusTFT::page_index_now; uint8_t DgusTFT::message_index; uint8_t DgusTFT::pop_up_index; @@ -142,6 +143,7 @@ namespace Anycubic { pop_up_index = 100; page_index_now = 1; page_index_last = 1; + page_index_last_2 = 1; lcd_txtbox_index = 0; @@ -243,6 +245,30 @@ namespace Anycubic { page175_handle(); } else if(page_index_now == 176) { page176_handle(); + } else if(177 <= page_index_now && page_index_now <= 198) { +#if 0 // ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("line: ", __LINE__); + SERIAL_ECHOLNPAIR("func: ", page_index_now); +#endif +// page177_to_198_handle(); + } else if(199 == page_index_now || page_index_now == 200) { +#if 0 // ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("line: ", __LINE__); + SERIAL_ECHOLNPAIR("func: ", page_index_now); +#endif + page199_to_200_handle(); + } else if(page_index_now == 201 || page_index_now == 204) { + + page201_handle(); + + } else if(page_index_now == 202 || page_index_now == 205) { + + page202_handle(); + + } else if(page_index_now == 203 || page_index_now == 206) { + + page203_handle(); + } else { if(lcd_info.language == ExtUI::CHS) { @@ -259,10 +285,9 @@ namespace Anycubic { fun_array[page_index_now-1-120](); // ENG page_index is 120 more than CHS } else { -#if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("line: ", __LINE__); - SERIAL_ECHOLNPAIR("fun not exists: ", page_index_now); -#endif + SERIAL_ECHOLN("lcd function not exists"); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); + SERIAL_ECHOLNPAIR("page_index_last_2: ", page_index_last_2); } } @@ -283,29 +308,55 @@ namespace Anycubic { if(strncmp(error, "Heating Failed", strlen("Heating Failed")) == 0) { if(strncmp(component, "Bed", strlen("Bed")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_BED_HEATER); SERIAL_ECHOLNPAIR("Check Bed heater"); } else if(strncmp(component, "E1", strlen("E1")) == 0) { - ChangePageOfTFT(PAGE_ABNORMAL); + ChangePageOfTFT(PAGE_CHS_ABNORMAL_HOTEND_HEATER); SERIAL_ECHOLNPAIR("Check E1 heater"); } } else if(strncmp(error, "Err: MINTEMP", strlen("Err: MINTEMP")) == 0) { if(strncmp(component, "Bed", strlen("Bed")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_BED_NTC); + SERIAL_ECHOLNPAIR("Check Bed thermistor"); + } else if(strncmp(component, "E1", strlen("E1")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_HOTEND_NTC); + SERIAL_ECHOLNPAIR("Check E1 thermistor"); + } + + } else if(strncmp(error, "Err: MAXTEMP", strlen("Err: MAXTEMP")) == 0) { + + if(strncmp(component, "Bed", strlen("Bed")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_BED_NTC); SERIAL_ECHOLNPAIR("Check Bed thermistor"); } else if(strncmp(component, "E1", strlen("E1")) == 0) { - ChangePageOfTFT(PAGE_ABNORMAL); + ChangePageOfTFT(PAGE_CHS_ABNORMAL_HOTEND_NTC); SERIAL_ECHOLNPAIR("Check E1 thermistor"); } } else if(strncmp(error, "THERMAL RUNAWAY", strlen("THERMAL RUNAWAY")) == 0) { if(strncmp(component, "Bed", strlen("Bed")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_BED_HEATER); SERIAL_ECHOLNPAIR("Check Bed thermal runaway"); } else if(strncmp(component, "E1", strlen("E1")) == 0) { - ChangePageOfTFT(PAGE_ABNORMAL); + ChangePageOfTFT(PAGE_CHS_ABNORMAL_HOTEND_HEATER); SERIAL_ECHOLNPAIR("Check E1 thermal runaway"); } + + } else if(strncmp(error, "Homing Failed", strlen("Homing Failed")) == 0) { + + if (strncmp(component, "X", strlen("X")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_X_ENDSTOP); + SERIAL_ECHOLNPAIR("Check X endstop"); + } else if(strncmp(component, "Y", strlen("Y")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_Y_ENDSTOP); + SERIAL_ECHOLNPAIR("Check Y endstop"); + } else if(strncmp(component, "Z", strlen("Z")) == 0) { + ChangePageOfTFT(PAGE_CHS_ABNORMAL_Z_ENDSTOP); + SERIAL_ECHOLNPAIR("Check Z endstop"); + } } } @@ -509,7 +560,8 @@ namespace Anycubic { if(probe_cnt == GRID_MAX_POINTS_X*GRID_MAX_POINTS_Y) { probe_cnt = 0; injectCommands_P(PSTR("M500")); // G27 park nozzle - ChangePageOfTFT(PAGE_PreLEVEL); +// ChangePageOfTFT(PAGE_PreLEVEL); + FakeChangePageOfTFT(PAGE_PreLEVEL); // this avoid a overquick UI fresh when probing done printer_state = AC_printer_idle; msg_matched = true; } @@ -519,6 +571,7 @@ namespace Anycubic { if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) { PlayTune(BEEPER_PIN, BeepBeepBeeep, 1); injectCommands_P(PSTR("G1 Z50 F500")); + ChangePageOfTFT(PAGE_CHS_ABNORMAL_LEVELING_SENSOR); // SendtoTFTLN(AC_msg_probing_complete); printer_state = AC_printer_idle; msg_matched = true; @@ -619,6 +672,29 @@ namespace Anycubic { printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. } + void DgusTFT::HomingStart() { + if(!isPrintingFromMedia()) { + ChangePageOfTFT(PAGE_CHS_HOMING); + } + } + + void DgusTFT::HomingComplete() { + if(lcd_info.language == ExtUI::ENG) { + if(page_index_last > 120) { + page_index_last -= 120; + } + } + +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("HomingComplete, line: ", __LINE__); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); +#endif + + if(!isPrintingFromMedia()) { + ChangePageOfTFT(page_index_last); + } + } + void DgusTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEN string to the panel #if ACDEBUG(AC_SOME) serialprintPGM(str); @@ -654,7 +730,6 @@ namespace Anycubic { uint8_t data_buf[20] = {0}; uint8_t data_index = 0; - uint8_t data_len = 0; uint8_t *p_u8 = (uint8_t *)(&address)+1 ; @@ -748,6 +823,10 @@ namespace Anycubic { void DgusTFT::ChangePageOfTFT(uint32_t page_index) { +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("ChangePageOfTFT: ", page_index); +#endif + uint8_t data_buf[20] = {0}; uint8_t data_index = 0; uint32_t data_temp = 0; @@ -760,6 +839,10 @@ namespace Anycubic { data_temp = PAGE_ENG_OUTAGE_RECOVERY; } else if(PAGE_CHS_PROBE_PREHEATING == page_index) { data_temp = PAGE_ENG_PROBE_PREHEATING; + } else if(PAGE_CHS_HOMING <= page_index && page_index <= PAGE_ENG_HOMING) { + data_temp = page_index+12; + } else if(PAGE_CHS_PROBE_PRECHECK <= page_index && page_index <= PAGE_CHS_PROBE_PRECHECK_FAILED) { + data_temp = page_index+3; } else { data_temp = page_index+120; } @@ -783,8 +866,55 @@ namespace Anycubic { TFTSer.write(data_buf[i]); } + page_index_last_2 = page_index_last; page_index_last = page_index_now; - page_index_now = data_temp ; + page_index_now = data_temp; + +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("page_index_last_2: ", page_index_last_2); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); + SERIAL_ECHOLNPAIR("page_index_now: ", page_index_now); +#endif + + } + + void DgusTFT::FakeChangePageOfTFT(uint32_t page_index) { + +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("ChangePageOfTFT: ", page_index); +#endif + + uint8_t data_buf[20] = {0}; + uint8_t data_index = 0; + uint32_t data_temp = 0; + + if(lcd_info.language == ExtUI::CHS) { + data_temp = page_index; + + } else if(lcd_info.language == ExtUI::ENG) { + if(PAGE_OUTAGE_RECOVERY == page_index) { + data_temp = PAGE_ENG_OUTAGE_RECOVERY; + } else if(PAGE_CHS_PROBE_PREHEATING == page_index) { + data_temp = PAGE_ENG_PROBE_PREHEATING; + } else if(PAGE_CHS_HOMING <= page_index && page_index <= PAGE_ENG_HOMING) { + data_temp = page_index+12; + } else if(PAGE_CHS_PROBE_PRECHECK <= page_index && page_index <= PAGE_CHS_PROBE_PRECHECK_FAILED) { + data_temp = page_index+3; + } else { + data_temp = page_index+120; + } + } + + page_index_last_2 = page_index_last; + page_index_last = page_index_now; + page_index_now = data_temp; + +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("page_index_last_2: ", page_index_last_2); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); + SERIAL_ECHOLNPAIR("page_index_now: ", page_index_now); +#endif + } void DgusTFT::LcdAudioSet(ExtUI::audio_t audio) { @@ -1001,7 +1131,6 @@ namespace Anycubic { void DgusTFT::ProcessPanelRequest() { unsigned char * p_u8 ; - unsigned char i,j; unsigned int control_index = 0; unsigned int control_value; unsigned int temp; @@ -1490,7 +1619,6 @@ namespace Anycubic { static millis_t flash_time = 0; char str_buf[20]; static uint8_t progress_last = 0; - unsigned int temp; switch (key_value) { @@ -1573,7 +1701,6 @@ namespace Anycubic { void DgusTFT::page5_handle(void) // print settings { char str_buf[10]; - float z_off; static bool z_change = false; switch (key_value) { @@ -1593,6 +1720,9 @@ namespace Anycubic { float z_off = getZOffset_mm(); // SERIAL_ECHOLNPAIR("z_off: ", z_off); // setSoftEndstopState(false); + if(z_off <= -5) { + return ; + } z_off -= 0.05f; setZOffset_mm(z_off); @@ -1630,9 +1760,13 @@ namespace Anycubic { float z_off = getZOffset_mm(); // SERIAL_ECHOLNPAIR("z_off: ", z_off); // setSoftEndstopState(false); + + if(z_off >= 5) { + return ; + } z_off += 0.05f; setZOffset_mm(z_off); - + str_buf[0]=0; strcat(str_buf, ftostr(getZOffset_mm())); SendTxtToTFT(str_buf, TXT_LEVEL_OFFSET); @@ -1718,8 +1852,6 @@ namespace Anycubic { void DgusTFT::page7_handle(void) // tools { - unsigned char str_buf[20]; - unsigned int temp; switch (key_value) { @@ -1777,7 +1909,6 @@ namespace Anycubic { { static uint16_t movespeed = 50; static float move_dis = 1.0f; - unsigned char value[30]; if(key_value == 2 || key_value == 4 || key_value == 6 || key_value == 8 || @@ -1788,7 +1919,6 @@ namespace Anycubic { } } - value[0]=0; // if(!planner.movesplanned())return; switch (key_value) { case 0: @@ -1940,7 +2070,6 @@ namespace Anycubic { void DgusTFT::page10_handle(void) { static millis_t flash_time = 0; - uint16_t temp; switch (key_value) { case 0: @@ -2052,6 +2181,9 @@ namespace Anycubic { char str_ver[32]; // sprintf(str_ver, "%04d-%02d-%02d %02d:%02d:%02d\n", BUILD_YEAR, BUILD_MONTH, BUILD_DAY, BUILD_HOUR, BUILD_MIN, BUILD_SEC); sprintf(str_ver, MAIN_BOARD_FIRMWARE_VER); + + + SendTxtToTFT(str_ver, TXT_VERSION); ChangePageOfTFT(PAGE_ABOUT); break; @@ -2197,8 +2329,8 @@ namespace Anycubic { case 2: if(!isPrinting()) { -// setAxisPosition_mm(10.0, Z, 5); - ChangePageOfTFT(PAGE_LEVEL_ENSURE); +// ChangePageOfTFT(PAGE_LEVEL_ENSURE); + ChangePageOfTFT(PAGE_CHS_PROBE_PRECHECK); } break; @@ -2237,6 +2369,9 @@ namespace Anycubic { case 2: { setSoftEndstopState(false); + if(getZOffset_mm() <= -5) { + return ; + } z_off = getZOffset_mm() - 0.0500f; setZOffset_mm(z_off); @@ -2255,6 +2390,9 @@ namespace Anycubic { case 3: { setSoftEndstopState(false); + if(getZOffset_mm() >= 5) { + return ; + } z_off = getZOffset_mm() + 0.0500f; setZOffset_mm(z_off); @@ -2391,7 +2529,6 @@ namespace Anycubic { SendTxtToTFT(str_buf, TXT_FILAMENT_TEMP); if(!isPrinting()) { - char value[20]; if(filament_status==1) { if(canMove(E0) && !commandsInQueue()) { injectCommands_P(AC_cmnd_manual_load_filament); @@ -2765,25 +2902,35 @@ namespace Anycubic { break; } - if(millis() < (flash_time +1000) )return; + if(millis() < (flash_time + 1000) ) { + return; + } flash_time=millis(); + + } void DgusTFT::page34_handle(void) { + char str_buf[20]; static millis_t flash_time = 0; - if(millis() < (flash_time +1000) )return; + if(millis() < (flash_time + 1500) )return; flash_time=millis(); - + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(E0), (uint16_t)getTargetTemp_celsius(E0)); + SendTxtToTFT(str_buf, TXT_MAIN_HOTEND); + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(BED), (uint16_t)getTargetTemp_celsius(BED)); + SendTxtToTFT(str_buf, TXT_MAIN_BED); + if(pop_up_index==25) { pop_up_index=100; ChangePageOfTFT(PAGE_PreLEVEL); } - + } - + void DgusTFT::page115_handle(void) { static millis_t flash_time = 0; @@ -3066,12 +3213,238 @@ namespace Anycubic { void DgusTFT::page175_handle(void) // CHS probe preheating handler { + static millis_t flash_time = 0; + char str_buf[16]; + if(millis() < (flash_time +1500) ) { + return; + } + flash_time=millis(); + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(E0), (uint16_t)getTargetTemp_celsius(E0)); + SendTxtToTFT(str_buf, TXT_MAIN_HOTEND); + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(BED), (uint16_t)getTargetTemp_celsius(BED)); + SendTxtToTFT(str_buf, TXT_MAIN_BED); } void DgusTFT::page176_handle(void) // ENG probe preheating handler { + static millis_t flash_time = 0; + char str_buf[16]; + + if(millis() < (flash_time +1500) ) { + return; + } + flash_time=millis(); + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(E0), (uint16_t)getTargetTemp_celsius(E0)); + SendTxtToTFT(str_buf, TXT_MAIN_HOTEND); + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(BED), (uint16_t)getTargetTemp_celsius(BED)); + SendTxtToTFT(str_buf, TXT_MAIN_BED); + } + void DgusTFT::page177_to_198_handle(void) + { + switch (key_value) + { + case 1: // return + +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("page_index_now: ", page_index_now); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); + SERIAL_ECHOLNPAIR("page_index_last_2: ", page_index_last_2); +#endif + + if((PAGE_CHS_ABNORMAL_X_ENDSTOP <= page_index_now && + page_index_now <= PAGE_CHS_ABNORMAL_Z_ENDSTOP) || + (PAGE_ENG_ABNORMAL_X_ENDSTOP <= page_index_now && + page_index_now <= PAGE_ENG_ABNORMAL_Z_ENDSTOP)) { + + if(lcd_info.language == ExtUI::ENG) { + if(page_index_last_2 > 120) { + page_index_last_2 -= 120; + } + + if(page_index_last > 120) { + page_index_last -= 120; + } + } + + if(PAGE_STATUS1 == page_index_last_2 || PAGE_STATUS2 == page_index_last_2 || + PAGE_PRINT_FINISH == page_index_last) { + ChangePageOfTFT(PAGE_MAIN); + } else { + ChangePageOfTFT(page_index_last_2); + } + + } else { + + if(lcd_info.language == ExtUI::ENG) { + if(page_index_last > 120) { + page_index_last -= 120; + } + } + ChangePageOfTFT(page_index_last); + } + + onSurviveInKilled(); + disable_all_steppers(); + + break; + + default: + break; + } + } + +#if 0 + void DgusTFT::page178_to_181_190_to_193_handle(void) // temperature abnormal + { + switch (key_value) + { + case 1: // return + + SERIAL_ECHOLNPAIR("page_index_now: ", page_index_now); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); + SERIAL_ECHOLNPAIR("page_index_last_2: ", page_index_last_2); + + if(isPrinting() || isPrintingPaused() || isPrintingFromMedia()) { + printer_state = AC_printer_stopping; + stopPrint(); + ChangePageOfTFT(PAGE_MAIN); + } else { + ChangePageOfTFT(page_index_last); + } + + onSurviveInKilled(); + + break; + + default: + break; + } + } +#endif + + void DgusTFT::page199_to_200_handle(void) + { + switch (key_value) + { + case 1: // return + +#if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("page_index_now: ", page_index_now); + SERIAL_ECHOLNPAIR("page_index_last: ", page_index_last); + SERIAL_ECHOLNPAIR("page_index_last_2: ", page_index_last_2); +#endif + + onSurviveInKilled(); + + ChangePageOfTFT(PAGE_PreLEVEL); + + break; + + default: + break; + } + } + + void DgusTFT::page201_handle(void) // probe precheck + { + static millis_t probe_check_time = 0; + static millis_t temperature_time = 0; + static uint8_t probe_check_counter = 0; + static uint8_t probe_state_last = 0; + static bool probe_tare_flag = 0; + char str_buf[16]; + + if(!probe_tare_flag) { + ProbeTare(); + + delay(100); + + if(getProbeState()) { // triggered too early + probe_check_counter = 0; + probe_tare_flag = 0; + ChangePageOfTFT(PAGE_CHS_PROBE_PRECHECK_FAILED); + } + probe_tare_flag = 1; + } + + switch (key_value) { + case 1: // cancel + + probe_check_counter = 0; + probe_tare_flag = 0; + ChangePageOfTFT(PAGE_PreLEVEL); + break; + + default: + break; + } + + if(millis() >= (probe_check_time + 300) ) { + + probe_check_time=millis(); + + if(!probe_state_last && getProbeState()) { + + probe_check_counter = 0; + probe_tare_flag = 0; + ChangePageOfTFT(PAGE_CHS_PROBE_PRECHECK_OK); + } + + probe_state_last = getProbeState(); + + if(probe_check_counter++ >= 200) { // waiting for 1 min + probe_check_counter = 0; + probe_tare_flag = 0; + ChangePageOfTFT(PAGE_CHS_PROBE_PRECHECK_FAILED); + } + } + + if(millis() >= (temperature_time + 1500) ) { + temperature_time=millis(); + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(E0), (uint16_t)getTargetTemp_celsius(E0)); + SendTxtToTFT(str_buf, TXT_MAIN_HOTEND); + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(BED), (uint16_t)getTargetTemp_celsius(BED)); + SendTxtToTFT(str_buf, TXT_MAIN_BED); + } + } + + void DgusTFT::page202_handle(void) // probe precheck ok + { + static millis_t flash_time = 0; + static millis_t probe_check_counter = 0; + static uint8_t probe_state_last = 0; + char str_buf[16]; + + delay(3000); + + injectCommands_P(PSTR("G28\nG29")); + printer_state = AC_printer_probing; + ChangePageOfTFT(PAGE_LEVELING); + } + + void DgusTFT::page203_handle(void) // probe precheck failed + { + static millis_t flash_time = 0; + static millis_t probe_check_counter = 0; + static uint8_t probe_state_last = 0; + char str_buf[16]; + + if(millis() < (flash_time + 1500) ) { + return; + } + flash_time=millis(); + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(E0), (uint16_t)getTargetTemp_celsius(E0)); + SendTxtToTFT(str_buf, TXT_MAIN_HOTEND); + + sprintf(str_buf,"%u/%u",(uint16_t)getActualTemp_celsius(BED), (uint16_t)getTargetTemp_celsius(BED)); + SendTxtToTFT(str_buf, TXT_MAIN_BED); } void DgusTFT::pop_up_manager(void) diff --git a/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.h b/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.h index b9f5615bd5..2aee248b3f 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.h +++ b/Marlin/src/lcd/extui/lib/anycubic_dgus/dgus_tft.h @@ -33,7 +33,7 @@ #include "../../../../inc/MarlinConfigPre.h" #include "../../ui_api.h" -#define MAIN_BOARD_FIRMWARE_VER "V2.3.5" +#define MAIN_BOARD_FIRMWARE_VER "V2.4.5" /****************** PAGE INDEX***********************/ @@ -85,6 +85,43 @@ #define PAGE_CHS_PROBE_PREHEATING (176+PAGE_OFFSET) #define PAGE_ENG_PROBE_PREHEATING (175+PAGE_OFFSET) +#define PAGE_CHS_HOMING (177+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_BED_HEATER (178+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_BED_NTC (179+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_HOTEND_HEATER (180+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_HOTEND_NTC (181+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_ENDSTOP (182+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_X_ENDSTOP (182+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_Y_ENDSTOP (183+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_Z_ENDSTOP (184+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_ZL_ENDSTOP (185+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_ZR_ENDSTOP (186+PAGE_OFFSET) +#define PAGE_CHS_ABNORMAL_LEVELING_SENSOR (187+PAGE_OFFSET) +#define PAGE_CHS_LEVELING_FAILED (188+PAGE_OFFSET) + +#define PAGE_ENG_HOMING (189+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_BED_HEATER (190+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_BED_NTC (191+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_HOTEND_HEATER (192+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_HOTEND_NTC (193+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_ENDSTOP (194+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_X_ENDSTOP (194+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_Y_ENDSTOP (195+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_Z_ENDSTOP (196+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_ZL_ENDSTOP (197+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_ZR_ENDSTOP (198+PAGE_OFFSET) +#define PAGE_ENG_ABNORMAL_LEVELING_SENSOR (199+PAGE_OFFSET) +#define PAGE_ENG_LEVELING_FAILED (200+PAGE_OFFSET) + +#define PAGE_CHS_PROBE_PRECHECK (201+PAGE_OFFSET) +#define PAGE_CHS_PROBE_PRECHECK_OK (202+PAGE_OFFSET) +#define PAGE_CHS_PROBE_PRECHECK_FAILED (203+PAGE_OFFSET) + +#define PAGE_ENG_PROBE_PRECHECK (204+PAGE_OFFSET) +#define PAGE_ENG_PROBE_PRECHECK_OK (205+PAGE_OFFSET) +#define PAGE_ENG_PROBE_PRECHECK_FAILED (206+PAGE_OFFSET) + + /****************** Lcd control **************************/ #define REG_LCD_READY 0x0014 @@ -328,6 +365,7 @@ namespace Anycubic { static uint8_t data_buf[64]; static uint8_t data_index; static uint32_t page_index_last; + static uint32_t page_index_last_2; static uint8_t message_index; static uint8_t pop_up_index; static uint32_t key_index; @@ -361,6 +399,8 @@ namespace Anycubic { void StatusChange(const char * const ); void PowerLoss(); void PowerLossRecovery(); + void HomingStart(); + void HomingComplete(); typedef void (*p_fun)(void); @@ -403,8 +443,20 @@ namespace Anycubic { static void page170_handle(void); // ENG Mute handler static void page171_handle(void); // CHS power outage resume handler static void page173_handle(void); // ENG power outage resume handler - static void page175_handle(void); // CHS probe preheating handler - static void page176_handle(void); // ENG probe preheating handler + static void page175_handle(void); // ENG probe preheating handler + static void page176_handle(void); // CHS probe preheating handler + + static void page177_to_198_handle(void); +// static void page178_to_181_190_to_193_handle(void); + static void page199_to_200_handle(void); + + static void page201_handle(void); + static void page202_handle(void); + static void page203_handle(void); + static void page204_handle(void); + static void page205_handle(void); + static void page206_handle(void); + static void pop_up_manager(void); void SendtoTFT(PGM_P); @@ -426,6 +478,7 @@ namespace Anycubic { static void SendColorToTFT(uint32_t color, uint32_t address); static void SendReadNumOfTxtToTFT(uint8_t number, uint32_t address); static void ChangePageOfTFT(uint32_t page_index); + static void FakeChangePageOfTFT(uint32_t page_index); static void LcdAudioSet(ExtUI::audio_t audio); private: diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 595d114b45..8c5f73017d 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -102,7 +102,7 @@ namespace ExtUI { static struct { - uint8_t printer_killed : 1; + volatile uint8_t printer_killed : 1; TERN_(JOYSTICK, uint8_t jogging : 1); TERN_(SDSUPPORT, uint8_t was_sd_printing : 1); } flags; @@ -791,6 +791,14 @@ namespace ExtUI { void setProbeOffset_mm(const float val, const axis_t axis) { probe.offset.pos[axis] = val; } + + void ProbeTare(void) + { + OUT_WRITE(AUTO_LEVEL_TX_PIN, LOW); + delay(300); + OUT_WRITE(AUTO_LEVEL_TX_PIN, HIGH); + delay(100); + } #endif #if ENABLED(BACKLASH_GCODE) @@ -999,6 +1007,21 @@ namespace ExtUI { onStatusChanged(msg); } + void onSurviveInKilled() + { + thermalManager.killed = 0; + flags.printer_killed = 0; + marlin_state = MF_RUNNING; +// SERIAL_ECHOLNPAIR("survived at: ", millis()); + } + + void onKilledStatusGet() + { + SERIAL_ECHOLNPAIR("thermalManager.killed: ", thermalManager.killed); + SERIAL_ECHOLNPAIR("flags.printer_killed: ", flags.printer_killed); + SERIAL_ECHOLNPAIR("marlin_state: ", marlin_state); + } + FileList::FileList() { refresh(); } void FileList::refresh() { num_files = 0xFFFF; } @@ -1066,10 +1089,14 @@ void MarlinUI::update() { ExtUI::onIdle(); } void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) { using namespace ExtUI; + SERIAL_ECHOLNPAIR("flags.printer_killed: ", flags.printer_killed); if (!flags.printer_killed) { flags.printer_killed = true; onPrinterKilled(error, component); } } + + + #endif // EXTENSIBLE_UI diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 7314081d7a..ab76494b58 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -44,6 +44,7 @@ #include "../../inc/MarlinConfig.h" #include "../marlinui.h" +#include "../../module/probe.h" namespace ExtUI { @@ -239,6 +240,8 @@ namespace ExtUI { #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t); void setProbeOffset_mm(const float, const axis_t); + inline bool getProbeState(void) { return PROBE_TRIGGERED(); } + void ProbeTare(void); #endif #if ENABLED(BACKLASH_GCODE) @@ -366,6 +369,8 @@ namespace ExtUI { void onUserConfirmRequired_P(PGM_P const pstr); void onStatusChanged(const char * const msg); void onStatusChanged_P(PGM_P const pstr); + void onSurviveInKilled(); + void onKilledStatusGet(); void onHomingStart(); void onHomingComplete(); void onSteppersDisabled(); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index b1c7c1c585..45e6c77cea 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -323,9 +323,22 @@ void Endstops::not_homing() { #if ENABLED(VALIDATE_HOMING_ENDSTOPS) // If the last move failed to trigger an endstop, call kill - void Endstops::validate_homing_move() { - if (trigger_state()) hit_on_purpose(); - else kill(GET_TEXT(MSG_KILL_HOMING_FAILED)); + uint8_t Endstops::validate_homing_move() { + if (trigger_state()) { + hit_on_purpose(); + return true; + } else if(HOMING_X == homing_state) { + homing_state = HOMING_FAILED_X; + kill(GET_TEXT(MSG_KILL_HOMING_FAILED), "X"); // (const char *)homing_state+'0' + } else if(HOMING_Y == homing_state) { + homing_state = HOMING_FAILED_Y; + kill(GET_TEXT(MSG_KILL_HOMING_FAILED), "Y"); + } else if(HOMING_Z == homing_state) { + homing_state = HOMING_FAILED_Z; + kill(GET_TEXT(MSG_KILL_HOMING_FAILED), "Z"); + } + + return false; } #endif diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 05936a6bf3..bb0e82b662 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -145,7 +145,7 @@ class Endstops { #if ENABLED(VALIDATE_HOMING_ENDSTOPS) // If the last move failed to trigger an endstop, call kill - static void validate_homing_move(); + static uint8_t validate_homing_move(); #else FORCE_INLINE static void validate_homing_move() { hit_on_purpose(); } #endif diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 99853f24df..39dcecede7 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1290,7 +1290,7 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) { /** * Home an individual linear axis */ -void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0, const bool final_approach=true) { +uint8_t do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0, const bool final_approach=true) { DEBUG_SECTION(log_move, "do_homing_move", DEBUGGING(LEVELING)); const feedRate_t home_fr_mm_s = fr_mm_s ?: homing_feedrate(axis); @@ -1363,10 +1363,14 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t if (axis == Z_AXIS && final_approach) probe.set_probing_paused(false); #endif - endstops.validate_homing_move(); + if(!endstops.validate_homing_move()) { + return false; + } // Re-enable stealthChop if used. Disable diag1 pin on driver. TERN_(SENSORLESS_HOMING, end_sensorless_homing_per_axis(axis, stealth_states)); + + return true; } } @@ -1551,7 +1555,6 @@ void set_axis_never_homed(const AxisEnum axis) { */ void homeaxis(const AxisEnum axis) { - #if IS_SCARA // Only Z homing (with probe) is permitted if (axis != Z_AXIS) { BUZZ(100, 880); return; } @@ -1619,10 +1622,15 @@ void homeaxis(const AxisEnum axis) { // // Fast move towards endstop until triggered // - const float move_length = 1.5f * max_length(TERN(DELTA, Z_AXIS, axis)) * axis_home_dir; + const float move_length = 1.1f * max_length(TERN(DELTA, Z_AXIS, axis)) * axis_home_dir; if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Home Fast: ", move_length, "mm"); + do_homing_move(axis, move_length, 0.0, !use_probe_bump); + if(HOMING_FAILED_X == homing_state || HOMING_FAILED_Y == homing_state) { + return; + } + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 503cb812cb..2e3b1e1913 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -87,6 +87,7 @@ Probe probe; xyz_pos_t Probe::offset; // Initialized by settings.load() +int8_t Probe::status = 0; #if HAS_PROBE_XY_OFFSET const xy_pos_t &Probe::offset_xy = Probe::offset; @@ -769,6 +770,7 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise stow(); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); #if DISABLED(G29_RETRY_AND_RECOVER) + status = -1; SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED); #endif } diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index d28cdff53a..d75cf415e7 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -51,6 +51,8 @@ class Probe { static xyz_pos_t offset; + static int8_t status; + #if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING) static void preheat_for_probing(const uint16_t hotend_temp, const uint16_t bed_temp); #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f5ddc2e9f2..c53cb3b8e0 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -337,6 +337,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, float Temperature::redundant_temperature = 0.0; #endif +volatile uint8_t Temperature::killed = 0; + volatile bool Temperature::raw_temps_ready = false; #if ENABLED(PID_EXTRUSION_SCALING) @@ -790,10 +792,12 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { // Temperature Error Handlers // -inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { +inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) +{ marlin_state = MF_KILLED; #if USE_BEEPER - thermalManager.disable_all_heaters(); +#if 0 +// thermalManager.disable_all_heaters(); for (uint8_t i = 20; i--;) { WRITE(BEEPER_PIN, HIGH); delay(25); @@ -804,14 +808,23 @@ inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { delay(40); watchdog_refresh(); } - WRITE(BEEPER_PIN, HIGH); + WRITE(BEEPER_PIN, LOW); +#endif + + watchdog_refresh(); + TERN_(USE_BEEPER, buzzer.tone(300, 1000)); + watchdog_refresh(); + TERN_(USE_BEEPER, buzzer.tone(300, 1000)); + watchdog_refresh(); + #endif + kill(lcd_msg, HEATER_PSTR(heater_id)); } void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_msg, PGM_P const lcd_msg) { - static uint8_t killed = 0; +// static uint8_t killed = 0; if (IsRunning() && TERN1(BOGUS_TEMPERATURE_GRACE_PERIOD, killed == 2)) { SERIAL_ERROR_START(); @@ -826,7 +839,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms SERIAL_EOL(); } - disable_all_heaters(); // always disable (even for bogus temp) +// disable_all_heaters(); // always disable (even for bogus temp) watchdog_refresh(); #if BOGUS_TEMPERATURE_GRACE_PERIOD @@ -856,6 +869,11 @@ void Temperature::max_temp_error(const heater_id_t heater_id) { #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(1); #endif + + if(millis() < 3000) { + return ; + } + _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP)); } diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index f570fe2107..dc98b55c0c 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -300,6 +300,8 @@ class Temperature { public: + static volatile uint8_t killed; + #if HAS_HOTEND #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) static hotend_info_t temp_hotend[HOTEND_TEMPS]; @@ -804,6 +806,7 @@ class Temperature { #endif private: + static void update_raw_temperatures(); static void updateTemperaturesFromRawValues();