mirror of https://github.com/espruino/BangleApps
Merge pull request #2778 from RomanistHere/feat/localisation-pebbled
feat: localisation pebbledpull/2786/head
commit
f609e3e051
|
@ -2,3 +2,4 @@
|
||||||
0.02: Tell clock widgets to hide.
|
0.02: Tell clock widgets to hide.
|
||||||
0.03: Swipe down to see widgets
|
0.03: Swipe down to see widgets
|
||||||
Support for fast loading
|
Support for fast loading
|
||||||
|
0.04: Localisation request: added Miles and AM/PM
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "pebbled",
|
"id": "pebbled",
|
||||||
"name": "Pebble Clock with distance",
|
"name": "Pebble Clock with distance",
|
||||||
"shortName": "Pebble + distance",
|
"shortName": "Pebble + distance",
|
||||||
"version": "0.03",
|
"version": "0.04",
|
||||||
"description": "Fork of Pebble Clock with distance in KM. Both step count and the distance are on the main screen. Default step length = 0.75m (can be changed in settings).",
|
"description": "Fork of Pebble Clock with distance in KM. Both step count and the distance are on the main screen. Default step length = 0.75m (can be changed in settings).",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"icon": "pebbled.png",
|
"icon": "pebbled.png",
|
||||||
|
|
|
@ -16,6 +16,15 @@ let drawTimeout;
|
||||||
let loadSettings = function() {
|
let loadSettings = function() {
|
||||||
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green', 'avStep': 0.75};
|
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green', 'avStep': 0.75};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let tConv24 = function(time24) {
|
||||||
|
var ts = time24;
|
||||||
|
var H = +ts.substr(0, 2);
|
||||||
|
var h = (H % 12) || 12;
|
||||||
|
h = (h < 10)?("0"+h):h;
|
||||||
|
ts = h + ts.substr(2, 3);
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
const img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AE8AAAoeXoAfeDQUBmcyD7A+Dh///8QD649CiAfaHwUvD4sEHy0DDYIfEICg+Cn4fHICY+DD4nxcgojOHwgfEIAYfRCIQaDD4ZAFD5r7DH4//kAfRCIZ/GAAnwD5p9DX44fTHgYSBf4ofVDAQEBl4fFUAgfOXoQzBgIfFBAIfPP4RAEAoYAB+cRiK/SG4h/WIBAfXIA7CBAAswD55AHn6fUIBMCD65AHl4gCmcziAfQQJqfQQJpiDgk0IDXxQLRAEECaBM+QgRYRYgUIA0CD4ggSQJiDCiAKBICszAAswD55AHABKBVD7BAFABIqBD5pAFABPxD55AOD6BADiIAJQAyxLABwf/gaAPAH4A/AH4ARA=="));
|
const img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AE8AAAoeXoAfeDQUBmcyD7A+Dh///8QD649CiAfaHwUvD4sEHy0DDYIfEICg+Cn4fHICY+DD4nxcgojOHwgfEIAYfRCIQaDD4ZAFD5r7DH4//kAfRCIZ/GAAnwD5p9DX44fTHgYSBf4ofVDAQEBl4fFUAgfOXoQzBgIfFBAIfPP4RAEAoYAB+cRiK/SG4h/WIBAfXIA7CBAAswD55AHn6fUIBMCD65AHl4gCmcziAfQQJqfQQJpiDgk0IDXxQLRAEECaBM+QgRYRYgUIA0CD4ggSQJiDCiAKBICszAAswD55AHABKBVD7BAFABIqBD5pAFABPxD55AOD6BADiIAJQAyxLABwf/gaAPAH4A/AH4ARA=="));
|
||||||
|
|
||||||
|
@ -30,16 +39,19 @@ let batteryWarning = false;
|
||||||
let draw = function() {
|
let draw = function() {
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
let da = date.toString().split(" ");
|
let da = date.toString().split(" ");
|
||||||
let timeStr = da[4].substr(0,5);
|
let timeStr = settings.localization === "US" ? tConv24(da[4].substr(0,5)) : da[4].substr(0,5);
|
||||||
const t = 6;
|
const t = 6;
|
||||||
let stps = Bangle.getHealthStatus("day").steps;
|
let stps = Bangle.getHealthStatus("day").steps;
|
||||||
|
const distInKm = (stps / 1000 * settings.avStep).toFixed(2);
|
||||||
|
const distance = settings.localization === "US" ? (distInKm / 1.609).toFixed(2) : distInKm;
|
||||||
|
const distanceStr = settings.localization === "US" ? distance + ' MI' : distance + ' KM';
|
||||||
|
|
||||||
// turn the warning on once we have dipped below 15%
|
// turn the warning on once we have dipped below 25%
|
||||||
if (E.getBattery() < 15)
|
if (E.getBattery() < 25)
|
||||||
batteryWarning = true;
|
batteryWarning = true;
|
||||||
|
|
||||||
// turn the warning off once we have dipped above 20%
|
// turn the warning off once we have dipped above 30%
|
||||||
if (E.getBattery() > 20)
|
if (E.getBattery() > 30)
|
||||||
batteryWarning = false;
|
batteryWarning = false;
|
||||||
|
|
||||||
g.reset();
|
g.reset();
|
||||||
|
@ -88,7 +100,7 @@ let draw = function() {
|
||||||
g.setColor('#fff'); // white on blue or red best contrast
|
g.setColor('#fff'); // white on blue or red best contrast
|
||||||
else
|
else
|
||||||
g.setColor('#000'); // otherwise black regardless of theme
|
g.setColor('#000'); // otherwise black regardless of theme
|
||||||
g.drawString((stps / 1000 * settings.avStep).toFixed(2) + ' KM', w/2, ha + 107);
|
g.drawString(distanceStr, w/2, ha + 107);
|
||||||
|
|
||||||
// queue next draw
|
// queue next draw
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
const SETTINGS_FILE = "pebbleDistance.json";
|
const SETTINGS_FILE = "pebbleDistance.json";
|
||||||
|
|
||||||
// initialize with default settings...
|
// initialize with default settings...
|
||||||
let s = {'bg': '#0f0', 'color': 'Green', 'avStep': 0.75};
|
let s = {'bg': '#0f0', 'color': 'Green', 'avStep': 0.75, 'localization': 'World'};
|
||||||
|
|
||||||
// ...and overwrite them with any saved values
|
// ...and overwrite them with any saved values
|
||||||
// This way saved values are preserved if a new version adds more settings
|
// This way saved values are preserved if a new version adds more settings
|
||||||
|
@ -20,9 +20,10 @@
|
||||||
|
|
||||||
var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
|
var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
|
||||||
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
|
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
|
||||||
|
var local_options = ['World', 'US'];
|
||||||
|
|
||||||
E.showMenu({
|
E.showMenu({
|
||||||
'': { 'title': 'Pebble Clock' },
|
'': { 'title': 'PebbleD Clock' },
|
||||||
'< Back': back,
|
'< Back': back,
|
||||||
'Color': {
|
'Color': {
|
||||||
value: 0 | color_options.indexOf(s.color),
|
value: 0 | color_options.indexOf(s.color),
|
||||||
|
@ -43,6 +44,15 @@
|
||||||
s.avStep = v;
|
s.avStep = v;
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'Localization': {
|
||||||
|
value: 0 | local_options.indexOf(s.localization),
|
||||||
|
min: 0, max: 1,
|
||||||
|
format: v => local_options[v],
|
||||||
|
onchange: v => {
|
||||||
|
s.localization = local_options[v];
|
||||||
|
save();
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue