From a40eb22cdf1215ddb70ae0c5a67012a1cb3ae05a Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Tue, 22 Feb 2022 22:40:34 +0100 Subject: [PATCH] Temporarily load widgets and overwrite their draw methods to hide them --- apps/imageclock/app.js | 12 ++++++++++++ apps/imageclock/demomode.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 apps/imageclock/demomode.js diff --git a/apps/imageclock/app.js b/apps/imageclock/app.js index df3f11cb7..502927538 100644 --- a/apps/imageclock/app.js +++ b/apps/imageclock/app.js @@ -551,4 +551,16 @@ if (!events || events.includes("charging")) { Bangle.on('charging', handleCharging); } +function clearWidgetsDraw(){ + if (WIDGETS && typeof WIDGETS === "object") { + for (let wd of WIDGETS) { + wd.draw = () => {}; + wd.area = ""; + } + } +} + +Bangle.loadWidgets(); +clearWidgetsDraw(); + handleLock(Bangle.isLocked(), true); diff --git a/apps/imageclock/demomode.js b/apps/imageclock/demomode.js new file mode 100644 index 000000000..8c9d19195 --- /dev/null +++ b/apps/imageclock/demomode.js @@ -0,0 +1,29 @@ +var demostate = 0; +function demoMode(){ + lockedRedraw = 2000; + unlockedRedraw = 2000; + for (var c in multistates){ + multistates[c] = ()=>{return ["on","off"][demostate%2];}; + if (c == "WeatherTemperatureUnit") multistates[c] = ()=>{return ["celsius","fahrenheit"][demostate%2];}; + if (c == "Notifications") multistates[c] = ()=>{return ["on","off","vibrate"][demostate%3];}; + } + for (var c in numbers){ + if (c.contains("Minute")) numbers[c] = ()=>{return Math.floor((Math.random() * 9) + 1);}; + if (c.contains("Second")) numbers[c] = ()=>{return Math.floor((Math.random() * 9) + 1);}; + if (c.contains("Hour")) numbers[c] = ()=>{return Math.floor((Math.random() * 9) + 1);}; + } + for (var c in numbers){ + if (c.contains("Ones")) numbers[c] = ()=>{return Math.floor((Math.random() * 9) + 1);}; + if (c.contains("Tens")) numbers[c] = ()=>{return Math.floor((Math.random() * 9) + 1);}; + } + numbers.Pulse = ()=>{return Math.floor((Math.random() * 60) + 40);}; + numbers.Steps = ()=>{return Math.floor((Math.random() * 10000) + 10);}; + numbers.Temperature = ()=>{return Math.floor((Math.random() * 15) + 10);}; + numbers.Pressure = ()=>{return Math.floor((Math.random() * 1000) + 10);}; + numbers.Altitude = ()=>{return Math.floor((Math.random() * 1000) + 10);}; + numbers.WeatherCode = ()=>{return Math.floor((Math.random() * 800) + 100);}; + numbers.WeatherTemperature = ()=>{return Math.floor((Math.random() * 10) + 0);}; +} +demoMode(); +handleLock(false); +setInterval(()=>{demostate++;},1000);