From d8bfad06ae46a018c3a7ede4779c52e1345f7782 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 20 Apr 2022 17:03:15 +0200 Subject: [PATCH 1/6] LCARS V0.22 - Fixed alarm and use build in steps function as fallback. --- apps/lcars/ChangeLog | 1 + apps/lcars/README.md | 3 +-- apps/lcars/lcars.app.js | 22 +++++++++++++--------- apps/lcars/metadata.json | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/lcars/ChangeLog b/apps/lcars/ChangeLog index 9c17376bb..e622feb1f 100644 --- a/apps/lcars/ChangeLog +++ b/apps/lcars/ChangeLog @@ -19,3 +19,4 @@ 0.19: Alarms can not go bigger than 100. 0.20: Use alarm for alarm functionality instead of own implementation. 0.21: Add custom theming. +0.22: Fix alarm and add build in function for step counting. \ No newline at end of file diff --git a/apps/lcars/README.md b/apps/lcars/README.md index 65e31b3cc..6d4b18b9a 100644 --- a/apps/lcars/README.md +++ b/apps/lcars/README.md @@ -1,8 +1,7 @@ # LCARS clock A simple LCARS inspired clock. -Note: To display the steps, the wpedom app is required. To show weather data -such as temperature, humidity or window you BangleJS must be connected +To show weather data such as temperature, humidity or window you BangleJS must be connected with Gadgetbride and the weather app must be installed. To use the timer the "sched" app must be installed on your device. diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 3210d6832..aa50fb348 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -1,3 +1,4 @@ +const TIMER_IDX = "lcars"; const SETTINGS_FILE = "lcars.setting.json"; const locale = require('locale'); const storage = require('Storage') @@ -35,7 +36,7 @@ let lcarsViewPos = 0; var plotMonth = false; -function convert24to16(input) +function convert24to16(input) { let RGB888 = parseInt(input.replace(/^#/, ''), 16); let r = (RGB888 & 0xFF0000) >> 16; @@ -171,7 +172,7 @@ Graphics.prototype.setFontAntonioLarge = function(scale) { */ var drawTimeout; function queueDraw() { - + // Faster updates during alarm to ensure that it is // shown correctly... var timeout = isAlarmEnabled() ? 10000 : 60000; @@ -556,17 +557,20 @@ function draw(){ * Step counter via widget */ function getSteps() { + var steps = 0; try{ if (WIDGETS.wpedom !== undefined) { - return WIDGETS.wpedom.getSteps(); + steps = WIDGETS.wpedom.getSteps(); } else if (WIDGETS.activepedom !== undefined) { - return WIDGETS.activepedom.getSteps(); + steps = WIDGETS.activepedom.getSteps(); + } else { + steps = Bangle.getHealthStatus("day").steps; } } catch(ex) { // In case we failed, we can only show 0 steps. } - return 0; + return steps; } @@ -639,7 +643,7 @@ function increaseAlarm(){ var minutes = isAlarmEnabled() ? getAlarmMinutes() : 0; var alarm = require('sched') alarm.setAlarm(TIMER_IDX, { - timer : (minutes+5)*60*1000, + timer : (minutes+5)*60*1000, }); alarm.reload(); } catch(ex){ } @@ -654,9 +658,9 @@ function decreaseAlarm(){ alarm.setAlarm(TIMER_IDX, undefined); if(minutes > 0){ - alarm.setAlarm(TIMER_IDX, { - timer : minutes*60*1000, - }); + alarm.setAlarm(TIMER_IDX, { + timer : minutes*60*1000, + }); } alarm.reload(); diff --git a/apps/lcars/metadata.json b/apps/lcars/metadata.json index 5f3eaa971..40da1b37f 100644 --- a/apps/lcars/metadata.json +++ b/apps/lcars/metadata.json @@ -3,7 +3,7 @@ "name": "LCARS Clock", "shortName":"LCARS", "icon": "lcars.png", - "version":"0.21", + "version":"0.22", "readme": "README.md", "supports": ["BANGLEJS2"], "description": "Library Computer Access Retrieval System (LCARS) clock.", From a02e6d79c4af51639f255d1b5ea79b8de148145e Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 20 Apr 2022 17:05:05 +0200 Subject: [PATCH 2/6] Use same data for settings otherwise settings change after first save. --- apps/lcars/lcars.settings.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/lcars/lcars.settings.js b/apps/lcars/lcars.settings.js index 2656a54ab..c948c7763 100644 --- a/apps/lcars/lcars.settings.js +++ b/apps/lcars/lcars.settings.js @@ -5,9 +5,9 @@ const storage = require('Storage') let settings = { alarm: -1, - dataRow1: "Battery", - dataRow2: "Steps", - dataRow3: "Temp", + dataRow1: "Steps", + dataRow2: "Temp", + dataRow3: "Battery", speed: "kph", fullscreen: false, themeColor1BG: "#FF9900", @@ -23,7 +23,7 @@ storage.write(SETTINGS_FILE, settings) } - + var dataOptions = ["Steps", "Battery", "VREF", "HRM", "Temp", "Humidity", "Wind", "Altitude", "CoreT"]; var speedOptions = ["kph", "mph"]; var color_options = ['Green','Orange','Cyan','Purple','Red','Blue','Yellow','White']; From 058beeae94fb397e7bfecdc11a5a4d29351b9082 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 20 Apr 2022 17:09:33 +0200 Subject: [PATCH 3/6] Better stability for weather --- apps/lcars/lcars.app.js | 49 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index aa50fb348..590ae56bb 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -579,38 +579,35 @@ function getWeather(){ try { weatherJson = storage.readJSON('weather.json'); + var weather = weatherJson.weather; + + // Temperature + weather.temp = locale.temp(weather.temp-273.15); + + // Humidity + weather.hum = weather.hum + "%"; + + // Wind + const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/); + var speedFactor = settings.speed == "kph" ? 1.0 : 1.0 / 1.60934; + weather.wind = Math.round(wind[1] * speedFactor); + + return weather + } catch(ex) { // Return default } - if(weatherJson === undefined){ - return { - temp: "-", - hum: "-", - txt: "-", - wind: "-", - wdir: "-", - wrose: "-" - }; - } - - var weather = weatherJson.weather; - - // Temperature - weather.temp = locale.temp(weather.temp-273.15); - - // Humidity - weather.hum = weather.hum + "%"; - - // Wind - const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/); - var speedFactor = settings.speed == "kph" ? 1.0 : 1.0 / 1.60934; - weather.wind = Math.round(wind[1] * speedFactor); - - return weather + return { + temp: " ? ", + hum: " ? ", + txt: " ? ", + wind: " ? ", + wdir: " ? ", + wrose: " ? " + }; } - /* * Handle alarm */ From 945bc31b366b4693c1c1e07cd2e5aafb412c0637 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 20 Apr 2022 17:15:10 +0200 Subject: [PATCH 4/6] Fix info alignment --- apps/lcars/lcars.app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 590ae56bb..072eead54 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -291,6 +291,9 @@ function drawInfo(){ return; } + // Draw Infor is called from different sources so + // we have to ensure that the alignment is always the same. + g.setFontAlign(-1, -1, 0); g.setFontAntonioMedium(); g.setColor(color2); g.clearRect(120, 10, g.getWidth(), 75); From f8a2c280fe6c1f8bb42bf4151423ce09606fc1e9 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 20 Apr 2022 17:24:11 +0200 Subject: [PATCH 5/6] Show last healt status for HRM --- apps/lcars/lcars.app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 072eead54..92c4e8e7c 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -238,7 +238,7 @@ function _drawData(key, y, c){ value = E.getAnalogVRef().toFixed(2) + "V"; } else if(key == "HRM"){ - value = Math.round(Bangle.getHealthStatus("day").bpm); + value = Math.round(Bangle.getHealthStatus("last").bpm); } else if (key == "TEMP"){ var weather = getWeather(); From 088453d8ce5ffbd0ae8f30d0f3af76ca691d2bf4 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 20 Apr 2022 17:24:50 +0200 Subject: [PATCH 6/6] HRM as default --- apps/lcars/lcars.app.js | 2 +- apps/lcars/lcars.settings.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 92c4e8e7c..07ca51fd9 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -5,7 +5,7 @@ const storage = require('Storage') let settings = { alarm: -1, dataRow1: "Steps", - dataRow2: "Temp", + dataRow2: "HRM", dataRow3: "Battery", speed: "kph", fullscreen: false, diff --git a/apps/lcars/lcars.settings.js b/apps/lcars/lcars.settings.js index c948c7763..b64feb30e 100644 --- a/apps/lcars/lcars.settings.js +++ b/apps/lcars/lcars.settings.js @@ -6,7 +6,7 @@ let settings = { alarm: -1, dataRow1: "Steps", - dataRow2: "Temp", + dataRow2: "HRM", dataRow3: "Battery", speed: "kph", fullscreen: false,