@@ -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
static inline float pgm_read_any (const float *p) { return pgm_read_float_near (p); }
665
663
static inline signed char pgm_read_any (const signed char *p) { return pgm_read_byte_near (p); }
@@ -1021,7 +1019,7 @@ inline void get_serial_commands() {
1021
1019
// send "wait" to indicate Marlin is still waiting.
1022
1020
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
1023
1021
static millis_t last_command_time = 0 ;
1024
- millis_t ms = millis ();
1022
+ const millis_t ms = millis ();
1025
1023
if (commands_in_queue == 0 && !MYSERIAL.available () && ELAPSED (ms, last_command_time + NO_TIMEOUTS)) {
1026
1024
SERIAL_ECHOLNPGM (MSG_WAIT);
1027
1025
last_command_time = ms;
@@ -4700,8 +4698,8 @@ inline void gcode_G92() {
4700
4698
4701
4699
#endif
4702
4700
4703
- wait_for_user = true ;
4704
4701
KEEPALIVE_STATE (PAUSED_FOR_USER);
4702
+ wait_for_user = true ;
4705
4703
4706
4704
stepper.synchronize ();
4707
4705
refresh_cmd_timeout ();
@@ -5040,7 +5038,7 @@ inline void gcode_M42() {
5040
5038
if (first_pin > NUM_DIGITAL_PINS - 1 ) return ;
5041
5039
}
5042
5040
5043
- bool ignore_protection = code_seen (' I' ) ? code_value_bool () : false ;
5041
+ const bool ignore_protection = code_seen (' I' ) ? code_value_bool () : false ;
5044
5042
5045
5043
// Watch until click, M108, or reset
5046
5044
if (code_seen (' W' ) && code_value_bool ()) { // watch digital pins
@@ -6314,8 +6312,8 @@ inline void gcode_M121() { endstops.enable_globally(false); }
6314
6312
6315
6313
#if DISABLED(SDSUPPORT)
6316
6314
// Wait for lcd click or M108
6317
- wait_for_user = true ;
6318
6315
KEEPALIVE_STATE (PAUSED_FOR_USER);
6316
+ wait_for_user = true ;
6319
6317
while (wait_for_user) idle ();
6320
6318
KEEPALIVE_STATE (IN_HANDLER);
6321
6319
@@ -7581,7 +7579,7 @@ inline void gcode_M503() {
7581
7579
disable_e_steppers ();
7582
7580
safe_delay (100 );
7583
7581
7584
- millis_t nozzle_timeout = millis () + (millis_t )(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000L ;
7582
+ const millis_t nozzle_timeout = millis () + (millis_t )(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL ;
7585
7583
bool nozzle_timed_out = false ;
7586
7584
float temps[4 ];
7587
7585
@@ -7596,25 +7594,25 @@ inline void gcode_M503() {
7596
7594
7597
7595
HOTEND_LOOP () temps[e] = thermalManager.target_temperature [e]; // Save nozzle temps
7598
7596
7597
+ KEEPALIVE_STATE (PAUSED_FOR_USER);
7599
7598
wait_for_user = true ; // LCD click or M108 will clear this
7600
7599
while (wait_for_user) {
7601
- millis_t current_ms = millis ();
7600
+
7602
7601
if (nozzle_timed_out)
7603
7602
lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
7604
7603
7605
7604
#if HAS_BUZZER
7606
7605
filament_change_beep ();
7607
7606
#endif
7608
7607
7609
- if (current_ms >= nozzle_timeout) {
7610
- if (!nozzle_timed_out) {
7611
- nozzle_timed_out = true ; // on nozzle timeout remember the nozzles need to be reheated
7612
- HOTEND_LOOP () thermalManager.setTargetHotend (0 , e); // Turn off all the nozzles
7613
- lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
7614
- }
7608
+ if (!nozzle_timed_out && ELAPSED (millis (), nozzle_timeout)) {
7609
+ nozzle_timed_out = true ; // on nozzle timeout remember the nozzles need to be reheated
7610
+ HOTEND_LOOP () thermalManager.setTargetHotend (0 , e); // Turn off all the nozzles
7611
+ lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
7615
7612
}
7616
7613
idle (true );
7617
7614
}
7615
+ KEEPALIVE_STATE (IN_HANDLER);
7618
7616
7619
7617
if (nozzle_timed_out) // Turn nozzles back on if they were turned off
7620
7618
HOTEND_LOOP () thermalManager.setTargetHotend (temps[e], e);
@@ -7642,13 +7640,15 @@ inline void gcode_M503() {
7642
7640
filament_change_beep (true );
7643
7641
#endif
7644
7642
7643
+ KEEPALIVE_STATE (PAUSED_FOR_USER);
7645
7644
wait_for_user = true ; // LCD click or M108 will clear this
7646
7645
while (wait_for_user && nozzle_timed_out) {
7647
7646
#if HAS_BUZZER
7648
7647
filament_change_beep ();
7649
7648
#endif
7650
7649
idle (true );
7651
7650
}
7651
+ KEEPALIVE_STATE (IN_HANDLER);
7652
7652
7653
7653
// Show "load" message
7654
7654
lcd_filament_change_show_message (FILAMENT_CHANGE_MESSAGE_LOAD);
@@ -10160,9 +10160,9 @@ void prepare_move_to_destination() {
10160
10160
#if HAS_CONTROLLERFAN
10161
10161
10162
10162
void controllerFan () {
10163
- static millis_t lastMotorOn = 0 ; // Last time a motor was turned on
10164
- static millis_t nextMotorCheck = 0 ; // Last time the state was checked
10165
- millis_t ms = millis ();
10163
+ static millis_t lastMotorOn = 0 , // Last time a motor was turned on
10164
+ nextMotorCheck = 0 ; // Last time the state was checked
10165
+ const millis_t ms = millis ();
10166
10166
if (ELAPSED (ms, nextMotorCheck)) {
10167
10167
nextMotorCheck = ms + 2500UL ; // Not a time critical function, so only check every 2.5s
10168
10168
if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || thermalManager.soft_pwm_bed > 0
@@ -10495,7 +10495,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
10495
10495
10496
10496
if (commands_in_queue < BUFSIZE) get_available_commands ();
10497
10497
10498
- millis_t ms = millis ();
10498
+ const millis_t ms = millis ();
10499
10499
10500
10500
if (max_inactive_time && ELAPSED (ms, previous_cmd_ms + max_inactive_time)) {
10501
10501
SERIAL_ERROR_START;
@@ -10709,7 +10709,7 @@ void kill(const char* lcd_msg) {
10709
10709
10710
10710
thermalManager.disable_all_heaters ();
10711
10711
disable_all_steppers ();
10712
-
10712
+
10713
10713
#if ENABLED(ULTRA_LCD)
10714
10714
kill_screen (lcd_msg);
10715
10715
#else
@@ -10718,7 +10718,7 @@ void kill(const char* lcd_msg) {
10718
10718
10719
10719
_delay_ms (250 ); // Wait a short time
10720
10720
cli (); // Stop interrupts
10721
-
10721
+
10722
10722
_delay_ms (250 ); // Wait to ensure all interrupts routines stopped
10723
10723
thermalManager.disable_all_heaters (); // turn off heaters again
10724
10724
0 commit comments