Add an auto-measure toggle with a cable length range, and console keys through the harness
This commit is contained in:
@@ -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:
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user