Skip to content

Commit a586122

Browse files
authored
Merge pull request #2222 from halemmerich/gpstrek
gpstrek - Improve target markers in compass
2 parents 395ceeb + b13eece commit a586122

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

apps/gpstrek/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
0.05: Added adjustment for Bangle.js magnetometer heading fix
77
0.06: Fix waypoint menu always selecting last waypoint
88
Fix widget adding listeners more than once
9+
0.07: Show checkered flag for target markers
10+
Single waypoints are now shown in the compass view

apps/gpstrek/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Tapping or button to switch to the next information display, swipe right for the
1010

1111
Choose either a route or a waypoint as basis for the display.
1212

13-
After this selection and availability of a GPS fix the compass will show a blue dot for your destination and a green one for possibly available waypoints on the way.
13+
After this selection and availability of a GPS fix the compass will show a checkered flag for your destination and a green dot for possibly available waypoints on the way.
1414
Waypoints are shown with name if available and distance to waypoint.
1515

1616
As long as no GPS signal is available the compass shows the heading from the build in magnetometer. When a GPS fix becomes available, the compass display shows the GPS course. This can be differentiated by the display of bubble levels on top and sides of the compass.

apps/gpstrek/app.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,14 @@ function getCompassSlice(compassDataSource){
239239
} else {
240240
bpos=Math.round(bpos*increment);
241241
}
242-
graphics.setColor(p.color);
243-
graphics.fillCircle(bpos,y+height-12,Math.floor(width*0.03));
242+
if (p.color){
243+
graphics.setColor(p.color);
244+
}
245+
if (p.icon){
246+
graphics.drawImage(p.icon, bpos,y+height-12, {rotate:0,scale:2});
247+
} else {
248+
graphics.fillCircle(bpos,y+height-12,Math.floor(width*0.03));
249+
}
244250
}
245251
}
246252
if (compassDataSource.getMarkers){
@@ -595,8 +601,8 @@ function showBackgroundMenu(){
595601
"title" : "Background",
596602
back : showMenu,
597603
},
598-
"Start" : ()=>{ E.showPrompt("Start?").then((v)=>{ if (v) {WIDGETS.gpstrek.start(true); removeMenu();} else {E.showMenu(mainmenu);}});},
599-
"Stop" : ()=>{ E.showPrompt("Stop?").then((v)=>{ if (v) {WIDGETS.gpstrek.stop(true); removeMenu();} else {E.showMenu(mainmenu);}});},
604+
"Start" : ()=>{ E.showPrompt("Start?").then((v)=>{ if (v) {WIDGETS.gpstrek.start(true); removeMenu();} else {showMenu();}}).catch(()=>{E.showMenu(mainmenu);});},
605+
"Stop" : ()=>{ E.showPrompt("Stop?").then((v)=>{ if (v) {WIDGETS.gpstrek.stop(true); removeMenu();} else {showMenu();}}).catch(()=>{E.showMenu(mainmenu);});},
600606
};
601607
E.showMenu(menu);
602608
}
@@ -677,21 +683,26 @@ function setClosestWaypoint(route, startindex, progress){
677683

678684
let screen = 1;
679685

686+
const finishIcon = atob("CggB//meZmeZ+Z5n/w==");
687+
680688
const compassSliceData = {
681689
getCourseType: function(){
682690
return (state.currentPos && state.currentPos.course) ? "GPS" : "MAG";
683691
},
684692
getCourse: function (){
685693
if(compassSliceData.getCourseType() == "GPS") return state.currentPos.course;
686-
return state.compassHeading?360-state.compassHeading:undefined;
694+
return state.compassHeading?state.compassHeading:undefined;
687695
},
688696
getPoints: function (){
689697
let points = [];
690698
if (state.currentPos && state.currentPos.lon && state.route && state.route.currentWaypoint){
691699
points.push({bearing:bearing(state.currentPos, state.route.currentWaypoint), color:"#0f0"});
692700
}
693701
if (state.currentPos && state.currentPos.lon && state.route){
694-
points.push({bearing:bearing(state.currentPos, getLast(state.route)), color:"#00f"});
702+
points.push({bearing:bearing(state.currentPos, getLast(state.route)), icon: finishIcon});
703+
}
704+
if (state.currentPos && state.currentPos.lon && state.waypoint){
705+
points.push({bearing:bearing(state.currentPos, state.waypoint), icon: finishIcon});
695706
}
696707
return points;
697708
},

apps/gpstrek/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "gpstrek",
33
"name": "GPS Trekking",
4-
"version": "0.06",
4+
"version": "0.07",
55
"description": "Helper for tracking the status/progress during hiking. Do NOT depend on this for navigation!",
66
"icon": "icon.png",
77
"screenshots": [{"url":"screen1.png"},{"url":"screen2.png"},{"url":"screen3.png"},{"url":"screen4.png"}],

apps/gpstrek/screen2.png

188 Bytes
Loading

apps/gpstrek/widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function onGPS(fix) {
2424
}
2525

2626
function onMag(e) {
27-
if (!state.compassHeading) state.compassHeading = 360-e.heading;
27+
if (!state.compassHeading) state.compassHeading = e.heading;
2828

2929
//if (a+180)mod 360 == b then
3030
//return (a+b)/2 mod 360 and ((a+b)/2 mod 360) + 180 (they are both the solution, so you may choose one depending if you prefer counterclockwise or clockwise direction)

0 commit comments

Comments
 (0)