1
0
Fork 0
master
frederic wagner 2022-09-16 13:34:23 +02:00
parent 8a7c24b473
commit a3a73e423e
5 changed files with 52 additions and 5 deletions

View File

@ -56,3 +56,4 @@
0.14:
* Detect starting distance to compute a good average speed.
* Settings

View File

@ -10,7 +10,6 @@
- config screen
- are we on foot (and should use compass)
- disable gps off
- average speed becomes invalid if you stop and restart
- pause when not moving
@ -26,5 +25,3 @@
* misc
- code is becoming messy

View File

@ -2,6 +2,14 @@ let simulated = false;
let file_version = 3;
let code_key = 47490;
var settings = Object.assign(
{
keep_gps_alive: false,
max_speed: 35,
},
require("Storage").readJSON("gipy.json", true) || {}
);
let interests_colors = [
0xf800, // Bakery, red
0x001f, // DrinkingWater, blue
@ -175,8 +183,9 @@ class Status {
}
// disable gps when far from next point and locked
if (Bangle.isLocked()) {
let time_to_next_point = this.distance_to_next_point / 9.7; // 35km/h is 9.7 m/s
if (Bangle.isLocked() && !settings.keep_gps_alive) {
let time_to_next_point =
(this.distance_to_next_point * 3.6) / settings.max_speed;
if (time_to_next_point > 60) {
Bangle.setGPSPower(false, "gipy");
setTimeout(function () {

View File

@ -13,8 +13,10 @@
"readme": "README.md",
"storage": [
{"name":"gipy.app.js","url":"app.js"},
{"name":"gipy.settings.js","url":"settings.js"},
{"name":"gipy.img","url":"app-icon.js","evaluate":true}
],
"data": [
{"name":"gipy.json"}
]
}

38
apps/gipy/settings.js Normal file
View File

@ -0,0 +1,38 @@
(function (back) {
var FILE = "gipy.json";
// Load settings
var settings = Object.assign(
{
keep_gps_alive: false,
max_speed: 35,
},
require("Storage").readJSON(FILE, true) || {}
);
function writeSettings() {
require("Storage").writeJSON(FILE, settings);
}
// Show the menu
E.showMenu({
"": { title: "Gipy" },
"< Back": () => back(),
"keep gps alive": {
value: !!settings.keep_gps_alive, // !! converts undefined to false
format: (v) => (v ? "Yes" : "No"),
onchange: (v) => {
settings.keep_gps_alive = v;
writeSettings();
},
},
"max speed": {
value: 35 | settings.max_speed, // 0| converts undefined to 0
min: 0,
max: 130,
onchange: (v) => {
settings.max_speed = v;
writeSettings();
},
},
});
});