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

🚸 Retain power during Pause (#22227)

Cytown пре 4 година
родитељ
комит
61c48b8513

+ 1
- 1
Marlin/src/MarlinCore.cpp Прегледај датотеку

@@ -617,7 +617,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
617 617
 
618 618
   TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
619 619
 
620
-  TERN_(AUTO_POWER_CONTROL, powerManager.check());
620
+  TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused()));
621 621
 
622 622
   TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check());
623 623
 

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

@@ -91,7 +91,11 @@ extern bool wait_for_heatup;
91 91
     #define PSU_OFF_SOON() powerManager.power_off_soon()
92 92
   #else
93 93
     #define PSU_ON()     PSU_PIN_ON()
94
-    #define PSU_OFF()    PSU_PIN_OFF()
94
+    #if ENABLED(PS_OFF_SOUND)
95
+      #define PSU_OFF()  do{ BUZZ(1000, 659); PSU_PIN_OFF(); }while(0)
96
+    #else
97
+      #define PSU_OFF()  PSU_PIN_OFF()
98
+    #endif
95 99
     #define PSU_OFF_SOON PSU_OFF
96 100
   #endif
97 101
 #endif

+ 16
- 3
Marlin/src/feature/power.cpp Прегледај датотеку

@@ -50,6 +50,9 @@ Power powerManager;
50 50
 millis_t Power::lastPowerOn;
51 51
 
52 52
 bool Power::is_power_needed() {
53
+
54
+  if (printJobOngoing() || printingIsPaused()) return true;
55
+
53 56
   #if ENABLED(AUTO_POWER_FANS)
54 57
     FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true;
55 58
   #endif
@@ -110,9 +113,17 @@ bool Power::is_power_needed() {
110 113
   #define POWER_TIMEOUT 0
111 114
 #endif
112 115
 
113
-void Power::check() {
116
+void Power::check(const bool pause) {
117
+  static bool _pause = false;
114 118
   static millis_t nextPowerCheck = 0;
115
-  millis_t now = millis();
119
+  const millis_t now = millis();
120
+  #if POWER_TIMEOUT > 0
121
+    if (pause != _pause) {
122
+      lastPowerOn = now + !now;
123
+      _pause = pause;
124
+    }
125
+    if (pause) return;
126
+  #endif
116 127
   if (ELAPSED(now, nextPowerCheck)) {
117 128
     nextPowerCheck = now + 2500UL;
118 129
     if (is_power_needed())
@@ -123,7 +134,8 @@ void Power::check() {
123 134
 }
124 135
 
125 136
 void Power::power_on() {
126
-  lastPowerOn = millis();
137
+  const millis_t now = millis();
138
+  lastPowerOn = now + !now;
127 139
   if (!powersupply_on) {
128 140
     PSU_PIN_ON();
129 141
     safe_delay(PSU_POWERUP_DELAY);
@@ -152,6 +164,7 @@ void Power::power_off() {
152 164
 void Power::power_off_soon() {
153 165
   #if POWER_OFF_DELAY
154 166
     lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY);
167
+    //if (!lastPowerOn) ++lastPowerOn;
155 168
   #else
156 169
     power_off();
157 170
   #endif

+ 1
- 1
Marlin/src/feature/power.h Прегледај датотеку

@@ -29,7 +29,7 @@
29 29
 
30 30
 class Power {
31 31
   public:
32
-    static void check();
32
+    static void check(const bool pause);
33 33
     static void power_on();
34 34
     static void power_off();
35 35
     static void power_off_soon();

+ 5
- 2
Marlin/src/lcd/marlinui.h Прегледај датотеку

@@ -529,10 +529,13 @@ public:
529 529
 
530 530
     static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
531 531
 
532
-  #elif HAS_WIRED_LCD
532
+  #else
533 533
 
534 534
     static constexpr bool on_status_screen() { return true; }
535
-    FORCE_INLINE static void run_current_screen() { status_screen(); }
535
+
536
+    #if HAS_WIRED_LCD
537
+      FORCE_INLINE static void run_current_screen() { status_screen(); }
538
+    #endif
536 539
 
537 540
   #endif
538 541
 

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