From ae68361bd49e9eeb092401f646bc1248b8a14258 Mon Sep 17 00:00:00 2001 From: David Peer Date: Fri, 14 Jan 2022 14:29:31 +0100 Subject: [PATCH] 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); } })