@@ -443,7 +443,6 @@ void startOrResumeJob() {
443
443
444
444
/* *
445
445
* Minimal management of Marlin's core activities:
446
- * - Check for Filament Runout
447
446
* - Keep the command buffer full
448
447
* - Check for maximum inactive time between commands
449
448
* - Check for maximum inactive time between stepper commands
@@ -454,13 +453,8 @@ void startOrResumeJob() {
454
453
* - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
455
454
* - Pulse FET_SAFETY_PIN if it exists
456
455
*/
457
-
458
456
inline void manage_inactivity (const bool ignore_stepper_queue=false ) {
459
457
460
- #if HAS_FILAMENT_SENSOR
461
- runout.run ();
462
- #endif
463
-
464
458
if (queue.length < BUFSIZE) queue.get_available_commands ();
465
459
466
460
const millis_t ms = millis ();
@@ -644,9 +638,53 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
644
638
}
645
639
646
640
/* *
647
- * Standard idle routine keeps the machine alive
641
+ * Standard idle routine keeps the machine alive:
642
+ * - Core Marlin activities
643
+ * - Manage heaters (and Watchdog)
644
+ * - Max7219 heartbeat, animation, etc.
645
+ *
646
+ * Only after setup() is complete:
647
+ * - Handle filament runout sensors
648
+ * - Run HAL idle tasks
649
+ * - Handle Power-Loss Recovery
650
+ * - Run StallGuard endstop checks
651
+ * - Handle SD Card insert / remove
652
+ * - Handle USB Flash Drive insert / remove
653
+ * - Announce Host Keepalive state (if any)
654
+ * - Update the Print Job Timer state
655
+ * - Update the Beeper queue
656
+ * - Read Buttons and Update the LCD
657
+ * - Run i2c Position Encoders
658
+ * - Auto-report Temperatures / SD Status
659
+ * - Update the Prusa MMU2
660
+ * - Handle Joystick jogging
648
661
*/
649
662
void idle (TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/* =false*/ )) {
663
+
664
+ // Core Marlin activities
665
+ manage_inactivity (TERN_ (ADVANCED_PAUSE_FEATURE, no_stepper_sleep));
666
+
667
+ // Manage Heaters (and Watchdog)
668
+ thermalManager.manage_heater ();
669
+
670
+ // Max7219 heartbeat, animation, etc
671
+ #if ENABLED(MAX7219_DEBUG)
672
+ max7219.idle_tasks ();
673
+ #endif
674
+
675
+ // Return if setup() isn't completed
676
+ if (marlin_state == MF_INITIALIZING) return ;
677
+
678
+ // Handle filament runout sensors
679
+ #if HAS_FILAMENT_SENSOR
680
+ runout.run ();
681
+ #endif
682
+
683
+ // Run HAL idle tasks
684
+ #ifdef HAL_IDLETASK
685
+ HAL_idletask ();
686
+ #endif
687
+
650
688
// Handle Power-Loss Recovery
651
689
#if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
652
690
recovery.outage ();
@@ -660,29 +698,21 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
660
698
if (endstops.tmc_spi_homing_check ()) break ;
661
699
#endif
662
700
663
- // Max7219 heartbeat, animation, etc.
664
- #if ENABLED(MAX7219_DEBUG )
665
- max7219. idle_tasks ();
701
+ // Handle SD Card insert / remove
702
+ #if ENABLED(SDSUPPORT )
703
+ card. manage_media ();
666
704
#endif
667
705
668
- // Read Buttons and Update the LCD
669
- ui.update ();
706
+ // Handle USB Flash Drive insert / remove
707
+ #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
708
+ Sd2Card::idle ();
709
+ #endif
670
710
671
711
// Announce Host Keepalive state (if any)
672
712
#if ENABLED(HOST_KEEPALIVE_FEATURE)
673
713
gcode.host_keepalive ();
674
714
#endif
675
715
676
- // Core Marlin activities
677
- manage_inactivity (
678
- #if ENABLED(ADVANCED_PAUSE_FEATURE)
679
- no_stepper_sleep
680
- #endif
681
- );
682
-
683
- // Manage heaters (and Watchdog)
684
- thermalManager.manage_heater ();
685
-
686
716
// Update the Print Job Timer state
687
717
#if ENABLED(PRINTCOUNTER)
688
718
print_job_timer.tick ();
@@ -693,6 +723,9 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
693
723
buzzer.tick ();
694
724
#endif
695
725
726
+ // Read Buttons and Update the LCD
727
+ ui.update ();
728
+
696
729
// Run i2c Position Encoders
697
730
#if ENABLED(I2C_POSITION_ENCODERS)
698
731
static millis_t i2cpem_next_update_ms;
@@ -705,11 +738,6 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
705
738
}
706
739
#endif
707
740
708
- // Run HAL idle tasks
709
- #ifdef HAL_IDLETASK
710
- HAL_idletask ();
711
- #endif
712
-
713
741
// Auto-report Temperatures / SD Status
714
742
#if HAS_AUTO_REPORTING
715
743
if (!gcode.autoreport_paused ) {
@@ -722,11 +750,6 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
722
750
}
723
751
#endif
724
752
725
- // Handle USB Flash Drive insert / remove
726
- #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
727
- Sd2Card::idle ();
728
- #endif
729
-
730
753
// Update the Prusa MMU2
731
754
#if ENABLED(PRUSA_MMU2)
732
755
mmu2.mmu_loop ();
@@ -983,8 +1006,8 @@ void setup() {
983
1006
SETUP_RUN (ui.show_bootscreen ());
984
1007
#endif
985
1008
986
- #if ENABLED (SDSUPPORT) && defined(SDCARD_CONNECTION) && !SD_CONNECTION_IS(LCD )
987
- SETUP_RUN (card.mount ()); // Mount onboard / custom SD card before settings. first_load
1009
+ #if BOTH (SDSUPPORT, SDCARD_EEPROM_EMULATION )
1010
+ SETUP_RUN (card.mount ()); // Mount media with settings before first_load
988
1011
#endif
989
1012
990
1013
SETUP_RUN (settings.first_load ()); // Load data from EEPROM if available (or use defaults)
@@ -1151,10 +1174,6 @@ void setup() {
1151
1174
queue.inject_P (PSTR (STARTUP_COMMANDS));
1152
1175
#endif
1153
1176
1154
- #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
1155
- SETUP_RUN (card.beginautostart ());
1156
- #endif
1157
-
1158
1177
#if ENABLED(HOST_PROMPT_SUPPORT)
1159
1178
SETUP_RUN (host_action_prompt_end ());
1160
1179
#endif
0 commit comments