Преглед изворни кода

Clean up UI declarations, apply TERN_

Scott Lahteine пре 5 година
родитељ
комит
9f86dde195
3 измењених фајлова са 36 додато и 41 уклоњено
  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 Прегледај датотеку

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

+ 3
- 13
Marlin/src/MarlinCore.h Прегледај датотеку

38
 
38
 
39
 void stop();
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
 #if ENABLED(EXPERIMENTAL_I2CBUS)
45
 #if ENABLED(EXPERIMENTAL_I2CBUS)
56
   #include "feature/twibus.h"
46
   #include "feature/twibus.h"

+ 13
- 10
Marlin/src/lcd/ultralcd.h Прегледај датотеку

273
 
273
 
274
   // LCD implementations
274
   // LCD implementations
275
   static void clear_lcd();
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
   #if HAS_DISPLAY
287
   #if HAS_DISPLAY
279
 
288
 
332
 
341
 
333
       static millis_t next_button_update_ms;
342
       static millis_t next_button_update_ms;
334
 
343
 
335
-      static bool detected();
336
-
337
       static LCDViewAction lcdDrawUpdate;
344
       static LCDViewAction lcdDrawUpdate;
338
       FORCE_INLINE static bool should_draw() { return bool(lcdDrawUpdate); }
345
       FORCE_INLINE static bool should_draw() { return bool(lcdDrawUpdate); }
339
       FORCE_INLINE static void refresh(const LCDViewAction type) { lcdDrawUpdate = type; }
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
       #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
348
       #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
343
         static void draw_custom_bootscreen(const uint8_t frame=0);
349
         static void draw_custom_bootscreen(const uint8_t frame=0);
403
 
409
 
404
       static void status_screen();
410
       static void status_screen();
405
 
411
 
406
-    #else
407
-      static void refresh() {}
408
     #endif
412
     #endif
409
 
413
 
410
     static bool get_blink();
414
     static bool get_blink();
418
   #else // No LCD
422
   #else // No LCD
419
 
423
 
420
     // Send status to host as a notification
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
     static inline void init() {}
429
     static inline void init() {}
426
     static inline void update() {}
430
     static inline void update() {}
427
-    static inline void refresh() {}
428
     static inline void return_to_status() {}
431
     static inline void return_to_status() {}
429
     static inline void set_alert_status_P(PGM_P const) {}
432
     static inline void set_alert_status_P(PGM_P const) {}
430
     static inline void reset_status(const bool=false) {}
433
     static inline void reset_status(const bool=false) {}

Loading…
Откажи
Сачувај