forked from Elara6331/itd
62 lines
1.1 KiB
Go
62 lines
1.1 KiB
Go
package fusefs
|
|
|
|
import (
|
|
"go.arsenm.dev/infinitime"
|
|
"context"
|
|
"strconv"
|
|
)
|
|
|
|
func converterU8(ctx context.Context, in <-chan uint8) <-chan []byte {
|
|
out := make(chan []byte, 2)
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <- ctx.Done():
|
|
return
|
|
case event := <-in:
|
|
out <- []byte(strconv.Itoa(int(event)) + "\n")
|
|
}
|
|
}
|
|
}()
|
|
return out
|
|
}
|
|
|
|
func converterU32(ctx context.Context, in <-chan uint32) <-chan []byte {
|
|
out := make(chan []byte, 2)
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <- ctx.Done():
|
|
return
|
|
case event := <-in:
|
|
out <- []byte(strconv.Itoa(int(event)) + "\n")
|
|
}
|
|
}
|
|
}()
|
|
return out
|
|
}
|
|
|
|
func converterMotionValues(ctx context.Context, in <-chan infinitime.MotionValues) <-chan []byte {
|
|
out := make(chan []byte, 2)
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <- ctx.Done():
|
|
return
|
|
case event := <-in:
|
|
out <- []byte(strconv.Itoa(int(event.X)) + " " + strconv.Itoa(int(event.Y)) + " " + strconv.Itoa(int(event.Z)) + "\n")
|
|
}
|
|
}
|
|
}()
|
|
return out
|
|
}
|
|
|
|
func converter1String(ctx context.Context, in string) <-chan []byte {
|
|
out := make(chan []byte, 2)
|
|
out <- []byte(in + "\n")
|
|
close(out)
|
|
return out
|
|
}
|
|
|
|
|