From 2818c1049f50fc8706defcf0c9e2703d0b048d27 Mon Sep 17 00:00:00 2001 From: Stefan Kuehnel Date: Sun, 24 May 2020 15:05:11 +0200 Subject: [PATCH] Changed logic for reading settings --- apps.json | 2 +- apps/berlinc/berlin-clock.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index 0a9fda370..29b36dbf3 100644 --- a/apps.json +++ b/apps.json @@ -887,7 +887,7 @@ { "id": "berlinc", "name": "Berlin Clock", "icon": "berlin-clock.png", - "version":"0.03.06", + "version":"0.03.07", "description": "Berlin Clock (see https://en.wikipedia.org/wiki/Mengenlehreuhr)", "tags": "clock", "type":"clock", diff --git a/apps/berlinc/berlin-clock.js b/apps/berlinc/berlin-clock.js index 3bc04cd08..03ceafa3f 100644 --- a/apps/berlinc/berlin-clock.js +++ b/apps/berlinc/berlin-clock.js @@ -5,7 +5,9 @@ const width = g.getWidth() - 2 * offset; const height = g.getHeight() - 2 * offset; const rowHeight = height / 4; -const show_date = require("Storage").readJSON('berlin-clock.json')['showdate']; +const storage = require("Storage"); +const settingsfile = 'berlin-clock.json'; +var show_date = false; rowlights = []; @@ -58,6 +60,14 @@ function drawBerlinClock() { } } +// try to read settings +try { + const settings = storage.readJSON(settingsfile); + show_date=settings['showdate'] || false; +} catch (exception) { + console.log(exception) +} + // special function to handle display switch on Bangle.on('lcdPower', (on) => { g.clear();