From a703e154559b464bd882b07e981da10c6d02a9bc Mon Sep 17 00:00:00 2001
From: Gordon Williams
Date: Mon, 10 Feb 2020 13:49:36 +0000
Subject: [PATCH] Add GPS Recorder with companion code in Bangle App Loader
that allows the data to be read back as a KML
---
README.md | 79 ++++++++++++++
apps/beer/beercompass.html | 4 +-
apps/gpsrec/app.js | 4 -
apps/gpsrec/interface.html | 216 ++++++++++++++++++++++++++++++++-----
apps/qrcode/qrcode.html | 7 +-
apps/route/route.html | 3 +-
index.js | 42 ++++----
lib/customize.js | 25 +++++
lib/interface.js | 32 ++++++
9 files changed, 358 insertions(+), 54 deletions(-)
create mode 100644 lib/customize.js
create mode 100644 lib/interface.js
diff --git a/README.md b/README.md
index eaf8c6f4c..f79c8d4d4 100644
--- a/README.md
+++ b/README.md
@@ -192,10 +192,12 @@ about the app.
"custom": "custom.html", // if supplied, apps/custom.html is loaded in an
// iframe, and it must post back an 'app' structure
// like this one with 'storage','name' and 'id' set up
+ // see below for more info
"interface": "interface.html", // if supplied, apps/interface.html is loaded in an
// iframe, and it may interact with the connected Bangle
// to retrieve information from it
+ // see below for more info
"allow_emulator":true, // if 'app.js' will run in the emulator, set to true to
// add an icon to allow your app to be tested
@@ -218,6 +220,83 @@ about the app.
* tags is used for grouping apps in the library, separate multiple entries by comma. Known tags are `tool`, `system`, `clock`, `game`, `sound`, `gps`, `widget`, `launcher` or empty.
* storage is used to identify the app files and how to handle them
+### `apps.json`: `custom` element
+
+Apps that can be customised need to define a `custom` element in `apps.json`,
+which names an HTML file in that app's folder.
+
+When `custom` is defined, the 'upload' button is replaced by a customize
+button, and when clicked it opens the HTML page specified in an iframe.
+
+In that HTML file you're then responsible for handling a button
+press and calling `sendCustomizedApp` with your own customised
+version of what's in `apps.json`:
+
+```
+
+
+
+
+
+
+
+
+
+
+```
+
+This'll then be loaded in to the watch. See [apps/qrcode/grcode.html](the QR Code app)
+for a clean example.
+
+### `apps.json`: `interface` element
+
+Apps that create data that can be read back can define a `interface` element in `apps.json`,
+which names an HTML file in that app's folder.
+
+When `interface` is defined, a `Download from App` button is added to
+the app's description, and when clicked it opens the HTML page specified
+in an iframe.
+
+```
+
+
+
+
+
+
+
Loading...
+
+
+
+```
+
+When the page is ready a function called `onInit` is called,
+and in that you can call `Puck.write` and `Puck.eval` to get
+the data you require from Bangle.js.
+
+See [apps/gpsrec/interface.html](the GPS Recorder) for a full example.
+
## Coding hints
- Need to save state? Use the `E.on('kill',...)` event to save JSON to a file called `@7chname`, then load it at startup.
diff --git a/apps/beer/beercompass.html b/apps/beer/beercompass.html
index ba3988aec..cb5590fa7 100644
--- a/apps/beer/beercompass.html
+++ b/apps/beer/beercompass.html
@@ -33,6 +33,7 @@