Skip to content

Commit 70dca80

Browse files
committed
Debouncer can be timed on microsecond bases.
1 parent 444ca37 commit 70dca80

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: Debouncer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void Debouncer::pciHandleInterrupt(byte vect) {
5959
// -- After pin change we have the opposite level, lets start the bouncing timespan.
6060
this->_state += 1;
6161
this->lastCallTimeMicros = micros();
62-
this->setPeriodMs(this->debounceDelayMs);
62+
this->periodMicros = this->debounceDelayMicros;
6363
}
6464
}
6565
}

Diff for: Debouncer.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
#include <SoftTimer.h>
3131
#include <DelayRun.h>
32-
//#include <PciListener.h>
33-
#include "../PciManager/PciListener.h"
32+
#include <PciListener.h>
33+
//#include "../PciManager/PciListener.h"
3434
#include <Arduino.h>
3535

3636
#define MODE_OPEN_ON_PUSH HIGH
@@ -42,7 +42,7 @@
4242
#define STATE_ONOFF_BOUNCING 3
4343

4444
/** We say that 50 milliseconds are enough for the signal to stabilize. */
45-
#define DEFAULT_DEBOUNCE_DELAY_MILLIS 50
45+
#define DEFAULT_DEBOUNCE_DELAY_MICROS 50000
4646

4747
class Debouncer : public PciListener, public Task
4848
{
@@ -69,8 +69,8 @@ class Debouncer : public PciListener, public Task
6969
/**
7070
* Change the delay of the bouncing time-span. The default value is DEFAULT_DEBOUNCE_DELAY_MILLIS;
7171
*/
72-
unsigned long debounceDelayMs = DEFAULT_DEBOUNCE_DELAY_MILLIS;
73-
boolean setDebounceDelayMs(unsigned long debounceDelayMs) { this->debounceDelayMs = debounceDelayMs; return true; };
72+
unsigned long debounceDelayMicros = DEFAULT_DEBOUNCE_DELAY_MICROS;
73+
boolean setDebounceDelayMs(unsigned long debounceDelayMs) { this->debounceDelayMicros = debounceDelayMs * 1000; return true; };
7474
private:
7575
int _pin;
7676
int _onLevel;

0 commit comments

Comments
 (0)