Pārlūkot izejas kodu

Debounce for Power-Loss pin

Scott Lahteine 4 gadus atpakaļ
vecāks
revīzija
1292ff76b3
1 mainītis faili ar 8 papildinājumiem un 2 dzēšanām
  1. 8
    2
      Marlin/src/feature/powerloss.h

+ 8
- 2
Marlin/src/feature/powerloss.h Parādīt failu

@@ -186,8 +186,14 @@ class PrintJobRecovery {
186 186
 
187 187
     #if PIN_EXISTS(POWER_LOSS)
188 188
       static inline void outage() {
189
-        if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE)
190
-          _outage();
189
+        static constexpr uint8_t OUTAGE_THRESHOLD = 3;
190
+        static uint8_t outage_counter = 0;
191
+        if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
192
+          outage_counter++;
193
+          if (outage_counter >= OUTAGE_THRESHOLD) _outage();
194
+        }
195
+        else
196
+          outage_counter = 0;
191 197
       }
192 198
     #endif
193 199
 

Notiek ielāde…
Atcelt
Saglabāt