1
0
Fork 0

Show distance more accurately in conjunction with new locale app (fix #1523)

Also slightly more memory efficient locale module
master
Gordon Williams 2022-03-30 15:11:14 +01:00
parent a09df566f2
commit 48efab699d
10 changed files with 27 additions and 23 deletions

View File

@ -28,4 +28,5 @@
0.24: Better support for Bangle.js 2, avoid widget area for Graphs, smooth graphs more
0.25: Fix issue where if Bangle.js 2 got a GPS fix but no reported time, errors could be caused by the widget (fix #935)
0.26: Multiple bugfixes
0.27: Map drawing with light theme (fix #1023)
0.27: Map drawing with light theme (fix #1023)
0.28: Show distance more accurately in conjunction with new locale app (fix #1523)

View File

@ -248,7 +248,7 @@ function plotTrack(info) {
g.fillCircle(ox,oy,5);
if (info.qOSTM) g.setColor(0, 0, 0);
else g.setColor(g.theme.fg);
g.drawString(require("locale").distance(dist),g.getWidth() / 2, g.getHeight() - 20);
g.drawString(require("locale").distance(dist,2),g.getWidth() / 2, g.getHeight() - 20);
g.setFont("6x8",2);
g.setFontAlign(0,0,3);
g.drawString("Back",g.getWidth() - 10, g.getHeight()/2);

View File

@ -1,7 +1,7 @@
{
"id": "gpsrec",
"name": "GPS Recorder",
"version": "0.27",
"version": "0.28",
"description": "Application that allows you to record a GPS track. Can run in background",
"icon": "app.png",
"tags": "tool,outdoors,gps,widget",

View File

@ -15,4 +15,6 @@
0.13: Now use shorter de_DE date format to more closely match other languages for size
0.14: Added some first translations for Messages in nl_NL
0.15: Fixed sv_SE formatting, long date does not work well for Bangle.js2
Added Swedish localisation with English text
Added Swedish localisation with English text
0.16: Remove global variables that used RAM
Add second 'dp' argument for decimal places in distance/speed/temp (fix #1523)

View File

@ -158,10 +158,10 @@ exports = { name : "en_GB", currencySym:"£",
"%HH": "('0'+getHours(d)).slice(-2)",
"%MM": "('0'+d.getMinutes()).slice(-2)",
"%SS": "('0'+d.getSeconds()).slice(-2)",
"%A": "day.split(',')[d.getDay()]",
"%a": "day.split(',')[d.getDay() + 7]",
"%B": "month.split(',')[d.getMonth()]",
"%b": "month.split(',')[d.getMonth() + 12]",
"%A": `${js(locale.day)}.split(',')[d.getDay()]`,
"%a": `${js(locale.abday)}.split(',')[d.getDay()]`,
"%B": `${js(locale.month)}.split(',')[d.getMonth()]`,
"%b": `${js(locale.abmonth)}.split(',')[d.getMonth() + 12]`,
"%p": `d.getHours()<12?${js(locale.ampm[0].toUpperCase())}:${js(locale.ampm[1].toUpperCase())}`,
"%P": `d.getHours()<12?${js(locale.ampm[0].toLowerCase())}:${js(locale.ampm[1].toLowerCase())}`
};
@ -182,10 +182,10 @@ exports = { name : "en_GB", currencySym:"£",
var temperature = locale.temperature=='°F' ? '(t*9/5)+32' : 't';
var localeModule = `
var day = ${js(locale.day + ',' + locale.abday)};
var month = ${js(locale.month + ',' + locale.abmonth)};
function round(n) {
return n < 10 ? Math.round(n * 10) / 10 : Math.round(n);
function round(n, dp) {
if (dp===undefined) dp=0;
var p = Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10)));
return n.toFixed(p);
}
var is12;
function getHours(d) {
@ -197,8 +197,8 @@ function getHours(d) {
exports = {
name: ${js(locale.lang)},
currencySym: ${js(locale.currency_symbol)},
dow: (d,short) => day.split(',')[d.getDay() + (short ? 7 : 0)],
month: (d,short) => month.split(',')[d.getMonth() + (short ? 12 : 0)],
dow: (d,short) => ${js(locale.day + ',' + locale.abday)}.split(',')[d.getDay() + (short ? 7 : 0)],
month: (d,short) => ${js(locale.month + ',' + locale.abmonth)}.split(',')[d.getMonth() + (short ? 12 : 0)],
number: (n, dec) => {
if (dec == null) dec = 2;
var w = n.toFixed(dec),
@ -215,9 +215,9 @@ exports = {
return s.substr(0, i + 3) + r + (d ? '${locale.decimal_point}' + d: '');
},
currency: n => ${currency},
distance: n => n < ${distanceUnits[locale.distance[1]]} ? round(${unitConv(distanceUnits[locale.distance[0]])}) + ${js(locale.distance[0])} : round(${unitConv(distanceUnits[locale.distance[1]])}) + ${js(locale.distance[1])},
speed: n => round(${unitConv(speedUnits[locale.speed])}) + ${js(locale.speed)},
temp: t => Math.round(${temperature}) + ${js(locale.temperature)},
distance: (n,dp) => n < ${distanceUnits[locale.distance[1]]} ? round(${unitConv(distanceUnits[locale.distance[0]])},dp) + ${js(locale.distance[0])} : round(${unitConv(distanceUnits[locale.distance[1]])},dp) + ${js(locale.distance[1])},
speed: (n,dp) => round(${unitConv(speedUnits[locale.speed])},dp) + ${js(locale.speed)},
temp: (t,dp) => round(${temperature},dp) + ${js(locale.temperature)},
translate: s => ${locale.trans?`{var t=${js(locale.trans)};s=''+s;return t[s]||t[s.toLowerCase()]||s;}`:`s`},
date: (d,short) => short ? \`${dateS}\` : \`${dateN}\`,
time: (d,short) => short ? \`${timeS}\` : \`${timeN}\`,

View File

@ -1,7 +1,7 @@
{
"id": "locale",
"name": "Languages",
"version": "0.15",
"version": "0.16",
"description": "Translations for different countries",
"icon": "locale.png",
"type": "locale",

View File

@ -17,4 +17,5 @@
0.11: Fix KML and GPX export when there is no GPS data
0.12: Fix 'Back' label positioning on track/graph display, make translateable
0.13: Fix for when widget is used before app
0.14: Remove unneeded variable assignment
0.14: Remove unneeded variable assignment
0.15: Show distance more accurately in conjunction with new locale app (fix #1523)

View File

@ -307,7 +307,7 @@ function viewTrack(filename, info) {
g.fillCircle(ox,oy,5);
if (info.qOSTM) g.setColor("#000");
else g.setColor(g.theme.fg);
g.drawString(require("locale").distance(dist),g.getWidth() / 2, g.getHeight() - 20);
g.drawString(require("locale").distance(dist,2),g.getWidth() / 2, g.getHeight() - 20);
g.setFont("6x8",2);
g.setFontAlign(0,0,3);
var isBTN3 = "BTN3" in global;

View File

@ -2,7 +2,7 @@
"id": "recorder",
"name": "Recorder",
"shortName": "Recorder",
"version": "0.14",
"version": "0.15",
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
"icon": "app.png",
"tags": "tool,outdoors,gps,widget",

View File

@ -212,7 +212,7 @@ exports.getStats = function(statIDs, options) {
stats["dist"]={
title : "Dist",
getValue : function() { return state.distance; },
getString : function() { return require("locale").distance(state.distance); },
getString : function() { return require("locale").distance(state.distance,2); },
};
}
if (statIDs.includes("step")) {
@ -251,7 +251,7 @@ exports.getStats = function(statIDs, options) {
stats["speed"]={
title : "Speed",
getValue : function() { return state.curSpeed*3.6; }, // in kph
getString : function() { return require("locale").speed(state.curSpeed*3.6); },
getString : function() { return require("locale").speed(state.curSpeed*3.6,2); },
};
}
if (statIDs.includes("caden")) {