Update Gio version. Remove ticker as we already invalidate on

any Bluetooth event.
This commit is contained in:
Greg 2019-10-25 14:58:07 -04:00
parent f04f3b1ffb
commit 299600b537
1 changed files with 6 additions and 6 deletions

12
main.go
View File

@ -7,7 +7,6 @@ import (
"log" "log"
"os" "os"
"path" "path"
"time"
"git.wow.st/gmp/ble" "git.wow.st/gmp/ble"
@ -21,7 +20,7 @@ import (
"gioui.org/widget" "gioui.org/widget"
"gioui.org/widget/material" "gioui.org/widget/material"
_ "gioui.org/font/gofont" "gioui.org/font/gofont"
) )
type conf struct { type conf struct {
@ -74,6 +73,7 @@ func eventloop() {
app.Size(unit.Dp(400), unit.Dp(400)), app.Size(unit.Dp(400), unit.Dp(400)),
app.Title("HRM"), app.Title("HRM"),
) )
gofont.Register()
th := material.NewTheme() th := material.NewTheme()
gtx := &layout.Context{Queue: w.Queue()} gtx := &layout.Context{Queue: w.Queue()}
@ -117,7 +117,10 @@ func eventloop() {
c3 := f.Rigid(gtx, func() { c3 := f.Rigid(gtx, func() {
lst := &layout.List{Axis: layout.Vertical} lst := &layout.List{Axis: layout.Vertical}
lst.Layout(gtx, len(periphs), func(i int) { lst.Layout(gtx, len(periphs), func(i int) {
th.Button(periphs[i].Name).Layout(gtx, btns[i]) gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
layout.UniformInset(unit.Dp(2)).Layout(gtx, func() {
th.Button(periphs[i].Name).Layout(gtx, btns[i])
})
if btns[i].Clicked(gtx) { if btns[i].Clicked(gtx) {
b.StopScan() b.StopScan()
periph = periphs[i] periph = periphs[i]
@ -185,7 +188,6 @@ func eventloop() {
page = offpage page = offpage
tick := time.NewTicker(time.Second / 30)
events := b.Events() events := b.Events()
for { for {
@ -251,8 +253,6 @@ func eventloop() {
hr = hrDecode(e.Data) hr = hrDecode(e.Data)
} }
w.Invalidate() // refresh on any Bluetooth event w.Invalidate() // refresh on any Bluetooth event
case <-tick.C:
w.Invalidate()
case e := <-w.Events(): case e := <-w.Events():
switch e := e.(type) { switch e := e.(type) {
case system.DestroyEvent: case system.DestroyEvent: