tweaks - sort out activity handling when HRM=false (default), add README
parent
9a3b203429
commit
23aa25dbef
|
|
@ -142,6 +142,7 @@
|
||||||
"version":"0.18",
|
"version":"0.18",
|
||||||
"description": "The default notification handler for Gadgetbridge notifications from Android",
|
"description": "The default notification handler for Gadgetbridge notifications from Android",
|
||||||
"tags": "tool,system,android,widget",
|
"tags": "tool,system,android,widget",
|
||||||
|
"readme": "README.md",
|
||||||
"type":"widget",
|
"type":"widget",
|
||||||
"dependencies": { "notify":"type" },
|
"dependencies": { "notify":"type" },
|
||||||
"storage": [
|
"storage": [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
Gadgetbridge
|
||||||
|
=============
|
||||||
|
|
||||||
|
This widget allows your Bangle.js to communicate with the Gadgetbridge app on an Android phone.
|
||||||
|
|
||||||
|
Download the [latest Gadgetbridge for Android here](https://f-droid.org/packages/nodomain.freeyourgadget.gadgetbridge/).
|
||||||
|
|
||||||
|
This app supports:
|
||||||
|
|
||||||
|
* Displaying Notifications
|
||||||
|
* Song display and control
|
||||||
|
* Call answering
|
||||||
|
* Find My Phone / Find My Bangle
|
||||||
|
* Activity reporting
|
||||||
|
|
||||||
|
You can also add [the weather widget](https://banglejs.com/apps/#weather)
|
||||||
|
|
||||||
|
|
||||||
|
Notifications
|
||||||
|
-------------
|
||||||
|
|
||||||
|
By default a notification at the top of the screen is displayed. If you'd like a fullscreen notification
|
||||||
|
(which will involve leaving the current app) then install [Fullscreen Notifications](https://banglejs.com/apps/#notifyfs)
|
||||||
|
|
||||||
|
|
||||||
|
Song display and control
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
When the Song Display notification is showing on the screen and a song is playing, you
|
||||||
|
can swipe left or right on the screen to go to the next or previous song.
|
||||||
|
|
||||||
|
|
||||||
|
Find My Phone
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Go to `Settings`, `App/Widget Settings`, `Gadgetbridge`, `Find Phone`, `On`
|
||||||
|
|
||||||
|
If in range and connected your phone should start ringing.
|
||||||
|
|
||||||
|
|
||||||
|
Find My Bangle
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Onyour phone `Settings`, `App/Widget Settings`, `Gadgetbridge`, `Find Phone`, `On`
|
||||||
|
|
||||||
|
If in range and connected your phone should start ringing.
|
||||||
|
|
||||||
|
|
||||||
|
Activity reporting
|
||||||
|
------------------
|
||||||
|
|
||||||
|
You'll need a Gadgetbridge release *after* version 0.50.0 for Actvity Reporting to be enabled.
|
||||||
|
|
||||||
|
By default heart rate isn't reported, but it can be enabled from `Settings`, `App/Widget Settings`, `Gadgetbridge`, `Record HRM`
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
function updateSetting(setting, value) {
|
function updateSetting(setting, value) {
|
||||||
let settings = require('Storage').readJSON("gbridge.json", true) || {};
|
let settings = require('Storage').readJSON("gbridge.json", true) || {};
|
||||||
settings[setting] = value
|
settings[setting] = value
|
||||||
require('Storage').write('gbridge.json', settings);
|
require('Storage').writeJSON('gbridge.json', settings);
|
||||||
}
|
}
|
||||||
function setIcon(visible) {
|
function setIcon(visible) {
|
||||||
updateSetting('showIcon', visible);
|
updateSetting('showIcon', visible);
|
||||||
|
|
|
||||||
|
|
@ -150,31 +150,40 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleActivityEvent(event) {
|
function handleActivityEvent(event) {
|
||||||
// TODO: `t:"act", hrm:bool, stp:bool, int:int` - Enable realtime step counting, realtime heart rate. 'int' is the report interval in seconds
|
|
||||||
// add live view,
|
|
||||||
var s = settings();
|
var s = settings();
|
||||||
|
// handle setting activity interval
|
||||||
if (s.activityInterval===undefined ||
|
if (s.activityInterval===undefined ||
|
||||||
s.activityInterval<30)
|
s.activityInterval<30)
|
||||||
s.activityInterval = 30*60; // 3 minutes default
|
s.activityInterval = 3*60; // 3 minutes default
|
||||||
if (event.int) {
|
if (event.int) {
|
||||||
if (event.int<30) event.int = 30; // min 30 secs
|
if (event.int<30) event.int = 30; // min 30 secs
|
||||||
s.activityInterval = event.int;
|
s.activityInterval = event.int;
|
||||||
require('Storage').write("gbridge.json", s);
|
require('Storage').writeJSON("gbridge.json", s);
|
||||||
}
|
}
|
||||||
|
// set up interval/HRM to handle activity data
|
||||||
var interval = s.activityInterval;
|
var interval = s.activityInterval;
|
||||||
|
var realtime = event.hrm || event.stp;
|
||||||
if (activityInterval)
|
if (activityInterval)
|
||||||
clearInterval(activityInterval);
|
clearInterval(activityInterval);
|
||||||
activityInterval = undefined;
|
activityInterval = undefined;
|
||||||
Bangle.setHRMPower(1);
|
if (s.hrm) Bangle.setHRMPower(1);
|
||||||
if (event.hrm || event.stp) {
|
if (s.hrm) {
|
||||||
// if realtime reporting, leave HRM on and use that to trigger events
|
if (realtime) {
|
||||||
hrmTimeout = undefined;
|
// if realtime reporting, leave HRM on and use that to trigger events
|
||||||
} else {
|
hrmTimeout = undefined;
|
||||||
// else trigger it manually every so often
|
} else {
|
||||||
hrmTimeout = 5;
|
// else trigger it manually every so often
|
||||||
activityInterval = setInterval(function() {
|
|
||||||
hrmTimeout = 5;
|
hrmTimeout = 5;
|
||||||
Bangle.setHRMPower(1);
|
activityInterval = setInterval(function() {
|
||||||
|
hrmTimeout = 5;
|
||||||
|
Bangle.setHRMPower(1);
|
||||||
|
}, interval*1000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no HRM - manually push data
|
||||||
|
if (realtime) interval=10;
|
||||||
|
activityInterval = setInterval(function() {
|
||||||
|
sendActivity(-1);
|
||||||
}, interval*1000);
|
}, interval*1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,17 +252,6 @@
|
||||||
gbSend({ t: "status", bat: E.getBattery() });
|
gbSend({ t: "status", bat: E.getBattery() });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn on HRM and get a reading
|
|
||||||
function getHRM(callback) {
|
|
||||||
if (settings().hrm) {
|
|
||||||
Bangle.setHRMPower(1);
|
|
||||||
var timeout = 5;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
callback(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a summary of activity to Gadgetbridge
|
// Send a summary of activity to Gadgetbridge
|
||||||
function sendActivity(hrm) {
|
function sendActivity(hrm) {
|
||||||
var steps = currentSteps - lastSentSteps;
|
var steps = currentSteps - lastSentSteps;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue