Browse Source

Update powersupply_on in power_on/off (#10015)

Fix #10004
Scott Lahteine 7 years ago
parent
commit
3c2bfa5e53
No account linked to committer's email address

+ 13
- 9
Marlin/src/Marlin.h View File

42
 
42
 
43
 void manage_inactivity(bool ignore_stepper_queue = false);
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
 #if HAS_X2_ENABLE
45
 #if HAS_X2_ENABLE
55
   #define  enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
46
   #define  enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
56
   #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
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
   extern int lpq_len;
211
   extern int lpq_len;
221
 #endif
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
 bool pin_is_protected(const pin_t pin);
227
 bool pin_is_protected(const pin_t pin);
224
 
228
 
225
 #if HAS_SUICIDE
229
 #if HAS_SUICIDE

+ 2
- 2
Marlin/src/feature/power.cpp View File

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

+ 0
- 3
Marlin/src/gcode/control/M80_M81.cpp View File

86
       tmc2208_init();
86
       tmc2208_init();
87
     #endif
87
     #endif
88
 
88
 
89
-    powersupply_on = true;
90
-
91
     #if ENABLED(ULTIPANEL)
89
     #if ENABLED(ULTIPANEL)
92
       LCD_MESSAGEPGM(WELCOME_MSG);
90
       LCD_MESSAGEPGM(WELCOME_MSG);
93
     #endif
91
     #endif
119
     suicide();
117
     suicide();
120
   #elif HAS_POWER_SWITCH
118
   #elif HAS_POWER_SWITCH
121
     PSU_OFF();
119
     PSU_OFF();
122
-    powersupply_on = false;
123
   #endif
120
   #endif
124
 
121
 
125
   #if ENABLED(ULTIPANEL)
122
   #if ENABLED(ULTIPANEL)

+ 0
- 4
Marlin/src/lcd/ultralcd.cpp View File

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

+ 1
- 1
Marlin/src/module/planner.cpp View File

894
 
894
 
895
   #if ENABLED(AUTO_POWER_CONTROL)
895
   #if ENABLED(AUTO_POWER_CONTROL)
896
     if (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS])
896
     if (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS])
897
-        powerManager.power_on();
897
+      powerManager.power_on();
898
   #endif
898
   #endif
899
 
899
 
900
   //enable active axes
900
   //enable active axes

Loading…
Cancel
Save