Simplify fan checks now that lcd pause works correctly

This commit is contained in:
Yuri D'Elia 2022-07-07 12:10:44 +02:00
parent 1eb7871bab
commit 39ad53ab11
4 changed files with 35 additions and 37 deletions

View File

@ -1863,13 +1863,6 @@ void loop()
; ;
} }
#ifdef FANCHECK
if (fan_check_error && isPrintPaused && !IS_SD_PRINTING) {
KEEPALIVE_STATE(PAUSED_FOR_USER);
host_keepalive(); //prevent timeouts since usb processing is disabled until print is resumed. This is for a crude way of pausing a print on all hosts.
}
#endif
#ifdef PRUSA_M28 #ifdef PRUSA_M28
if (prusa_sd_card_upload) if (prusa_sd_card_upload)
{ {
@ -4197,16 +4190,6 @@ There are reasons why some G Codes aren't in numerical order.
void process_commands() void process_commands()
{ {
#ifdef FANCHECK
if(fan_check_error == EFCE_DETECTED) {
fan_check_error = EFCE_REPORTED;
if (usb_timer.running())
lcd_pause_usb_print();
else
lcd_pause_print();
}
#endif
if (!buflen) return; //empty command if (!buflen) return; //empty command
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG

View File

@ -82,21 +82,22 @@ static void fanSpeedErrorBeep(const char *serialMsg, const char *lcdMsg){
} }
void fanSpeedError(unsigned char _fan) { void fanSpeedError(unsigned char _fan) {
if (get_message_level() != 0 && isPrintPaused) return; if (fan_check_error == EFCE_REPORTED) return;
//to ensure that target temp. is not set to zero in case that we are resuming print fan_check_error = EFCE_REPORTED;
if (card.sdprinting || usb_timer.running()) {
if (heating_status != HeatingStatus::NO_HEATING) { if (IS_SD_PRINTING || usb_timer.running()) {
lcd_print_stop(); // A print is ongoing, pause the print normally
} if(!isPrintPaused) {
else { if (usb_timer.running())
fan_check_error = EFCE_DETECTED; //plans error for next processed command lcd_pause_usb_print();
else
lcd_pause_print();
} }
} }
else { else {
// SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSED); //Why pause octoprint? usb_timer.running() would be true in that case, so there is no need for this. // Nothing is going on, but still turn off heaters and report the error
setTargetHotend0(0); setTargetHotend0(0);
heating_status = HeatingStatus::NO_HEATING; heating_status = HeatingStatus::NO_HEATING;
fan_check_error = EFCE_REPORTED;
} }
switch (_fan) { switch (_fan) {
case 0: // extracting the same code from case 0 and case 1 into a function saves 72B case 0: // extracting the same code from case 0 and case 1 into a function saves 72B

View File

@ -8,7 +8,6 @@
enum { enum {
EFCE_OK = 0, //!< normal operation, both fans are ok EFCE_OK = 0, //!< normal operation, both fans are ok
EFCE_FIXED, //!< previous fan error was fixed EFCE_FIXED, //!< previous fan error was fixed
EFCE_DETECTED, //!< fan error detected, but not reported yet
EFCE_REPORTED //!< fan error detected and reported to LCD and serial EFCE_REPORTED //!< fan error detected and reported to LCD and serial
}; };
extern volatile uint8_t fan_check_error; extern volatile uint8_t fan_check_error;

View File

@ -5692,19 +5692,30 @@ static bool fan_error_selftest()
return 0; return 0;
} }
bool resume_print_checks() {
// reset the lcd status so that a newer error will be shown
lcd_return_to_status();
lcd_reset_alert_level();
// ensure thermal issues (temp or fan) are resolved before we allow to resume
if (get_temp_error()
#ifdef FANCHECK
|| fan_error_selftest()
#endif
) {
return false; // abort if error persists
}
return true;
}
//! @brief Resume paused print, send host action "resumed" //! @brief Resume paused print, send host action "resumed"
//! @todo It is not good to call restore_print_from_ram_and_continue() from function called by lcd_update(), //! @todo It is not good to call restore_print_from_ram_and_continue() from function called by lcd_update(),
//! as restore_print_from_ram_and_continue() calls lcd_update() internally. //! as restore_print_from_ram_and_continue() calls lcd_update() internally.
void lcd_resume_print() void lcd_resume_print()
{ {
lcd_return_to_status(); // reset lcd and ensure we can resume first
lcd_reset_alert_level(); if (!resume_print_checks()) return;
// ensure thermal issues (temp or fan) are resolved before we allow to resume
if (get_temp_error() || fan_error_selftest()) {
if (usb_timer.running()) SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSED);
return; // abort if error persists
}
cmdqueue_serial_disabled = false; cmdqueue_serial_disabled = false;
lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS));
@ -5722,7 +5733,11 @@ void lcd_resume_print()
//! @brief Resume paused USB/host print, send host action "resume" //! @brief Resume paused USB/host print, send host action "resume"
void lcd_resume_usb_print() void lcd_resume_usb_print()
{ {
SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUME); //resume octoprint // reset lcd and ensure we can resume first
if (!resume_print_checks()) return;
// resume the usb host
SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUME);
} }
static void change_sheet() static void change_sheet()