From a746510f0bf1bd4b12fba8fe2239c45f1c684f82 Mon Sep 17 00:00:00 2001 From: David Peer Date: Fri, 14 Jan 2022 13:05:17 +0100 Subject: [PATCH 01/10] Included altitude. --- apps/lcars/lcars.app.js | 40 +++++++++++++++++++++++++----------- apps/lcars/lcars.settings.js | 8 ++++---- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 3b9745a7a..e3a9d143b 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -116,11 +116,27 @@ function queueDraw() { } +function printRow(text, value, y, c){ + g.setColor(c); + g.fillRect(79, y-2, 85 ,y+18); + + g.setFontAlign(0,-1,0); + g.drawString(value, 110, y); + + g.setColor(c); + g.setFontAlign(-1,-1,0); + g.fillRect(133, y-2, 165 ,y+18); + g.fillCircle(161, y+8, 10); + g.setColor(cBlack); + g.drawString(text, 135, y); +} + function printData(key, y, c){ g.setFontAlign(-1,-1,0); key = key.toUpperCase() var text = key; var value = "ERR"; + var should_print= true; if(key == "STEPS"){ text = "STEP"; @@ -145,22 +161,22 @@ function printData(key, y, c){ var weather = getWeather(); value = weather.hum + "%"; + } else if (key == "ALTITUDE"){ + should_print= false; + text = "ALT"; + Bangle.getPressure().then(function(data){ + value = data.altitude.toFixed(0); + printRow(text, value, y, c); + }) + } else if(key == "CORET"){ value = locale.temp(parseInt(E.getTemperature())); } - g.setColor(c); - g.fillRect(79, y-2, 85 ,y+18); - - g.setFontAlign(0,-1,0); - g.drawString(value, 110, y); - - g.setColor(c); - g.setFontAlign(-1,-1,0); - g.fillRect(133, y-2, 165 ,y+18); - g.fillCircle(161, y+8, 10); - g.setColor(cBlack); - g.drawString(text, 135, y); + // Print for all datapoints that are not async + if(should_print){ + printRow(text, value, y, c); + } } function drawHorizontalBgLine(color, x1, x2, y, h){ diff --git a/apps/lcars/lcars.settings.js b/apps/lcars/lcars.settings.js index ba630799a..076dea4d1 100644 --- a/apps/lcars/lcars.settings.js +++ b/apps/lcars/lcars.settings.js @@ -18,14 +18,14 @@ storage.write(SETTINGS_FILE, settings) } - var data_options = ["Steps", "Battery", "VREF", "HRM", "Temp", "Humidity", "CoreT"]; + var data_options = ["Steps", "Battery", "VREF", "HRM", "Temp", "Humidity", "Altitude", "CoreT"]; E.showMenu({ '': { 'title': 'LCARS Clock' }, '< Back': back, 'Row 1': { value: 0 | data_options.indexOf(settings.dataRow1), - min: 0, max: 6, + min: 0, max: 7, format: v => data_options[v], onchange: v => { settings.dataRow1 = data_options[v]; @@ -34,7 +34,7 @@ }, 'Row 2': { value: 0 | data_options.indexOf(settings.dataRow2), - min: 0, max: 6, + min: 0, max: 7, format: v => data_options[v], onchange: v => { settings.dataRow2 = data_options[v]; @@ -43,7 +43,7 @@ }, 'Row 3': { value: 0 | data_options.indexOf(settings.dataRow3), - min: 0, max: 6, + min: 0, max: 7, format: v => data_options[v], onchange: v => { settings.dataRow3 = data_options[v]; From ebb35f75aa4fe759096338bab6735509d58860f1 Mon Sep 17 00:00:00 2001 From: David Peer Date: Fri, 14 Jan 2022 13:13:49 +0100 Subject: [PATCH 02/10] Stability improvement for alt. --- apps/lcars/lcars.app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index e3a9d143b..771a3e08a 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -165,8 +165,12 @@ function printData(key, y, c){ should_print= false; text = "ALT"; Bangle.getPressure().then(function(data){ - value = data.altitude.toFixed(0); - printRow(text, value, y, c); + if(data && data.altitude){ + value = data.altitude.toFixed(0); + printRow(text, value, y, c); + } else { + printRow(text, "-", y, c); + } }) } else if(key == "CORET"){ From ae68361bd49e9eeb092401f646bc1248b8a14258 Mon Sep 17 00:00:00 2001 From: David Peer Date: Fri, 14 Jan 2022 14:29:31 +0100 Subject: [PATCH 03/10] Stability improvements for data --- apps/lcars/lcars.app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 771a3e08a..6e2768998 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -131,11 +131,23 @@ function printRow(text, value, y, c){ g.drawString(text, 135, y); } + function printData(key, y, c){ + try{ + _printData(key, y, c); + } catch(ex){ + var text = key.toUpperCase(); + var value = "ERR-2"; + printRow(text, value, y, c); + } +} + + +function _printData(key, y, c){ g.setFontAlign(-1,-1,0); key = key.toUpperCase() var text = key; - var value = "ERR"; + var value = "ERR-1"; var should_print= true; if(key == "STEPS"){ @@ -164,12 +176,13 @@ function printData(key, y, c){ } else if (key == "ALTITUDE"){ should_print= false; text = "ALT"; + + // Immediately print something - avoid that its empty + printRow(text, "", y, c); Bangle.getPressure().then(function(data){ if(data && data.altitude){ value = data.altitude.toFixed(0); printRow(text, value, y, c); - } else { - printRow(text, "-", y, c); } }) From eb4279d2cee43c1d3261458a64882e4c23260480 Mon Sep 17 00:00:00 2001 From: David Peer Date: Fri, 14 Jan 2022 14:34:46 +0100 Subject: [PATCH 04/10] Better error handling --- apps/lcars/lcars.app.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 6e2768998..0bd6ced11 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -136,9 +136,7 @@ function printData(key, y, c){ try{ _printData(key, y, c); } catch(ex){ - var text = key.toUpperCase(); - var value = "ERR-2"; - printRow(text, value, y, c); + // Show last error - next try hopefully works. } } @@ -147,7 +145,7 @@ function _printData(key, y, c){ g.setFontAlign(-1,-1,0); key = key.toUpperCase() var text = key; - var value = "ERR-1"; + var value = "ERR"; var should_print= true; if(key == "STEPS"){ From 100457a56f3cef8a9ece0702b98315c5b7626a16 Mon Sep 17 00:00:00 2001 From: David Peer Date: Sat, 15 Jan 2022 14:42:33 +0100 Subject: [PATCH 05/10] Minor improvements - use bpm via build in function getHealthStatus --- apps/lcars/lcars.app.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 0bd6ced11..ac043a432 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -26,10 +26,8 @@ let cGrey = "#424242"; * Global lcars variables */ let lcarsViewPos = 0; -let drag; -let hrmValue = 0; +// let hrmValue = 0; var plotMonth = false; -var disableInfoUpdate = true; // When gadgetbridge connects, step infos cannot be loaded /* * Requirements and globals @@ -132,16 +130,17 @@ function printRow(text, value, y, c){ } -function printData(key, y, c){ +function drawData(key, y, c){ try{ - _printData(key, y, c); + _drawData(key, y, c); } catch(ex){ // Show last error - next try hopefully works. } } -function _printData(key, y, c){ +function _drawData(key, y, c){ + g.setFontAntonioMedium(); g.setFontAlign(-1,-1,0); key = key.toUpperCase() var text = key; @@ -160,7 +159,7 @@ function _printData(key, y, c){ value = E.getAnalogVRef().toFixed(2) + "V"; } else if(key == "HRM"){ - value = hrmValue; + value = Bangle.getHealthStatus("day").bpm.toFixed(0); } else if (key == "TEMP"){ var weather = getWeather(); @@ -169,7 +168,7 @@ function _printData(key, y, c){ } else if (key == "HUMIDITY"){ text = "HUM"; var weather = getWeather(); - value = weather.hum + "%"; + value = weather.hum; } else if (key == "ALTITUDE"){ should_print= false; @@ -304,9 +303,9 @@ function drawPosition0(){ // Draw data g.setFontAlign(-1, -1, 0); g.setColor(cWhite); - printData(settings.dataRow1, 97, cOrange); - printData(settings.dataRow2, 122, cPurple); - printData(settings.dataRow3, 147, cBlue); + drawData(settings.dataRow1, 97, cOrange); + drawData(settings.dataRow2, 122, cPurple); + drawData(settings.dataRow3, 147, cBlue); // Draw state drawState(); @@ -478,6 +477,7 @@ function getWeather(){ }; } else { weather.temp = locale.temp(parseInt(weather.temp-273.15)) + weather.hum = weather.hum + "%"; } return weather; @@ -550,10 +550,6 @@ Bangle.on('charging',function(charging) { drawState(); }); -Bangle.on('HRM', function (hrm) { - hrmValue = hrm.bpm; -}); - function increaseAlarm(){ if(isAlarmEnabled()){ From 7b1624a18ed4b2a6c241c21546a451e7a94c0d20 Mon Sep 17 00:00:00 2001 From: David Peer Date: Sun, 16 Jan 2022 11:41:28 +0100 Subject: [PATCH 06/10] Use math.round to get precise values. --- apps/lcars/lcars.app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index ac043a432..4ff6d37d6 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -159,7 +159,7 @@ function _drawData(key, y, c){ value = E.getAnalogVRef().toFixed(2) + "V"; } else if(key == "HRM"){ - value = Bangle.getHealthStatus("day").bpm.toFixed(0); + value = Math.round(Bangle.getHealthStatus("day").bpm); } else if (key == "TEMP"){ var weather = getWeather(); @@ -178,7 +178,7 @@ function _drawData(key, y, c){ printRow(text, "", y, c); Bangle.getPressure().then(function(data){ if(data && data.altitude){ - value = data.altitude.toFixed(0); + value = Math.round(data.altitude); printRow(text, value, y, c); } }) @@ -476,7 +476,7 @@ function getWeather(){ wrose: "-" }; } else { - weather.temp = locale.temp(parseInt(weather.temp-273.15)) + weather.temp = locale.temp(Math.round(weather.temp-273.15)) weather.hum = weather.hum + "%"; } From 838bae3dedcfa03239df0104bbf888f307d5e858 Mon Sep 17 00:00:00 2001 From: David Peer Date: Sun, 16 Jan 2022 11:43:13 +0100 Subject: [PATCH 07/10] Print row can be assync. Therefore we set the font there. --- apps/lcars/lcars.app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 4ff6d37d6..2b9976a1a 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -115,6 +115,8 @@ function queueDraw() { function printRow(text, value, y, c){ + g.setFontAntonioMedium(); + g.setFontAlign(-1,-1,0); g.setColor(c); g.fillRect(79, y-2, 85 ,y+18); @@ -140,8 +142,6 @@ function drawData(key, y, c){ function _drawData(key, y, c){ - g.setFontAntonioMedium(); - g.setFontAlign(-1,-1,0); key = key.toUpperCase() var text = key; var value = "ERR"; From dec56414c81ff2ccf116e1fa8796ed7ff860db0e Mon Sep 17 00:00:00 2001 From: David Peer Date: Sun, 16 Jan 2022 11:44:48 +0100 Subject: [PATCH 08/10] Added description to printRow --- apps/lcars/lcars.app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 2b9976a1a..81a501481 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -113,7 +113,11 @@ function queueDraw() { }, 60000 - (Date.now() % 60000)); } - +/** + * This function plots a data row in LCARS style. + * Note: It can be called async and therefore, the text alignment and + * font is set each time the function is called. + */ function printRow(text, value, y, c){ g.setFontAntonioMedium(); g.setFontAlign(-1,-1,0); From 53db4b2a04735440e13811b2a37d49b7c5b1a956 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 19 Jan 2022 10:13:40 +0100 Subject: [PATCH 09/10] Version 0.14 --- apps.json | 2 +- apps/lcars/ChangeLog | 5 +++-- apps/lcars/README.md | 13 +++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps.json b/apps.json index 14e12c164..07c80d083 100644 --- a/apps.json +++ b/apps.json @@ -4567,7 +4567,7 @@ "name": "LCARS Clock", "shortName":"LCARS", "icon": "lcars.png", - "version":"0.13", + "version":"0.14", "readme": "README.md", "supports": ["BANGLEJS2"], "description": "Library Computer Access Retrieval System (LCARS) clock.", diff --git a/apps/lcars/ChangeLog b/apps/lcars/ChangeLog index dba05915b..8d2eb6d2d 100644 --- a/apps/lcars/ChangeLog +++ b/apps/lcars/ChangeLog @@ -9,5 +9,6 @@ 0.09: Tab anywhere to open the launcher. 0.10: Removed swipes to be compatible with the Pattern Launcher. Stability improvements. 0.11: Show the gadgetbridge weather temperature (settings). -0.12: Added humidity to data. -0.13: Improved battery visualization. \ No newline at end of file +0.12: Added humidity as option to display. +0.13: Improved battery visualization. +0.14: Added altitude as option to display. \ No newline at end of file diff --git a/apps/lcars/README.md b/apps/lcars/README.md index 46e134f78..2b86921e5 100644 --- a/apps/lcars/README.md +++ b/apps/lcars/README.md @@ -13,10 +13,10 @@ To contribute you can open a PR at this [GitHub Repo]( https://github.com/peerda * Full screen mode - widgets are still loaded but not shown. * Tab on left/right to switch between different screens. * Cusomizable data that is shown on screen 1 (steps, weather etc.) - * Shows random images of real planets. + * Shows random and real images of planets. * Tap on top/bottom of screen 1 to activate an alarm. * The lower orange line indicates the battery level. - * Display graphs for steps + hrm on the second screen. + * Display graphs (day or month) for steps + hrm on the second screen. ## Data that can be configured * Steps - Steps loaded via the health module @@ -25,16 +25,17 @@ To contribute you can open a PR at this [GitHub Repo]( https://github.com/peerda * HRM - Last measured HRM * Temp - Weather temperature loaded via the weather module + gadgetbridge * Humidity - Humidity loaded via the weather module + gadgetbridge + * Altitude - Shows the altitude in m. * CoreT - Temperature of device ## Multiple screens support -Access different screens via swipe left/ right +Access different screens via tap on the left/ right side of the screen ![](screenshot.png) ![](screenshot_2.png) ## Contributors -- Initial creation and improvements: [David Peer](https://github.com/peerdavid). -- Improvements: [Adam Schmalhofer](https://github.com/adamschmalhofer). -- Improvements: [Jon Warrington](https://github.com/BartokW). +- [David Peer](https://github.com/peerdavid). +- [Adam Schmalhofer](https://github.com/adamschmalhofer). +- [Jon Warrington](https://github.com/BartokW). From b2db7f0a7fa5346700cf3022c99d8d91c0f6a165 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 19 Jan 2022 10:14:46 +0100 Subject: [PATCH 10/10] Typo --- apps/lcars/ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/lcars/ChangeLog b/apps/lcars/ChangeLog index 8d2eb6d2d..1abd519ab 100644 --- a/apps/lcars/ChangeLog +++ b/apps/lcars/ChangeLog @@ -9,6 +9,6 @@ 0.09: Tab anywhere to open the launcher. 0.10: Removed swipes to be compatible with the Pattern Launcher. Stability improvements. 0.11: Show the gadgetbridge weather temperature (settings). -0.12: Added humidity as option to display. +0.12: Added humidity as an option to display. 0.13: Improved battery visualization. -0.14: Added altitude as option to display. \ No newline at end of file +0.14: Added altitude as an option to display. \ No newline at end of file