Compare commits
3 Commits
390086788f
...
fa469ac9b9
Author | SHA1 | Date | |
---|---|---|---|
fa469ac9b9 | |||
c6a4d14f34 | |||
fe2dadfa1f |
6
go.mod
6
go.mod
|
@ -3,7 +3,7 @@ module git.wow.st/gmp/hrm
|
|||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20191101175813-af353822fa5e
|
||||
git.wow.st/gmp/ble v0.0.0-20191101185903-829baedeac2b
|
||||
gopkg.in/yaml.v2 v2.2.4
|
||||
gioui.org v0.0.0-20191126175243-2ca2e5462f16
|
||||
git.wow.st/gmp/ble v0.0.0-20191127154437-321b94a48682
|
||||
gopkg.in/yaml.v2 v2.2.7
|
||||
)
|
||||
|
|
18
go.sum
18
go.sum
|
@ -1,14 +1,8 @@
|
|||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
gioui.org v0.0.0-20191031200634-4e71f195ab51 h1:Epxo/e6oPvbDMMB8rrpmUlBe6ELeDpRuLzFUGfT6kJM=
|
||||
gioui.org v0.0.0-20191031200634-4e71f195ab51/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
|
||||
gioui.org v0.0.0-20191101175813-af353822fa5e h1:8NpYJwhzVg0A34MikFWRS65/PoYcluBGWZ3fgy8iXIg=
|
||||
gioui.org v0.0.0-20191101175813-af353822fa5e/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
|
||||
git.wow.st/gmp/ble v0.0.0-20191030160916-4e4c07169707 h1:46SbpM1pnBe+VNUSohkKz16s/8BFY2+hzRLZEiRR1Y0=
|
||||
git.wow.st/gmp/ble v0.0.0-20191030160916-4e4c07169707/go.mod h1:MiidWVofL6FTtRokC5JGBdVUhKyvZtnia5noj08r944=
|
||||
git.wow.st/gmp/ble v0.0.0-20191101184817-0ab45a1d9d54 h1:Tdomh1qilIgDXWU+CksM6682BKomGKFyw3+JXcP0LLo=
|
||||
git.wow.st/gmp/ble v0.0.0-20191101184817-0ab45a1d9d54/go.mod h1:MiidWVofL6FTtRokC5JGBdVUhKyvZtnia5noj08r944=
|
||||
git.wow.st/gmp/ble v0.0.0-20191101185903-829baedeac2b h1:ccSukYa0YCYZEXaweXXf/103edYKBECsQjExQBTH0vE=
|
||||
git.wow.st/gmp/ble v0.0.0-20191101185903-829baedeac2b/go.mod h1:MiidWVofL6FTtRokC5JGBdVUhKyvZtnia5noj08r944=
|
||||
gioui.org v0.0.0-20191126175243-2ca2e5462f16 h1:p31rtmKm51xpj2QtqGNlljAyHEP1oStU8MDRl2Dv7Gs=
|
||||
gioui.org v0.0.0-20191126175243-2ca2e5462f16/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
|
||||
git.wow.st/gmp/ble v0.0.0-20191127154437-321b94a48682 h1:8b9kt3AbWqpJwLukguXBGyUbidbgxpxrToUSX5rUSDE=
|
||||
git.wow.st/gmp/ble v0.0.0-20191127154437-321b94a48682/go.mod h1:Fh9BYe6AckJS7dzv2LFPr/wSYVMROUwmtc01VyQmuZo=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
|
@ -34,5 +28,5 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|||
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
14
main.go
14
main.go
|
@ -60,9 +60,12 @@ func saveConfig() {
|
|||
}
|
||||
|
||||
func hrDecode(x []byte) int {
|
||||
if len(x) < 4 {
|
||||
return 0
|
||||
}
|
||||
flags := x[0]
|
||||
if flags&0x80 != 0 { // uint16 format
|
||||
return int(binary.BigEndian.Uint16(x[1:2]))
|
||||
return int(binary.BigEndian.Uint16(x[1:3]))
|
||||
} else {
|
||||
return int(x[1])
|
||||
}
|
||||
|
@ -73,9 +76,9 @@ func eventloop() {
|
|||
app.Size(unit.Dp(400), unit.Dp(400)),
|
||||
app.Title("HRM"),
|
||||
)
|
||||
ble.Init() // allow ble driver to set up the JVM on Android
|
||||
gofont.Register()
|
||||
th := material.NewTheme()
|
||||
th.TextSize = unit.Sp(fontSize)
|
||||
gtx := &layout.Context{Queue: w.Queue()}
|
||||
|
||||
sysinset := &layout.Inset{}
|
||||
|
@ -88,6 +91,7 @@ func eventloop() {
|
|||
margin := layout.UniformInset(unit.Dp(10))
|
||||
|
||||
b := ble.NewBLE()
|
||||
b.Enable(w)
|
||||
|
||||
state := "starting"
|
||||
var hr int
|
||||
|
@ -240,13 +244,15 @@ func eventloop() {
|
|||
b.Scan()
|
||||
case ble.DiscoverServiceEvent:
|
||||
fmt.Printf("DiscoverService %s\n", e.Gatt.UUID)
|
||||
if e.Gatt.UUID == "180D" {
|
||||
//if e.Gatt.UUID == "180D" {
|
||||
if e.Gatt.IsHRM() {
|
||||
fmt.Printf("Found HRM Service\n")
|
||||
e.Peripheral.DiscoverCharacteristics(e.Service)
|
||||
}
|
||||
case ble.DiscoverCharacteristicEvent:
|
||||
fmt.Printf("DiscoverCharacteristic %s\n", e.Gatt.UUID)
|
||||
if e.Gatt.UUID == "2A37" {
|
||||
//if e.Gatt.UUID == "2A37" {
|
||||
if e.Gatt.IsHRV() {
|
||||
fmt.Printf("Found heart rate value\n")
|
||||
e.Peripheral.SetNotifyValue(e.Characteristic)
|
||||
}
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"gioui.org/app"
|
||||
)
|
||||
|
||||
var confDir string
|
||||
var fontSize float32 = 24
|
||||
|
||||
func getConfDir() string {
|
||||
if confDir != "" {
|
||||
return confDir
|
||||
if confDir == "" {
|
||||
var err error
|
||||
confDir,err = app.DataDir()
|
||||
if err != nil {
|
||||
log.Fatal("Cannot get configuration directory")
|
||||
}
|
||||
}
|
||||
confDir,_ = app.DataDir()
|
||||
return confDir
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
var confDir string
|
||||
var fontSize float32 = 16
|
||||
|
||||
func getConfDir() string {
|
||||
if confDir != "" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user