A simple heart rate monitor
Main changes: - go.mod: gioui.org v0.10.2, go 1.24, git.wow.st/gmp/ble e53c7be (commitNowAllowingStateLoss + BLUETOOTH_SCAN/CONNECT permission request from BlessedConnect.onAttach). - main.go: ported to the v0.10 API (app.Main + single-goroutine event loop, app.FrameEvent.Frame, material.* styles, op.Offset/ Affine, clip.Path for the circle). - On-demand rendering: no fixed 30 FPS ticker redraws. Frames are produced by Bluetooth events and input; 30 FPS only while the live stopwatch runs. The worker goroutine only polls the runtime permission (while a scan is pending) and starts the deferred scan. - widget.Clickable.Clicked must be called before Layout in v0.10: the Clickable consumes its click events during Layout. - circleClip: the clip.Path.Cube control points are relative to the pen; the second control point of each segment must be at (k-r), not (k). The old code drew a distorted, non-circular shape. - Android: perm_android.go pins a worker goroutine to one OS thread attached to the JVM for the life of the app (repeated attach/detach stack-overflows ART); the BLE view handle and scan permission state are shared with the render loop under bleMu. - os_android.go: AndroidViewEvent attach handling; os_others.go: no-op stubs for other platforms. New: - scripts/build.sh: gogio -> apktool decode -> inject BLUETOOTH_SCAN/BLUETOOTH_CONNECT into the manifest -> rebuild -> debug-sign -> install. Usage: ./scripts/build.sh [phone|emu] [--no-install]. - .gitignore: .DS_Store, *.idsig. |
||
|---|---|---|
| depjars | ||
| fastlane/metadata/android/en-US | ||
| hrm | ||
| scripts | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
HRM
An example heart rate monitor app for Android and MacOS using git.wow.st/gmp/ble and Gio.
The MacOS implementation uses a Core Bluetooth binding created by NSWrap. On Android, Martijn van Welie's Blessed library is used to simplify access to the Bluetooth Low-Energy hardware.
MacOS:
git clone https://git.wow.st/gmp/hrm
cd hrm/hrm
go build
./hrm
Android:
The gogio command from gioui.org/cmd/gogio must be installed to build
an Android APK.
git clone https://git.wow.st/gmp/hrm
cd hrm/hrm
gogio -target android .
adb install -r hrm.apk
The compiled Java code for the Android implementation is pre-packaged in
jar files. If you want to, you can re-compile these dependencies by running
go generate from the depjars directory. You will need to have gradle,
an Android SDK, and who knows what else installed on your machine.