From d9dcef8a874f2cce6740d515527126533239b840 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Feb 2017 00:13:58 -0600 Subject: [PATCH] Spacing, coding standards --- Marlin/Configuration_adv.h | 6 +-- Marlin/Marlin_main.cpp | 76 ++++++++++++++++------------------ Marlin/ultralcd.cpp | 23 ++++------ Marlin/ultralcd_impl_DOGM.h | 6 +-- Marlin/ultralcd_impl_HD44780.h | 2 +- 5 files changed, 51 insertions(+), 62 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 36b2387168..1f7ab48901 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -728,9 +728,9 @@ // or until outcoming filament color is not clear for filament color change #define FILAMENT_CHANGE_EXTRUDE_FEEDRATE 3 // Extrude filament feedrate in mm/s - must be slower than load feedrate #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define STEPPER_MOTORS_DONT_TIMEOUT_DURING_FILAMENT_CHANGE // Enable to make stepper motors hold position during filament change even if it - // takes longer than DEFAULT_STEPPER_DEACTIVE_TIME + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif /******************************************************************************\ diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2b72b1dc57..3a93bc63ef 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7310,7 +7310,7 @@ inline void gcode_M503() { } } - bool busy_doing_M600 = false; + static bool busy_doing_M600 = false; /** * M600: Pause for filament change @@ -7351,8 +7351,6 @@ inline void gcode_M503() { #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S); #endif - KEEPALIVE_STATE(IN_HANDLER); - // Initial retract before move to filament change position if (code_seen('E')) destination[E_AXIS] += code_value_axis_units(E_AXIS); #if defined(FILAMENT_CHANGE_RETRACT_LENGTH) && FILAMENT_CHANGE_RETRACT_LENGTH > 0 @@ -7409,10 +7407,9 @@ inline void gcode_M503() { disable_e3(); delay(100); - millis_t nozzle_timeout = millis() + FILAMENT_CHANGE_NOZZLE_TIMEOUT*1000L; + millis_t nozzle_timeout = millis() + FILAMENT_CHANGE_NOZZLE_TIMEOUT * 1000L; bool nozzle_timed_out = false; float temps[4]; - int iii; // Wait for filament insert by user and press button lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); @@ -7422,62 +7419,62 @@ inline void gcode_M503() { wait_for_user = true; // LCD click or M108 will clear this next_buzz = 0; runout_beep = 0; - for( iii=0; iii= nozzle_timeout) { - if (nozzle_timed_out == false ) { - nozzle_timed_out = true; // if the nozzle time out happens, remember we turned off the nozzles. - for( iii=0; iii 3 ) { - lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT); - goto KEEP_CHECKING_TEMPS; + // Show "wait for heating" + lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT); + + wait_for_heatup = true; + while (wait_for_heatup) { + idle(); + wait_for_heatup = false; + HOTEND_LOOP() { + if (abs(thermalManager.degHotend(e) - temps[e]) > 3) { + wait_for_heatup = true; + break; + } } } + // Show "insert filament" + if (nozzle_timed_out) + lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); + wait_for_user = true; // LCD click or M108 will clear this next_buzz = 0; runout_beep = 0; - while (wait_for_user) { - if (nozzle_timed_out == true) - lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); - else break; + while (wait_for_user && nozzle_timed_out) { #if HAS_BUZZER filament_change_beep(); #endif idle(true); } - // Show load message + // Show "load" message lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD); - idle(); - // Load filament if (code_seen('L')) destination[E_AXIS] -= code_value_axis_units(E_AXIS); #if defined(FILAMENT_CHANGE_LOAD_LENGTH) && FILAMENT_CHANGE_LOAD_LENGTH > 0 @@ -7504,8 +7501,6 @@ KEEP_CHECKING_TEMPS: lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_RESUME); - KEEPALIVE_STATE(IN_HANDLER); - // Set extruder to saved position destination[E_AXIS] = current_position[E_AXIS] = lastpos[E_AXIS]; planner.set_e_position_mm(current_position[E_AXIS]); @@ -10144,14 +10139,15 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { millis_t ms = millis(); if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) kill(PSTR(MSG_KILLED)); - - #if ENABLED(FILAMENT_CHANGE_FEATURE) - #ifdef STEPPER_MOTORS_DONT_TIMEOUT_DURING_FILAMENT_CHANGE - if (busy_doing_M600 == false ) // We only allow the stepper motors to time out if - #endif // we are not in the middle of an M600 command. + + // Prevent steppers timing-out in the middle of M600 + #if ENABLED(FILAMENT_CHANGE_FEATURE) && ENABLED(FILAMENT_CHANGE_NO_STEPPER_TIMEOUT) + #define M600_TEST !busy_doing_M600 + #else + #define M600_TEST true #endif - if (stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time) + if (M600_TEST && stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time) && !ignore_stepper_queue && !planner.blocks_queued()) { #if ENABLED(DISABLE_INACTIVE_X) disable_x(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 0dd0a59d51..b28880f61c 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -950,7 +950,7 @@ void kill_screen(const char* lcd_msg) { // Change filament // #if ENABLED(FILAMENT_CHANGE_FEATURE) - if (!thermalManager.tooColdToExtrude(active_extruder)) + if (!thermalManager.tooColdToExtrude(active_extruder)) MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change); #endif @@ -2446,19 +2446,19 @@ KeepDrawing: } #endif // LCD_INFO_MENU - /** - * - * Filament Change Feature Screens - * - */ + /** + * + * Filament Change Feature Screens + * + */ #if ENABLED(FILAMENT_CHANGE_FEATURE) void lcd_filament_change_toocold_menu() { START_MENU(); STATIC_ITEM(MSG_HEATING_FAILED_LCD, true, true); - STATIC_ITEM (MSG_FILAMENT_CHANGE_MINTEMP STRINGIFY(EXTRUDE_MINTEMP) ".", false, false); + STATIC_ITEM(MSG_FILAMENT_CHANGE_MINTEMP STRINGIFY(EXTRUDE_MINTEMP) ".", false, false); MENU_BACK(MSG_BACK); - STATIC_ITEM (" "); + STATIC_ITEM(" "); STATIC_ITEM(MSG_FILAMENT_CHANGE_NOZZLE, false, true); lcd_implementation_hotend_status(); END_MENU(); @@ -2604,31 +2604,24 @@ KeepDrawing: switch (message) { case FILAMENT_CHANGE_MESSAGE_INIT: defer_return_to_status = true; - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_init_message); break; case FILAMENT_CHANGE_MESSAGE_UNLOAD: - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_unload_message); break; case FILAMENT_CHANGE_MESSAGE_INSERT: - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_insert_message); break; case FILAMENT_CHANGE_MESSAGE_LOAD: - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_load_message); break; case FILAMENT_CHANGE_MESSAGE_EXTRUDE: - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_extrude_message); break; case FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE: - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_heat_nozzle); break; case FILAMENT_CHANGE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT: - lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcd_goto_screen(lcd_filament_change_wait_for_nozzles_to_heat); break; case FILAMENT_CHANGE_MESSAGE_OPTION: diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index cc1b709e80..d5799b22e1 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -382,9 +382,9 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, static void lcd_implementation_hotend_status() { u8g.setPrintPos(58, 60); - lcd_print( (char) '0'+active_extruder ); - lcd_print( ' ' ); - lcd_print( ' ' ); + lcd_print((char)('0' + active_extruder)); + lcd_print(' '); + lcd_print(' '); lcd_print(itostr3(thermalManager.degHotend(active_extruder))); lcd_print('/'); lcd_print(itostr3(thermalManager.degTargetHotend(active_extruder))); diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index f4fa4795db..786a0afdd6 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -593,7 +593,7 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, #endif // LCD_PROGRESS_BAR static void lcd_implementation_hotend_status() { - lcd.setCursor(10,3); + lcd.setCursor(10, 3); lcd.print(LCD_STR_THERMOMETER[active_extruder]); lcd.print(itostr3(thermalManager.degHotend(active_extruder))); lcd.print('/');