Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
dbb10e7c7d
|
@ -68,13 +68,18 @@ void ButtonDebounce::updateConfiguration () {
|
||||||
@returns true if the button is pressed, and will not return true again within the set timeout
|
@returns true if the button is pressed, and will not return true again within the set timeout
|
||||||
*/
|
*/
|
||||||
bool ButtonDebounce::readPinEvent() {
|
bool ButtonDebounce::readPinEvent() {
|
||||||
|
readValue = false;
|
||||||
|
return readPinState();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ButtonDebounce::readPinState() {
|
||||||
if (!pin) {
|
if (!pin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
efitick_t timeNow = getTimeNowNt();
|
efitick_t timeNow = getTimeNowNt();
|
||||||
// If it's been less than the threshold since we were last called
|
// If it's been less than the threshold since we were last called
|
||||||
if ((timeNow - timeLast) < threshold) {
|
if ((timeNow - timeLast) < threshold) {
|
||||||
return false;
|
return readValue;
|
||||||
}
|
}
|
||||||
// readValue is a class variable, so it needs to be reset.
|
// readValue is a class variable, so it needs to be reset.
|
||||||
// We don't actually need it to be a class variable in this method,
|
// We don't actually need it to be a class variable in this method,
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
void init(int t, brain_pin_e *p, pin_input_mode_e *m);
|
void init(int t, brain_pin_e *p, pin_input_mode_e *m);
|
||||||
void updateConfiguration();
|
void updateConfiguration();
|
||||||
bool readPinEvent();
|
bool readPinEvent();
|
||||||
|
bool readPinState();
|
||||||
static void updateConfigurationList();
|
static void updateConfigurationList();
|
||||||
private:
|
private:
|
||||||
int threshold;
|
int threshold;
|
||||||
|
|
Loading…
Reference in New Issue