From 772ac6a8d811d03f95385bac497814989cabb4d4 Mon Sep 17 00:00:00 2001 From: Drew Bowering Date: Tue, 2 Apr 2024 16:53:35 -0600 Subject: [PATCH] add select block to button press channel - outchan is unbuffered, so drop the message if there's already one sitting there. --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 911bbb2..0cf3693 100644 --- a/main.go +++ b/main.go @@ -211,7 +211,10 @@ func delayChan(inchan <-chan bool, outchan chan<- bool) { now := time.Now() if now.Sub(last) > pressdelay { last = now - outchan <- val + select { + case outchan <- val: + default: + } } } }