mirror of
https://github.com/clockworkpi/uConsole.git
synced 2026-03-27 22:32:53 +01:00
add keyboard source code
This commit is contained in:
23
Code/uconsole_keyboard/debouncer.ino
Normal file
23
Code/uconsole_keyboard/debouncer.ino
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user