一个写在GO中的示波器(支持串行输入和音频输入)

123 阅读1分钟

示波器

一个用GO语言编写的示波器 支持串行输入和音频输入

安装

go get github.com/suutaku/goosilloscope
go build

使用方法

作为一个工具:

Usage: goocilloscope COMMAND [arg...]

A simple ocilloscope writen in Go
               
Commands:      
  source       need specific a signnal source
               
Run 'goocilloscope COMMAND --help' for more information on a command.

作为一个图书馆:

ctx := context.Background()
	conn := connector.NewPortAudio(ctx)
	rd := myrender.NewRender(ctx, 1280, 640, conn)
	rd.Start()	

其他的

串行端口默认用: 分割接收的字节,你可以像这样设置你的成本数据清洗回调:

func washData(input []byte) []float32 {

	tmp := strings.Split(string(input), ":")
	res := make([]float32, 0)
	for i := 0; i < len(tmp); i++ {
		tmp64, _ := strconv.ParseFloat(string(tmp[i]), 32)
		res = append(res, float32(tmp64))
	}
	return res
}
conn := connector.NewSerial(ctx, "/dev/usb-serial", 9600)
conn.SetWashCallback(washData)

对于植入另一个输入源,请看:

$REPO/connector/connector.go