diff --git a/apps/run/ChangeLog b/apps/run/ChangeLog index 11d63b402..fd28c4414 100644 --- a/apps/run/ChangeLog +++ b/apps/run/ChangeLog @@ -4,3 +4,4 @@ 0.03: Fixed distance calculation, tested against Garmin Etrex, Amazfit GTS 2 0.04: Use the exstats module, and make what is displayed configurable 0.05: exstats updated so update 'distance' label is updated, option for 'speed' +0.06: Add option to record a run using the recorder app automatically diff --git a/apps/run/README.md b/apps/run/README.md index 10f6bafdb..17975f92c 100644 --- a/apps/run/README.md +++ b/apps/run/README.md @@ -32,6 +32,8 @@ that, and then start the `Run` app. Under `Settings` -> `App` -> `Run` you can change settings for this app. +* `Record Run` (only displayed if `Recorder` app installed) should the Run app automatically +record GPS/HRM/etc data every time you start a run? * `Pace` is the distance that pace should be shown over - 1km, 1 mile, 1/2 Marathon or 1 Marathon * `Box 1/2/3/4/5/6` are what should be shown in each of the 6 boxes on the display. From the top left, down. If you set it to `-` nothing will be displayed, so you can display only 4 boxes of information diff --git a/apps/run/app.js b/apps/run/app.js index 9e313ea2a..a8515a71a 100644 --- a/apps/run/app.js +++ b/apps/run/app.js @@ -6,6 +6,7 @@ var fontHeading = "6x8:2"; var fontValue = B2 ? "6x15:2" : "6x8:3"; var headingCol = "#888"; var fixCount = 0; +var isMenuDisplayed = false; g.clear(); Bangle.loadWidgets(); @@ -13,6 +14,7 @@ Bangle.drawWidgets(); // --------------------------- let settings = Object.assign({ + record : true, B1 : "dist", B2 : "time", B3 : "pacea", @@ -39,6 +41,19 @@ function onStartStop() { // if stopping running, don't clear state // so we can at least refer to what we've done layout.render(); + // start/stop recording + if (settings.record && WIDGETS["recorder"]) { + if (running) { + isMenuDisplayed = true; + WIDGETS["recorder"].setRecording(true).then(() => { + isMenuDisplayed = false; + layout.forgetLazyState(); + layout.render(); + }); + } else { + WIDGETS["recorder"].setRecording(false); + } + } } var lc = []; @@ -80,5 +95,5 @@ Bangle.on("GPS", function(fix) { // We always call ourselves once a second to update setInterval(function() { layout.clock.label = locale.time(new Date(),1); - layout.render(); + if (!isMenuDisplayed) layout.render(); }, 1000); diff --git a/apps/run/metadata.json b/apps/run/metadata.json index 0d718a1b3..ea68f4734 100644 --- a/apps/run/metadata.json +++ b/apps/run/metadata.json @@ -1,6 +1,6 @@ { "id": "run", "name": "Run", - "version":"0.05", + "version":"0.06", "description": "Displays distance, time, steps, cadence, pace and more for runners.", "icon": "app.png", "tags": "run,running,fitness,outdoors,gps", diff --git a/apps/run/settings.js b/apps/run/settings.js index 91a8b4333..7eb8a8611 100644 --- a/apps/run/settings.js +++ b/apps/run/settings.js @@ -9,6 +9,7 @@ // This way saved values are preserved if a new version adds more settings const storage = require('Storage') let settings = Object.assign({ + record : true, B1 : "dist", B2 : "time", B3 : "pacea", @@ -35,8 +36,17 @@ var menu = { '': { 'title': 'Run' }, - '< Back': back + '< Back': back, }; + if (WIDGETS["recorder"]) + menu[/*LANG*/"Record Run"] = { + value : !!settings.record, + format : v => v?/*LANG*/"Yes":/*LANG*/"No", + onchange : v => { + settings.record = v; + saveSettings(); + } + }; ExStats.appendMenuItems(menu, settings, saveSettings); Object.assign(menu,{ 'Box 1': getBoxChooser("B1"),