Procházet zdrojové kódy

Clean up UI declarations, apply TERN_

Scott Lahteine před 5 roky
rodič
revize
9f86dde195
3 změnil soubory, kde provedl 36 přidání a 41 odebrání
  1. 20
    18
      Marlin/src/MarlinCore.cpp
  2. 3
    13
      Marlin/src/MarlinCore.h
  3. 13
    10
      Marlin/src/lcd/ultralcd.h

+ 20
- 18
Marlin/src/MarlinCore.cpp Zobrazit soubor

@@ -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

+ 3
- 13
Marlin/src/MarlinCore.h Zobrazit soubor

@@ -38,19 +38,9 @@
38 38
 
39 39
 void stop();
40 40
 
41
-void idle(
42
-  #if ENABLED(ADVANCED_PAUSE_FEATURE)
43
-    bool no_stepper_sleep=false    // Pass true to keep steppers from timing out
44
-  #endif
45
-);
46
-
47
-inline void idle_no_sleep() {
48
-  idle(
49
-    #if ENABLED(ADVANCED_PAUSE_FEATURE)
50
-      true
51
-    #endif
52
-  );
53
-}
41
+// Pass true to keep steppers from timing out
42
+void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep=false));
43
+inline void idle_no_sleep() { idle(TERN_(ADVANCED_PAUSE_FEATURE, true)); }
54 44
 
55 45
 #if ENABLED(EXPERIMENTAL_I2CBUS)
56 46
   #include "feature/twibus.h"

+ 13
- 10
Marlin/src/lcd/ultralcd.h Zobrazit soubor

@@ -273,7 +273,16 @@ public:
273 273
 
274 274
   // LCD implementations
275 275
   static void clear_lcd();
276
-  static void init_lcd();
276
+
277
+  #if HAS_SPI_LCD
278
+    static bool detected();
279
+    static void init_lcd();
280
+    FORCE_INLINE static void refresh() { refresh(LCDVIEW_CLEAR_CALL_REDRAW); }
281
+  #else
282
+    static inline bool detected() { return true; }
283
+    static inline void init_lcd() {}
284
+    static inline void refresh()  {}
285
+  #endif
277 286
 
278 287
   #if HAS_DISPLAY
279 288
 
@@ -332,12 +341,9 @@ public:
332 341
 
333 342
       static millis_t next_button_update_ms;
334 343
 
335
-      static bool detected();
336
-
337 344
       static LCDViewAction lcdDrawUpdate;
338 345
       FORCE_INLINE static bool should_draw() { return bool(lcdDrawUpdate); }
339 346
       FORCE_INLINE static void refresh(const LCDViewAction type) { lcdDrawUpdate = type; }
340
-      FORCE_INLINE static void refresh() { refresh(LCDVIEW_CLEAR_CALL_REDRAW); }
341 347
 
342 348
       #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
343 349
         static void draw_custom_bootscreen(const uint8_t frame=0);
@@ -403,8 +409,6 @@ public:
403 409
 
404 410
       static void status_screen();
405 411
 
406
-    #else
407
-      static void refresh() {}
408 412
     #endif
409 413
 
410 414
     static bool get_blink();
@@ -418,13 +422,12 @@ public:
418 422
   #else // No LCD
419 423
 
420 424
     // Send status to host as a notification
421
-    void set_status(const char* message, const bool=false);
422
-    void set_status_P(PGM_P message, const int8_t=0);
423
-    void status_printf_P(const uint8_t, PGM_P message, ...);
425
+    static void set_status(const char* message, const bool=false);
426
+    static void set_status_P(PGM_P message, const int8_t=0);
427
+    static void status_printf_P(const uint8_t, PGM_P message, ...);
424 428
 
425 429
     static inline void init() {}
426 430
     static inline void update() {}
427
-    static inline void refresh() {}
428 431
     static inline void return_to_status() {}
429 432
     static inline void set_alert_status_P(PGM_P const) {}
430 433
     static inline void reset_status(const bool=false) {}

Loading…
Zrušit
Uložit