瀏覽代碼

Configurable kill pin state

Co-Authored-By: AbdullahGheith <abdullahgheith@users.noreply.github.com>
Scott Lahteine 4 年之前
父節點
當前提交
852a8d6685
共有 3 個文件被更改,包括 17 次插入5 次删除
  1. 8
    4
      Marlin/src/MarlinCore.cpp
  2. 7
    0
      Marlin/src/MarlinCore.h
  3. 2
    1
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+ 8
- 4
Marlin/src/MarlinCore.cpp 查看文件

245
 
245
 
246
 void setup_killpin() {
246
 void setup_killpin() {
247
   #if HAS_KILL
247
   #if HAS_KILL
248
-    SET_INPUT_PULLUP(KILL_PIN);
248
+    #if KILL_PIN_STATE
249
+      SET_INPUT_PULLDOWN(KILL_PIN);
250
+    #else
251
+      SET_INPUT_PULLUP(KILL_PIN);
252
+    #endif
249
   #endif
253
   #endif
250
 }
254
 }
251
 
255
 
496
     // -------------------------------------------------------------------------------
500
     // -------------------------------------------------------------------------------
497
     static int killCount = 0;   // make the inactivity button a bit less responsive
501
     static int killCount = 0;   // make the inactivity button a bit less responsive
498
     const int KILL_DELAY = 750;
502
     const int KILL_DELAY = 750;
499
-    if (!READ(KILL_PIN))
503
+    if (kill_state())
500
       killCount++;
504
       killCount++;
501
     else if (killCount > 0)
505
     else if (killCount > 0)
502
       killCount--;
506
       killCount--;
770
   #if HAS_KILL
774
   #if HAS_KILL
771
 
775
 
772
     // Wait for kill to be released
776
     // Wait for kill to be released
773
-    while (!READ(KILL_PIN)) watchdog_refresh();
777
+    while (kill_state()) watchdog_refresh();
774
 
778
 
775
     // Wait for kill to be pressed
779
     // Wait for kill to be pressed
776
-    while (READ(KILL_PIN)) watchdog_refresh();
780
+    while (!kill_state()) watchdog_refresh();
777
 
781
 
778
     void (*resetFunc)() = 0;      // Declare resetFunc() at address 0
782
     void (*resetFunc)() = 0;      // Declare resetFunc() at address 0
779
     resetFunc();                  // Jump to address 0
783
     resetFunc();                  // Jump to address 0

+ 7
- 0
Marlin/src/MarlinCore.h 查看文件

110
   inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_INVERTING); }
110
   inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_INVERTING); }
111
 #endif
111
 #endif
112
 
112
 
113
+#if HAS_KILL
114
+  #ifndef KILL_PIN_STATE
115
+    #define KILL_PIN_STATE LOW
116
+  #endif
117
+  inline bool kill_state() { return READ(KILL_PIN) == KILL_PIN_STATE; }
118
+#endif
119
+
113
 #if ENABLED(G29_RETRY_AND_RECOVER)
120
 #if ENABLED(G29_RETRY_AND_RECOVER)
114
   void event_probe_recover();
121
   void event_probe_recover();
115
   void event_probe_failure();
122
   void event_probe_failure();

+ 2
- 1
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp 查看文件

1683
       SERIAL_EOL();
1683
       SERIAL_EOL();
1684
 
1684
 
1685
       #if HAS_KILL
1685
       #if HAS_KILL
1686
-        SERIAL_ECHOLNPAIR("Kill pin on :", int(KILL_PIN), "  state:", READ(KILL_PIN));
1686
+        SERIAL_ECHOLNPAIR("Kill pin on :", int(KILL_PIN), "  state:", int(kill_state()));
1687
       #endif
1687
       #endif
1688
+
1688
       SERIAL_EOL();
1689
       SERIAL_EOL();
1689
       serial_delay(50);
1690
       serial_delay(50);
1690
 
1691
 

Loading…
取消
儲存