|
@@ -218,13 +218,8 @@ bool wait_for_heatup = true;
|
218
|
218
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
219
|
219
|
wait_for_user = true;
|
220
|
220
|
if (ms) ms += millis(); // expire time
|
221
|
|
- while (wait_for_user && !(ms && ELAPSED(millis(), ms))) {
|
222
|
|
- idle(
|
223
|
|
- #if ENABLED(ADVANCED_PAUSE_FEATURE)
|
224
|
|
- no_sleep
|
225
|
|
- #endif
|
226
|
|
- );
|
227
|
|
- }
|
|
221
|
+ while (wait_for_user && !(ms && ELAPSED(millis(), ms)))
|
|
222
|
+ idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep));
|
228
|
223
|
wait_for_user = false;
|
229
|
224
|
}
|
230
|
225
|
|
|
@@ -647,52 +642,54 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
647
|
642
|
/**
|
648
|
643
|
* Standard idle routine keeps the machine alive
|
649
|
644
|
*/
|
650
|
|
-void idle(
|
651
|
|
- #if ENABLED(ADVANCED_PAUSE_FEATURE)
|
652
|
|
- bool no_stepper_sleep/*=false*/
|
653
|
|
- #endif
|
654
|
|
-) {
|
|
645
|
+void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
|
|
646
|
+ // Handle Power-Loss Recovery
|
655
|
647
|
#if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
|
656
|
648
|
recovery.outage();
|
657
|
649
|
#endif
|
658
|
650
|
|
|
651
|
+ // Run StallGuard endstop checks
|
659
|
652
|
#if ENABLED(SPI_ENDSTOPS)
|
660
|
653
|
if (endstops.tmc_spi_homing.any
|
661
|
|
- #if ENABLED(IMPROVE_HOMING_RELIABILITY)
|
662
|
|
- && ELAPSED(millis(), sg_guard_period)
|
663
|
|
- #endif
|
664
|
|
- ) {
|
665
|
|
- for (uint8_t i = 4; i--;) // Read SGT 4 times per idle loop
|
|
654
|
+ && TERN1(IMPROVE_HOMING_RELIABILITY, ELAPSED(millis(), sg_guard_period))
|
|
655
|
+ ) LOOP_L_N(i, 4) // Read SGT 4 times per idle loop
|
666
|
656
|
if (endstops.tmc_spi_homing_check()) break;
|
667
|
|
- }
|
668
|
657
|
#endif
|
669
|
658
|
|
|
659
|
+ // Max7219 heartbeat, animation, etc.
|
670
|
660
|
#if ENABLED(MAX7219_DEBUG)
|
671
|
661
|
max7219.idle_tasks();
|
672
|
662
|
#endif
|
673
|
663
|
|
|
664
|
+ // Read Buttons and Update the LCD
|
674
|
665
|
ui.update();
|
675
|
666
|
|
|
667
|
+ // Announce Host Keepalive state (if any)
|
676
|
668
|
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
677
|
669
|
gcode.host_keepalive();
|
678
|
670
|
#endif
|
679
|
671
|
|
|
672
|
+ // Core Marlin activities
|
680
|
673
|
manage_inactivity(
|
681
|
674
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
682
|
675
|
no_stepper_sleep
|
683
|
676
|
#endif
|
684
|
677
|
);
|
685
|
678
|
|
|
679
|
+ // Manage heaters (and Watchdog)
|
686
|
680
|
thermalManager.manage_heater();
|
687
|
681
|
|
|
682
|
+ // Update the Print Job Timer state
|
688
|
683
|
#if ENABLED(PRINTCOUNTER)
|
689
|
684
|
print_job_timer.tick();
|
690
|
685
|
#endif
|
691
|
686
|
|
|
687
|
+ // Update the Beeper queue
|
692
|
688
|
#if USE_BEEPER
|
693
|
689
|
buzzer.tick();
|
694
|
690
|
#endif
|
695
|
691
|
|
|
692
|
+ // Run i2c Position Encoders
|
696
|
693
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
697
|
694
|
static millis_t i2cpem_next_update_ms;
|
698
|
695
|
if (planner.has_blocks_queued()) {
|
|
@@ -704,10 +701,12 @@ void idle(
|
704
|
701
|
}
|
705
|
702
|
#endif
|
706
|
703
|
|
|
704
|
+ // Run HAL idle tasks
|
707
|
705
|
#ifdef HAL_IDLETASK
|
708
|
706
|
HAL_idletask();
|
709
|
707
|
#endif
|
710
|
708
|
|
|
709
|
+ // Auto-report Temperatures / SD Status
|
711
|
710
|
#if HAS_AUTO_REPORTING
|
712
|
711
|
if (!gcode.autoreport_paused) {
|
713
|
712
|
#if ENABLED(AUTO_REPORT_TEMPERATURES)
|
|
@@ -719,14 +718,17 @@ void idle(
|
719
|
718
|
}
|
720
|
719
|
#endif
|
721
|
720
|
|
|
721
|
+ // Handle USB Flash Drive insert / remove
|
722
|
722
|
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
|
723
|
723
|
Sd2Card::idle();
|
724
|
724
|
#endif
|
725
|
725
|
|
|
726
|
+ // Update the Prusa MMU2
|
726
|
727
|
#if ENABLED(PRUSA_MMU2)
|
727
|
728
|
mmu2.mmu_loop();
|
728
|
729
|
#endif
|
729
|
730
|
|
|
731
|
+ // Handle Joystick jogging
|
730
|
732
|
#if ENABLED(POLL_JOG)
|
731
|
733
|
joystick.inject_jog_moves();
|
732
|
734
|
#endif
|