瀏覽代碼

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

Co-authored-by: Chris <chris@chrisnovoa.com>
Scott Lahteine 4 年之前
父節點
當前提交
7d64de646a
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 16 行新增1 行删除
  1. 3
    0
      Marlin/Configuration.h
  2. 13
    1
      Marlin/src/feature/power.cpp

+ 3
- 0
Marlin/Configuration.h 查看文件

@@ -335,6 +335,9 @@
335 335
   //#define PSU_DEFAULT_OFF         // Keep power off until enabled directly with M80
336 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 341
   //#define AUTO_POWER_CONTROL      // Enable automatic control of the PS_ON pin
339 342
   #if ENABLED(AUTO_POWER_CONTROL)
340 343
     #define AUTO_POWER_FANS         // Turn on PSU if fans need power

+ 13
- 1
Marlin/src/feature/power.cpp 查看文件

@@ -33,6 +33,10 @@
33 33
 #include "../module/stepper/indirection.h"
34 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 40
 #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN)
37 41
   #include "controllerfan.h"
38 42
 #endif
@@ -107,11 +111,19 @@ void Power::power_on() {
107 111
     safe_delay(PSU_POWERUP_DELAY);
108 112
     restore_stepper_drivers();
109 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 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 129
 #endif // AUTO_POWER_CONTROL

Loading…
取消
儲存