Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
OmegaRogue committed Dec 9, 2020
2 parents 15d51d5 + f5e57c1 commit dbf68a8
Show file tree
Hide file tree
Showing 25 changed files with 392 additions and 161 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,18 @@ It should also add `app.json` to `data`, to make sure it is cleaned up when the
},
```

## Modules

You can include any of [Espruino's modules](https://www.espruino.com/Modules) as
normal with `require("modulename")`. If you want to develop your own module for your
app(s) then you can do that too. Just add the module into the `modules` folder
then you can use it from your app as normal.

You won't be able to develop apps using your own modules with the IDE,
so instead we'd recommend you write your module to a Storage File called
`modulename` on Bangle.js. You can then develop your app as normal on Bangle.js
from the IDE.

## Coding hints

- use `g.setFont(.., size)` to multiply the font size, eg ("6x8",3) : "18x24"
Expand Down
25 changes: 14 additions & 11 deletions apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{ "id": "locale",
"name": "Languages",
"icon": "locale.png",
"version":"0.07",
"version":"0.08",
"description": "Translations for different countries",
"tags": "tool,system,locale,translate",
"type": "locale",
Expand Down Expand Up @@ -139,9 +139,10 @@
{ "id": "gbridge",
"name": "Gadgetbridge",
"icon": "app.png",
"version":"0.17",
"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": [
Expand Down Expand Up @@ -362,14 +363,15 @@
{ "id": "gpsrec",
"name": "GPS Recorder",
"icon": "app.png",
"version":"0.13",
"version":"0.16",
"interface": "interface.html",
"description": "Application that allows you to record a GPS track. Can run in background",
"tags": "tool,outdoors,gps,widget",
"storage": [
{"name":"gpsrec.app.js","url":"app.js"},
{"name":"gpsrec.img","url":"app-icon.js","evaluate":true},
{"name":"gpsrec.wid.js","url":"widget.js"}
{"name":"gpsrec.wid.js","url":"widget.js"},
{"name":"gpsrec.settings.js","url":"settings.js"}
],
"data": [
{"name":"gpsrec.json"},
Expand All @@ -379,13 +381,13 @@
{ "id": "gpsnav",
"name": "GPS Navigation",
"icon": "icon.png",
"version":"0.04",
"version":"0.05",
"description": "Displays GPS Course and Speed, + Directions to waypoint and waypoint recording, now with waypoint editor",
"tags": "tool,outdoors,gps",
"readme": "README.md",
"interface":"waypoints.html",
"storage": [
{"name":"gpsnav.app.js","url":"app.js"},
{"name":"gpsnav.app.js","url":"app.min.js"},
{"name":"waypoints.json","url":"waypoints.json","evaluate":false},
{"name":"gpsnav.img","url":"app-icon.js","evaluate":true}
]
Expand Down Expand Up @@ -941,12 +943,12 @@
]
},
{ "id": "assistedgps",
"name": "Assisted GPS Update",
"name": "Assisted GPS Update (AGPS)",
"icon": "app.png",
"version":"0.01",
"description": "Downloads assisted GPS data to Bangle.js for faster GPS startup and more accurate fixes",
"custom": "custom.html",
"tags": "tool,outdoors",
"tags": "tool,outdoors,agps",
"type": "RAM",
"storage": [ ]
},
Expand Down Expand Up @@ -1325,11 +1327,12 @@
"name": "OpenStreetMap",
"shortName":"OpenStMap",
"icon": "app.png",
"version":"0.03",
"version":"0.05",
"description": "[BETA] Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are",
"tags": "outdoors,gps",
"custom": "custom.html",
"storage": [
{"name":"openstmap","url":"openstmap.js"},
{"name":"openstmap.app.js","url":"app.js"},
{"name":"openstmap.img","url":"app-icon.js","evaluate":true}
]
Expand Down Expand Up @@ -2290,7 +2293,7 @@
"name": "File manager",
"shortName":"FileManager",
"icon": "icons8-filing-cabinet-48.png",
"version":"0.01",
"version":"0.02",
"description": "Simple file manager, allows user to examine watch storage and display, load or delete individual files",
"tags": "tools",
"readme": "README.md",
Expand Down Expand Up @@ -2473,6 +2476,6 @@
"storage": [
{"name":"gmeter.app.js","url":"app.js"},
{"name":"gmeter.img","url":"app-icon.js","evaluate":true}
]
]
}
]
6 changes: 2 additions & 4 deletions apps/assistedgps/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ <h2>Assisted GPS</h2>
var chunkSize = 128;
var js = "\x10Bangle.setGPSPower(1);\n"; // turn GPS on
//js += `\x10Bangle.on('GPS-raw',function (d) { if (d.startsWith("\\xB5\\x62\\x05\\x01")) Terminal.println("GPS ACK"); else if (d.startsWith("\\xB5\\x62\\x05\\x00")) Terminal.println("GPS NACK"); })\n`;
js += "\x10E.showMessage('Uploading...','AGPS');function p(n) {g.fillRect(0,g.getHeight()-80,g.getWidth()*n,g.getHeight()-60);}";
//js += "\x10var t=getTime()+1;while(t>getTime());\n"; // wait 1 sec
js += `\x10Serial1.write(atob("${btoa(String.fromCharCode.apply(null,UBX_MGA_INI_TIME_UTC()))}"))\n`; // set GPS time

for (var i=0;i<bin.length;i+=chunkSize) {
var chunk = bin.substr(i,chunkSize);
js += `\x10p(${Math.round(100*i/bin.length)/100});Serial1.write(atob("${btoa(chunk)}"))\n`;
js += `\x10Serial1.write(atob("${btoa(chunk)}"))\n`;
}
js += "\x10p(1);\n"; // finish progress bar
return js;
}

Expand Down
1 change: 1 addition & 0 deletions apps/fileman/ChangeLog
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.01: New app!
0.02: Improve handling of large amounts of files (fix #579)
13 changes: 8 additions & 5 deletions apps/fileman/fileman.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ function delete_file(fn) {
E.showPrompt("Delete\n"+fn+"?", {buttons: {"No":false, "Yes":true}}).then(function(v) {
if (v) {
if (fn.charCodeAt(fn.length-1)==1) {
var fh = STOR.open(fn.substr(0, fn.length-1), "w");
var fh = STOR.open(fn.substr(0, fn.length-1), "r");
fh.erase();
}
else STOR.erase(fn);
}
}).then(function() { files=get_pruned_file_list(); }).then(drawMenu);
}).then(function() { filed=[];files=get_pruned_file_list(); }).then(drawMenu);
}

function get_length(fn) {
Expand Down Expand Up @@ -90,10 +90,13 @@ function drawMenu() {
}

function get_pruned_file_list() {
var fl = STOR.list(/^[^\.]/);
// get storagefile list
var sf = STOR.list(/\1$/).map(s=>s.slice(0,-1));
var sffilter = f=>!sf.includes(f.slice(0,-1)) || f.endsWith("\1");
// get files - put '.' last
var fl = STOR.list(/^[^\.]/).filter(sffilter);
fl.sort();
fl = fl.concat(STOR.list(/^\./));
fl = fl.filter(f => (f.charCodeAt(f.length-1)>31 || f.charCodeAt(f.length-1)<2));
fl = fl.concat(STOR.list(/^\./).filter(sffilter).sort());
return fl;
}

Expand Down
1 change: 1 addition & 0 deletions apps/gbridge/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
0.16: Handle dismissing notifications on the phone
Nicer display of alarm clock notifications
0.17: Modified music notification for updated 'notify' library
0.18: Added reporting of step count and HRM (new Gadgetbridges can now log this)
54 changes: 54 additions & 0 deletions apps/gbridge/README.md
Original file line number Diff line number Diff line change
@@ -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`
7 changes: 6 additions & 1 deletion apps/gbridge/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,6 +30,11 @@
onchange: setIcon
},
"Find Phone" : function() { E.showMenu(findPhone); },
"Record HRM" : {
value: settings().hrm,
format: v => v?"Yes":"No",
onchange: v => updateSetting('hrm', v)
},
"< Back" : back,
};

Expand Down
82 changes: 77 additions & 5 deletions apps/gbridge/widget.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(() => {
// Music handling
const state = {
music: "stop",

Expand All @@ -10,13 +11,17 @@

scrollPos: 0
};

// activity reporting
var currentSteps = 0, lastSentSteps=0;
var activityInterval;
var hrmTimeout;

function settings() {
let settings = require('Storage').readJSON("gbridge.json", true) || {};
if (!("showIcon" in settings)) {
settings.showIcon = true;
}
return settings
return settings;
}

function gbSend(message) {
Expand Down Expand Up @@ -143,6 +148,45 @@
setTimeout(_=>Bangle.beep(), 1000);
},2000);
}

function handleActivityEvent(event) {
var s = settings();
// handle setting activity interval
if (s.activityInterval===undefined ||
s.activityInterval<30)
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').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;
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;
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);
}
}

var _GB = global.GB;
global.GB = (event) => {
Expand All @@ -163,6 +207,9 @@
case "find":
handleFindEvent(event);
break;
case "act":
handleActivityEvent(event);
break;
}
if(_GB)setTimeout(_GB,0,event);
};
Expand Down Expand Up @@ -201,14 +248,39 @@
}
}

WIDGETS["gbridgew"] = {area: "tl", width: 24, draw: draw, reload: reload};
reload();

function sendBattery() {
gbSend({ t: "status", bat: E.getBattery() });
}

// Send a summary of activity to Gadgetbridge
function sendActivity(hrm) {
var steps = currentSteps - lastSentSteps;
lastSentSteps = 0;
gbSend({ t: "act", stp: steps, hrm:hrm });
}

// Battery monitor
NRF.on("connect", () => setTimeout(sendBattery, 2000));
setInterval(sendBattery, 10*60*1000);
sendBattery();
// Activity monitor
Bangle.on("step", s => {
if (!lastSentSteps)
lastSentSteps = s-1;
currentSteps = s;
});
Bangle.on('HRM',function(hrm) {
var ok = hrm.confidence>80;
if (hrmTimeout!==undefined) hrmTimeout--;
if (ok || hrmTimeout<=0) {
if (hrmTimeout!==undefined)
Bangle.setHRMPower(0);
sendActivity(hrm.confidence>20 ? hrm.bpm : -1);
}
});
handleActivityEvent({}); // kicks off activity reporting

// Finally add widget
WIDGETS["gbridgew"] = {area: "tl", width: 24, draw: draw, reload: reload};
reload();
})();
2 changes: 2 additions & 0 deletions apps/gpsnav/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
0.02: Add SCREENACCESS interface
0.03: Add Waypoint Editor
0.04: Fix great circle formula
0.05: Use locale for speed and distance + fix Vector font sizes

Loading

0 comments on commit dbf68a8

Please sign in to comment.