@@ -655,11 +655,9 @@ static bool send_ok[BUFSIZE];
655
655
static MarlinBusyState busy_state = NOT_BUSY;
656
656
static millis_t next_busy_signal_ms = 0 ;
657
657
uint8_t host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
658
- #define KEEPALIVE_STATE (n ) do { busy_state = n; }while (0 )
659
658
#else
660
- #define host_keepalive () ;
661
- #define KEEPALIVE_STATE (n ) ;
662
- #endif // HOST_KEEPALIVE_FEATURE
659
+ #define host_keepalive () NOOP
660
+ #endif
663
661
664
662
#define DEFINE_PGM_READ_ANY (type, reader ) \
665
663
static inline type pgm_read_any (const type *p) \
@@ -1031,7 +1029,7 @@ inline void get_serial_commands() {
1031
1029
// send "wait" to indicate Marlin is still waiting.
1032
1030
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
1033
1031
static millis_t last_command_time = 0 ;
1034
- millis_t ms = millis ();
1032
+ const millis_t ms = millis ();
1035
1033
if (commands_in_queue == 0 && !MYSERIAL.available () && ELAPSED (ms, last_command_time + NO_TIMEOUTS)) {
1036
1034
SERIAL_ECHOLNPGM (MSG_WAIT);
1037
1035
last_command_time = ms;
@@ -4710,8 +4708,8 @@ inline void gcode_G92() {
4710
4708
4711
4709
#endif
4712
4710
4713
- wait_for_user = true ;
4714
4711
KEEPALIVE_STATE (PAUSED_FOR_USER);
4712
+ wait_for_user = true ;
4715
4713
4716
4714
stepper.synchronize ();
4717
4715
refresh_cmd_timeout ();
@@ -5050,7 +5048,7 @@ inline void gcode_M42() {
5050
5048
if (first_pin > NUM_DIGITAL_PINS - 1 ) return ;
5051
5049
}
5052
5050
5053
- bool ignore_protection = code_seen (' I' ) ? code_value_bool () : false ;
5051
+ const bool ignore_protection = code_seen (' I' ) ? code_value_bool () : false ;
5054
5052
5055
5053
// Watch until click, M108, or reset
5056
5054
if (code_seen (' W' ) && code_value_bool ()) { // watch digital pins
@@ -6324,8 +6322,8 @@ inline void gcode_M121() { endstops.enable_globally(false); }
6324
6322
6325
6323
#if DISABLED(SDSUPPORT)
6326
6324
// Wait for lcd click or M108
6327
- wait_for_user = true ;
6328
6325
KEEPALIVE_STATE (PAUSED_FOR_USER);
6326
+ wait_for_user = true ;
6329
6327
while (wait_for_user) idle ();
6330
6328
KEEPALIVE_STATE (IN_HANDLER);
6331
6329
@@ -7591,7 +7589,7 @@ inline void gcode_M503() {
7591
7589
disable_e_steppers ();
7592
7590
safe_delay (100 );
7593
7591
7594
- millis_t nozzle_timeout = millis () + (millis_t )(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000L ;
7592
+ const millis_t nozzle_timeout = millis () + (millis_t )(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL ;
7595
7593
bool nozzle_timed_out = false ;
7596
7594
float temps[4 ];
7597
7595
@@ -7606,25 +7604,25 @@ inline void gcode_M503() {
7606
7604
7607
7605
HOTEND_LOOP () temps[e] = thermalManager.target_temperature [e]; // Save nozzle temps
7608
7606
7607
+ KEEPALIVE_STATE (PAUSED_FOR_USER);
7609
7608
wait_for_user = true ; // LCD click or M108 will clear this
7610
7609
while (wait_for_user) {
7611
- millis_t current_ms = millis ();
7610
+
7612
7611
if (nozzle_timed_out)
7613
7612
lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
7614
7613
7615
7614
#if HAS_BUZZER
7616
7615
filament_change_beep ();
7617
7616
#endif
7618
7617
7619
- if (current_ms >= nozzle_timeout) {
7620
- if (!nozzle_timed_out) {
7621
- nozzle_timed_out = true ; // on nozzle timeout remember the nozzles need to be reheated
7622
- HOTEND_LOOP () thermalManager.setTargetHotend (0 , e); // Turn off all the nozzles
7623
- lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
7624
- }
7618
+ if (!nozzle_timed_out && ELAPSED (millis (), nozzle_timeout)) {
7619
+ nozzle_timed_out = true ; // on nozzle timeout remember the nozzles need to be reheated
7620
+ HOTEND_LOOP () thermalManager.setTargetHotend (0 , e); // Turn off all the nozzles
7621
+ lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
7625
7622
}
7626
7623
idle (true );
7627
7624
}
7625
+ KEEPALIVE_STATE (IN_HANDLER);
7628
7626
7629
7627
if (nozzle_timed_out) // Turn nozzles back on if they were turned off
7630
7628
HOTEND_LOOP () thermalManager.setTargetHotend (temps[e], e);
@@ -7652,13 +7650,15 @@ inline void gcode_M503() {
7652
7650
filament_change_beep (true );
7653
7651
#endif
7654
7652
7653
+ KEEPALIVE_STATE (PAUSED_FOR_USER);
7655
7654
wait_for_user = true ; // LCD click or M108 will clear this
7656
7655
while (wait_for_user && nozzle_timed_out) {
7657
7656
#if HAS_BUZZER
7658
7657
filament_change_beep ();
7659
7658
#endif
7660
7659
idle (true );
7661
7660
}
7661
+ KEEPALIVE_STATE (IN_HANDLER);
7662
7662
7663
7663
// Show "load" message
7664
7664
lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_LOAD);
@@ -10137,9 +10137,9 @@ void prepare_move_to_destination() {
10137
10137
#if HAS_CONTROLLERFAN
10138
10138
10139
10139
void controllerFan () {
10140
- static millis_t lastMotorOn = 0 ; // Last time a motor was turned on
10141
- static millis_t nextMotorCheck = 0 ; // Last time the state was checked
10142
- millis_t ms = millis ();
10140
+ static millis_t lastMotorOn = 0 , // Last time a motor was turned on
10141
+ nextMotorCheck = 0 ; // Last time the state was checked
10142
+ const millis_t ms = millis ();
10143
10143
if (ELAPSED (ms, nextMotorCheck)) {
10144
10144
nextMotorCheck = ms + 2500UL ; // Not a time critical function, so only check every 2.5s
10145
10145
if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || thermalManager.soft_pwm_bed > 0
@@ -10472,7 +10472,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
10472
10472
10473
10473
if (commands_in_queue < BUFSIZE) get_available_commands ();
10474
10474
10475
- millis_t ms = millis ();
10475
+ const millis_t ms = millis ();
10476
10476
10477
10477
if (max_inactive_time && ELAPSED (ms, previous_cmd_ms + max_inactive_time)) {
10478
10478
SERIAL_ERROR_START;
@@ -10686,7 +10686,7 @@ void kill(const char* lcd_msg) {
10686
10686
10687
10687
thermalManager.disable_all_heaters ();
10688
10688
disable_all_steppers ();
10689
-
10689
+
10690
10690
#if ENABLED(ULTRA_LCD)
10691
10691
kill_screen (lcd_msg);
10692
10692
#else
@@ -10695,7 +10695,7 @@ void kill(const char* lcd_msg) {
10695
10695
10696
10696
_delay_ms (250 ); // Wait a short time
10697
10697
cli (); // Stop interrupts
10698
-
10698
+
10699
10699
_delay_ms (250 ); // Wait to ensure all interrupts routines stopped
10700
10700
thermalManager.disable_all_heaters (); // turn off heaters again
10701
10701
0 commit comments