diff --git a/apps.json b/apps.json index fe9db5472..f31a77243 100644 --- a/apps.json +++ b/apps.json @@ -142,6 +142,7 @@ "version":"0.18", "description": "The default notification handler for Gadgetbridge notifications from Android", "tags": "tool,system,android,widget", + "readme": "README.md", "type":"widget", "dependencies": { "notify":"type" }, "storage": [ diff --git a/apps/gbridge/README.md b/apps/gbridge/README.md new file mode 100644 index 000000000..867b736ab --- /dev/null +++ b/apps/gbridge/README.md @@ -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` diff --git a/apps/gbridge/settings.js b/apps/gbridge/settings.js index fbb4d98a7..42fa84a3e 100644 --- a/apps/gbridge/settings.js +++ b/apps/gbridge/settings.js @@ -12,7 +12,7 @@ function updateSetting(setting, value) { let settings = require('Storage').readJSON("gbridge.json", true) || {}; settings[setting] = value - require('Storage').write('gbridge.json', settings); + require('Storage').writeJSON('gbridge.json', settings); } function setIcon(visible) { updateSetting('showIcon', visible); diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index c8e363c6b..d616e8816 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -150,31 +150,40 @@ } 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(); + // handle setting activity interval if (s.activityInterval===undefined || s.activityInterval<30) - s.activityInterval = 30*60; // 3 minutes default + s.activityInterval = 3*60; // 3 minutes default if (event.int) { if (event.int<30) event.int = 30; // min 30 secs 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 realtime = event.hrm || event.stp; if (activityInterval) clearInterval(activityInterval); activityInterval = undefined; - Bangle.setHRMPower(1); - if (event.hrm || event.stp) { - // if realtime reporting, leave HRM on and use that to trigger events - hrmTimeout = undefined; - } else { - // else trigger it manually every so often - hrmTimeout = 5; - activityInterval = setInterval(function() { + if (s.hrm) Bangle.setHRMPower(1); + if (s.hrm) { + if (realtime) { + // if realtime reporting, leave HRM on and use that to trigger events + hrmTimeout = undefined; + } else { + // else trigger it manually every so often 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); } } @@ -243,17 +252,6 @@ 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 function sendActivity(hrm) { var steps = currentSteps - lastSentSteps;