mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
makeybutton: use smaller buffer for faster response
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
committed by
Daniel Esteban
parent
d0163c67f5
commit
1f54c7dd23
@@ -1,6 +1,6 @@
|
||||
package makeybutton
|
||||
|
||||
const bufferSize = 10
|
||||
const bufferSize = 6
|
||||
|
||||
// Buffer is a buffer to keep track of the most recent readings for a button.
|
||||
type Buffer struct {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (b *Button) Get() ButtonEvent {
|
||||
b.readings.Put(pressed)
|
||||
|
||||
switch {
|
||||
case pressed && avg > 0:
|
||||
case pressed && avg > -1 * bufferSize - 2:
|
||||
if b.state == Press {
|
||||
return NotChanged
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user