Add an auto-measure toggle with a cable length range, and console keys through the harness

This commit is contained in:
flamingcow
2026-08-30 19:10:00 -07:00
parent 36c2ff34fe
commit 5a74fe0c76
6 changed files with 188 additions and 41 deletions
+6 -9
View File
@@ -160,11 +160,11 @@ func watchTouch(w, h int) (*touchState, error) {
return state, nil
}
// Delivers a value every time space is pressed. Puts the terminal in
// non-canonical mode so the keypress arrives without waiting for a newline,
// and returns a function that restores the original settings.
func watchSpace() (<-chan struct{}, func()) {
ch := make(chan struct{}, 1)
// Delivers each key as it is pressed. Puts the terminal in non-canonical mode
// so keypresses arrive without waiting for a newline, and returns a function
// that restores the original settings.
func watchKeys() (<-chan byte, func()) {
ch := make(chan byte, 8)
restore := func() {}
fd := int(os.Stdin.Fd())
@@ -187,11 +187,8 @@ func watchSpace() (<-chan struct{}, func()) {
return
}
for _, b := range buf[:n] {
if b != ' ' {
continue
}
select {
case ch <- struct{}{}:
case ch <- b:
default:
}
}