diff --git a/apps.json b/apps.json index 9b4953ac6..32fc5838c 100644 --- a/apps.json +++ b/apps.json @@ -4555,7 +4555,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..1abd519ab 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 an option to display. +0.13: Improved battery visualization. +0.14: Added altitude as an 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). diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 3b9745a7a..81a501481 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 @@ -115,12 +113,43 @@ function queueDraw() { }, 60000 - (Date.now() % 60000)); } - -function printData(key, y, c){ +/** + * 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); + 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 drawData(key, y, c){ + try{ + _drawData(key, y, c); + } catch(ex){ + // Show last error - next try hopefully works. + } +} + + +function _drawData(key, y, c){ key = key.toUpperCase() var text = key; var value = "ERR"; + var should_print= true; if(key == "STEPS"){ text = "STEP"; @@ -134,7 +163,7 @@ function printData(key, y, c){ value = E.getAnalogVRef().toFixed(2) + "V"; } else if(key == "HRM"){ - value = hrmValue; + value = Math.round(Bangle.getHealthStatus("day").bpm); } else if (key == "TEMP"){ var weather = getWeather(); @@ -143,24 +172,29 @@ 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; + text = "ALT"; + + // Immediately print something - avoid that its empty + printRow(text, "", y, c); + Bangle.getPressure().then(function(data){ + if(data && data.altitude){ + value = Math.round(data.altitude); + 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){ @@ -273,9 +307,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(); @@ -446,7 +480,8 @@ 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 + "%"; } return weather; @@ -519,10 +554,6 @@ Bangle.on('charging',function(charging) { drawState(); }); -Bangle.on('HRM', function (hrm) { - hrmValue = hrm.bpm; -}); - function increaseAlarm(){ if(isAlarmEnabled()){ 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];