Skip to content

Commit 875ba41

Browse files
committed
runplus: show satelite strength bar (+setting)
1 parent b2fe290 commit 875ba41

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

apps/runplus/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Write to correct settings file, fixing settings not working.
3333
track screen state
3434
0.30: Change the "time" stat to show active time (duration) rather than
3535
elapsed time (fix #3802), and sync with recorder on load
36+
0.31: Add setting to show GPS strength bar on the left

apps/runplus/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Displays distance, time, steps, cadence, pace and heart rate for runners. Based
44
It requires the input of your minimum and maximum heart rate in the settings for the app to work. You can come back to the initial run screen anytime by swiping left.
55
To use it, start the app and press the middle button so that the red STOP in the bottom right turns to a green `RUN`.
66

7-
To focus on a single stat, tap on the stat and it will take up the full screen. Tap again to return to the main screen.
8-
97
## Display 1st screen
108

119
* `DIST` - the distance travelled based on the GPS (if you have a GPS lock).
@@ -23,6 +21,8 @@ so if you have no GPS lock you just need to wait.
2321
* The current time is displayed right at the bottom of the screen
2422
* `RUN/STOP` - whether the distance for your run is being displayed or not
2523

24+
To focus on a single stat, tap on the stat and it will take up the full screen. Tap again to return to the main screen.
25+
2626
## Display 2nd screen
2727

2828
Unlock the screen and navigate between displays by swiping left or right.
@@ -75,10 +75,12 @@ app loader, the module is automatically included in the app's source. However
7575
when developing via the IDE the module won't get pulled in by default.
7676

7777
There are some options to fix this easily - please check out the [modules README.md file](https://github.com/espruino/BangleApps/blob/master/modules/README.md)
78+
7879
## Contributors (Run and Run+)
7980
gfwilliams
8081
hughbarney
8182
GrandVizierOlaf
8283
BartS23
8384
f-teacher
8485
thyttan
86+
bobrippling

apps/runplus/app.js

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ let settings = Object.assign({
2828
paceLength: 1000,
2929
alwaysResume: false,
3030
vibrate: false,
31+
showSats: false,
3132
notify: {
3233
dist: {
3334
value: 0,
@@ -197,9 +198,48 @@ lc.push({ type:"h", id:"bottom", filly:1, c:[
197198
{type:"txt", font:fontHeading, label:"---", id:"status", fillx:1 }
198199
]});
199200
// Now calculate the layout
200-
let layout = new Layout( {
201-
type:"v", c: lc
202-
},{lazy:true, btns:[{ label:"---", cb: onStartStop, id:"button"}]});
201+
let topLevel = { type:"v", c: lc };
202+
if(settings.showSats){
203+
const drawGpsLvl = l => {
204+
const gps = l.gps;
205+
const nsats = gps?.satellites ?? 0;
206+
207+
if (!gps || !gps.fix)
208+
g.setColor("#FF0000");
209+
else if (gps.satellites < 4)
210+
g.setColor("#FF5500");
211+
else if (gps.satellites < 6)
212+
g.setColor("#FF8800");
213+
else if (gps.satellites < 8)
214+
g.setColor("#FFCC00");
215+
else
216+
g.setColor("#00FF00");
217+
218+
g.fillRect(
219+
l.x,
220+
l.y + l.h - 10 - (l.h - 10) * ((nsats > 12 ? 12 : nsats) / 12),
221+
l.x + l.w - 1,
222+
l.y + l.h - 1
223+
);
224+
};
225+
226+
topLevel = {
227+
type: "h",
228+
c: [
229+
{
230+
type: "custom",
231+
render: drawGpsLvl,
232+
id: "gpslvl",
233+
filly: 1,
234+
width: 5,
235+
bgCol: g.theme.bg, // automatically clears before render()
236+
},
237+
topLevel,
238+
]
239+
}
240+
}
241+
let layout = new Layout(topLevel, {lazy:true, btns:[{ label:"---", cb: onStartStop, id:"button"}]});
242+
delete topLevel;
203243
delete lc;
204244
setStatus(exs.state.active);
205245
layout.render();

apps/runplus/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "runplus",
33
"name": "Run+",
4-
"version": "0.30",
4+
"version": "0.31",
55
"author": "thyttan",
66
"description": "Displays distance, time, steps, cadence, pace and more for runners. Based on the Run app, but extended with additional screens for heart rate interval training and individual stat focus.",
77
"icon": "app.png",

apps/runplus/settings.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
paceLength: 1000, // TODO: Default to either 1km or 1mi based on locale
2020
alwaysResume: false,
2121
vibrate: false,
22+
showSats: false,
2223
notify: {
2324
dist: {
2425
increment: 0,
@@ -88,6 +89,13 @@
8889
saveSettings();
8990
},
9091
};
92+
menu[/*LANG*/"Show satelite bar"] = {
93+
value : settings.showSats,
94+
onchange : v => {
95+
settings.showSats = v;
96+
saveSettings();
97+
},
98+
};
9199
var notificationsMenu = {
92100
'< Back': function() { E.showMenu(menu) },
93101
}

0 commit comments

Comments
 (0)