borrwoed a lot code from https://github.com/foriequal0/devterm_keyboard in order to optimize the trackball

This commit is contained in:
cuu
2021-12-16 20:41:37 +08:00
parent 1a1be01dbb
commit b1370d2124
18 changed files with 538 additions and 118 deletions

View File

@@ -0,0 +1,23 @@
#include "debouncer.h"
Debouncer::Debouncer()
: timeout(0)
{
}
void Debouncer::updateTime(millis_t delta) {
if (timeout > delta) {
timeout -= delta;
} else {
timeout = 0;
}
}
bool Debouncer::sample(bool value) {
if (value || timeout == 0) {
timeout = DEBOUNCE_MS;
return true;
}
return false;
}