Fix debounce (#1814)

* 1,2,4,7,9

* 6

* fix type mismatch

* change field

* comment

* Revert "comment"

This reverts commit f7ce8ed48d015490ed82d692270198817569b5a3.

* Revert "Revert "comment""

This reverts commit 99f2d5cadcbf444bf58acf9e57a6fed61355d5be.

* Revert "change field"

This reverts commit 55ec050cd947696cdffccae6b29fe48d95ab5f17.

* rename var

* comments

* use func in init

* default values

* remove redundant check

* check

* use bool

* mark false when done

* pointer

* check GPIO_UNASSIGNED

* wat

* merge carnage

* oops, accidentally downgraded submodule
This commit is contained in:
David Holdeman 2020-09-21 17:25:24 -05:00 committed by GitHub
parent 2d771018e8
commit 181113ff17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -56,13 +56,17 @@ void ButtonDebounce::stopConfiguration () {
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */ #endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
#ifndef EFI_UNIT_TEST #ifndef EFI_UNIT_TEST
brain_pin_markUnused(active_pin); brain_pin_markUnused(active_pin);
needsInit = true;
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */
} }
} }
void ButtonDebounce::startConfiguration () { void ButtonDebounce::startConfiguration () {
#ifndef EFI_UNIT_TEST #ifndef EFI_UNIT_TEST
efiSetPadMode("Button", *m_pin, getInputMode(*m_mode)); if (needsInit) {
efiSetPadMode("Button", *m_pin, getInputMode(*m_mode));
needsInit = false;
}
#endif #endif
active_pin = *m_pin; active_pin = *m_pin;
active_mode = *m_mode; active_mode = *m_mode;
@ -77,7 +81,7 @@ bool ButtonDebounce::readPinEvent() {
} }
bool ButtonDebounce::readPinState() { bool ButtonDebounce::readPinState() {
if (!m_pin) { if (*m_pin == GPIO_UNASSIGNED) {
return false; return false;
} }
efitick_t timeNow = getTimeNowNt(); efitick_t timeNow = getTimeNowNt();

View File

@ -33,4 +33,5 @@ private:
bool initialized = false; bool initialized = false;
ButtonDebounce *nextDebounce = nullptr; ButtonDebounce *nextDebounce = nullptr;
static ButtonDebounce* s_firstDebounce; static ButtonDebounce* s_firstDebounce;
bool needsInit = false;
}; };