diff --git a/apps/gpsrec/ChangeLog b/apps/gpsrec/ChangeLog index 365405846..f923739f0 100644 --- a/apps/gpsrec/ChangeLog +++ b/apps/gpsrec/ChangeLog @@ -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) diff --git a/apps/gpsrec/app.js b/apps/gpsrec/app.js index 833a816ea..527eb780d 100644 --- a/apps/gpsrec/app.js +++ b/apps/gpsrec/app.js @@ -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); diff --git a/apps/gpsrec/metadata.json b/apps/gpsrec/metadata.json index 088b8c741..8f4736066 100644 --- a/apps/gpsrec/metadata.json +++ b/apps/gpsrec/metadata.json @@ -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", diff --git a/apps/locale/ChangeLog b/apps/locale/ChangeLog index 2dbb4febb..3354a57c1 100644 --- a/apps/locale/ChangeLog +++ b/apps/locale/ChangeLog @@ -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 \ No newline at end of file + 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) diff --git a/apps/locale/locale.html b/apps/locale/locale.html index b23225d5f..b58b4a297 100644 --- a/apps/locale/locale.html +++ b/apps/locale/locale.html @@ -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}\`, diff --git a/apps/locale/metadata.json b/apps/locale/metadata.json index c8908c7a7..20f1f72b8 100644 --- a/apps/locale/metadata.json +++ b/apps/locale/metadata.json @@ -1,7 +1,7 @@ { "id": "locale", "name": "Languages", - "version": "0.15", + "version": "0.16", "description": "Translations for different countries", "icon": "locale.png", "type": "locale", diff --git a/apps/recorder/ChangeLog b/apps/recorder/ChangeLog index e9877808c..877b1354a 100644 --- a/apps/recorder/ChangeLog +++ b/apps/recorder/ChangeLog @@ -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 \ No newline at end of file +0.14: Remove unneeded variable assignment +0.15: Show distance more accurately in conjunction with new locale app (fix #1523) diff --git a/apps/recorder/app.js b/apps/recorder/app.js index 99252e0e2..fb3dfab4f 100644 --- a/apps/recorder/app.js +++ b/apps/recorder/app.js @@ -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; diff --git a/apps/recorder/metadata.json b/apps/recorder/metadata.json index d715af38d..4146e92be 100644 --- a/apps/recorder/metadata.json +++ b/apps/recorder/metadata.json @@ -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", diff --git a/modules/exstats.js b/modules/exstats.js index 056dc9f0f..5d7cf0c2b 100644 --- a/modules/exstats.js +++ b/modules/exstats.js @@ -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")) {