Bläddra i källkod

Update powersupply_on in power_on/off (#10015)

Fix #10004
Scott Lahteine 6 år sedan
förälder
incheckning
3c2bfa5e53
Inget konto är kopplat till bidragsgivarens mejladress

+ 13
- 9
Marlin/src/Marlin.h Visa fil

@@ -42,15 +42,6 @@ void idle(
42 42
 
43 43
 void manage_inactivity(bool ignore_stepper_queue = false);
44 44
 
45
-// Auto Power Control
46
-#if ENABLED(AUTO_POWER_CONTROL)
47
-  #define PSU_ON()  powerManager.power_on()
48
-  #define PSU_OFF() powerManager.power_off()
49
-#else
50
-  #define PSU_ON()  OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE)
51
-  #define PSU_OFF() OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP)
52
-#endif
53
-
54 45
 #if HAS_X2_ENABLE
55 46
   #define  enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
56 47
   #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
@@ -220,6 +211,19 @@ extern millis_t max_inactive_time, stepper_inactive_time;
220 211
   extern int lpq_len;
221 212
 #endif
222 213
 
214
+#if HAS_POWER_SWITCH
215
+  extern bool powersupply_on;
216
+  #define PSU_PIN_ON()  do{ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); powersupply_on = true; }while(0)
217
+  #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); powersupply_on = false; }while(0)
218
+  #if ENABLED(AUTO_POWER_CONTROL)
219
+    #define PSU_ON()  powerManager.power_on()
220
+    #define PSU_OFF() powerManager.power_off()
221
+  #else
222
+    #define PSU_ON()  PSU_PIN_ON()
223
+    #define PSU_OFF() PSU_PIN_OFF()
224
+  #endif
225
+#endif
226
+
223 227
 bool pin_is_protected(const pin_t pin);
224 228
 
225 229
 #if HAS_SUICIDE

+ 2
- 2
Marlin/src/feature/power.cpp Visa fil

@@ -87,11 +87,11 @@ void Power::check() {
87 87
 
88 88
 void Power::power_on() {
89 89
   lastPowerOn = millis();
90
-  OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE);
90
+  PSU_PIN_ON();
91 91
 }
92 92
 
93 93
 void Power::power_off() {
94
-  OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
94
+  PSU_PIN_OFF();
95 95
 }
96 96
 
97 97
 #endif // AUTO_POWER_CONTROL

+ 0
- 3
Marlin/src/gcode/control/M80_M81.cpp Visa fil

@@ -86,8 +86,6 @@
86 86
       tmc2208_init();
87 87
     #endif
88 88
 
89
-    powersupply_on = true;
90
-
91 89
     #if ENABLED(ULTIPANEL)
92 90
       LCD_MESSAGEPGM(WELCOME_MSG);
93 91
     #endif
@@ -119,7 +117,6 @@ void GcodeSuite::M81() {
119 117
     suicide();
120 118
   #elif HAS_POWER_SWITCH
121 119
     PSU_OFF();
122
-    powersupply_on = false;
123 120
   #endif
124 121
 
125 122
   #if ENABLED(ULTIPANEL)

+ 0
- 4
Marlin/src/lcd/ultralcd.cpp Visa fil

@@ -175,10 +175,6 @@ uint16_t max_display_update_time = 0;
175 175
     #define TALL_FONT_CORRECTION 0
176 176
   #endif
177 177
 
178
-  #if HAS_POWER_SWITCH
179
-    extern bool powersupply_on;
180
-  #endif
181
-
182 178
   bool no_reentry = false;
183 179
   constexpr int8_t menu_bottom = LCD_HEIGHT - (TALL_FONT_CORRECTION);
184 180
 

+ 1
- 1
Marlin/src/module/planner.cpp Visa fil

@@ -894,7 +894,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
894 894
 
895 895
   #if ENABLED(AUTO_POWER_CONTROL)
896 896
     if (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS])
897
-        powerManager.power_on();
897
+      powerManager.power_on();
898 898
   #endif
899 899
 
900 900
   //enable active axes

Laddar…
Avbryt
Spara