Some tweaks for the beginning of Android support.

This commit is contained in:
Greg 2019-11-22 16:17:17 -05:00
parent 390086788f
commit fe2dadfa1f
4 changed files with 17 additions and 52 deletions

9
go.mod
View File

@ -1,9 +0,0 @@
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
)

38
go.sum
View File

@ -1,38 +0,0 @@
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=
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=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs=
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
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=

11
main.go
View File

@ -73,7 +73,6 @@ 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()
gtx := &layout.Context{Queue: w.Queue()}
@ -240,7 +239,8 @@ 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)
}
@ -256,6 +256,13 @@ func eventloop() {
w.Invalidate() // refresh on any Bluetooth event
case e := <-w.Events():
switch e := e.(type) {
case system.StageEvent:
if e.Stage == system.StageRunning {
//Do not block the main loop
go func() {
b.Enable(w)
}()
}
case system.DestroyEvent:
return
case system.FrameEvent:

View File

@ -1,15 +1,20 @@
package main
import (
"log"
"gioui.org/app"
)
var confDir string
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
}