Bladeren bron

Add power-on/off G-code options (#19837)

Co-authored-by: Chris <chris@chrisnovoa.com>
Scott Lahteine 4 jaren geleden
bovenliggende
commit
7d64de646a
No account linked to committer's email address
2 gewijzigde bestanden met toevoegingen van 16 en 1 verwijderingen
  1. 3
    0
      Marlin/Configuration.h
  2. 13
    1
      Marlin/src/feature/power.cpp

+ 3
- 0
Marlin/Configuration.h Bestand weergeven

335
   //#define PSU_DEFAULT_OFF         // Keep power off until enabled directly with M80
335
   //#define PSU_DEFAULT_OFF         // Keep power off until enabled directly with M80
336
   //#define PSU_POWERUP_DELAY 250   // (ms) Delay for the PSU to warm up to full power
336
   //#define PSU_POWERUP_DELAY 250   // (ms) Delay for the PSU to warm up to full power
337
 
337
 
338
+  //#define PSU_POWERUP_GCODE  "M355 S1"  // G-code to run after power-on (e.g., case light on)
339
+  //#define PSU_POWEROFF_GCODE "M355 S0"  // G-code to run before power-off (e.g., case light off)
340
+
338
   //#define AUTO_POWER_CONTROL      // Enable automatic control of the PS_ON pin
341
   //#define AUTO_POWER_CONTROL      // Enable automatic control of the PS_ON pin
339
   #if ENABLED(AUTO_POWER_CONTROL)
342
   #if ENABLED(AUTO_POWER_CONTROL)
340
     #define AUTO_POWER_FANS         // Turn on PSU if fans need power
343
     #define AUTO_POWER_FANS         // Turn on PSU if fans need power

+ 13
- 1
Marlin/src/feature/power.cpp Bestand weergeven

33
 #include "../module/stepper/indirection.h"
33
 #include "../module/stepper/indirection.h"
34
 #include "../MarlinCore.h"
34
 #include "../MarlinCore.h"
35
 
35
 
36
+#if defined(PSU_POWERUP_GCODE) || defined(PSU_POWEROFF_GCODE)
37
+  #include "../gcode/gcode.h"
38
+#endif
39
+
36
 #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN)
40
 #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN)
37
   #include "controllerfan.h"
41
   #include "controllerfan.h"
38
 #endif
42
 #endif
107
     safe_delay(PSU_POWERUP_DELAY);
111
     safe_delay(PSU_POWERUP_DELAY);
108
     restore_stepper_drivers();
112
     restore_stepper_drivers();
109
     TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY));
113
     TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY));
114
+    #ifdef PSU_POWERUP_GCODE
115
+      GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWERUP_GCODE));
116
+    #endif
110
   }
117
   }
111
 }
118
 }
112
 
119
 
113
 void Power::power_off() {
120
 void Power::power_off() {
114
-  if (powersupply_on) PSU_PIN_OFF();
121
+  if (powersupply_on) {
122
+    #ifdef PSU_POWEROFF_GCODE
123
+      GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE));
124
+    #endif
125
+  	PSU_PIN_OFF();
126
+  }
115
 }
127
 }
116
 
128
 
117
 #endif // AUTO_POWER_CONTROL
129
 #endif // AUTO_POWER_CONTROL

Laden…
Annuleren
Opslaan