weatherclock v0.06

master
lunctis-viribus 2023-02-28 17:57:51 +01:00
parent 6e4f6c69c0
commit b163721777
2 changed files with 8 additions and 8 deletions

View File

@ -3,4 +3,4 @@
0.03: Minor layout extra spaces. 0.03: Minor layout extra spaces.
0.04: Layout now compatible with Bangle.js 2. 0.04: Layout now compatible with Bangle.js 2.
0.05: Use weather condition code for icon selection. 0.05: Use weather condition code for icon selection.
0.06: Dev-Add settings menu to hide elements. Images placed into functions for performance. Use lib.js of weather app for drawing weather icons. WeatherClock icons now match weather conditions better. 0.06: WeatherClock icons now reflect weather conditions better. Add settings menu to hide elements and to use weather icons of Weather app. Images placed into functions for performance.

View File

@ -1,11 +1,11 @@
const Layout = require("Layout"); const Layout = require("Layout");
const storage = require('Storage'); const storage = require("Storage");
const locale = require("locale"); const locale = require("locale");
const SETTINGS_FILE = "weatherClock.json"; const SETTINGS_FILE = "weatherClock.json";
let s; let s;
const w = require('weather'); const w = require("weather");
// weather icons from https://icons8.com/icon/set/weather/color // Weather icons from https://icons8.com/icon/set/weather/color
function getSun() { function getSun() {
return require("heatshrink").decompress(atob("mEwwhC/AH4AbhvQC6vd7ouVC4IwUCwIwUFwQwQCYgAHDZQXc9wACC6QWDDAgXN7wXF9oXPCwowDC5guGGAYXMCw4wCC5RGJJAZGTJBiNISIylQVJrLCC5owGF65fXR7AwBC5jvhC7JIILxapDFxAXOGAy9KC4owGBAQXODAgHDC54AHC8T0FAAQSOGg4qPGA4WUGAIuVC7AA/AH4AEA=")); return require("heatshrink").decompress(atob("mEwwhC/AH4AbhvQC6vd7ouVC4IwUCwIwUFwQwQCYgAHDZQXc9wACC6QWDDAgXN7wXF9oXPCwowDC5guGGAYXMCw4wCC5RGJJAZGTJBiNISIylQVJrLCC5owGF65fXR7AwBC5jvhC7JIILxapDFxAXOGAy9KC4owGBAQXODAgHDC54AHC8T0FAAQSOGg4qPGA4WUGAIuVC7AA/AH4AEA="));
} }
@ -91,10 +91,10 @@ function chooseIconByCode(code) {
} }
} }
// timeout used to update every minute // Timeout used to update every minute
var drawTimeout; var drawTimeout;
// schedule a draw for the next minute // Schedule a draw for the next minute
function queueDraw() { function queueDraw() {
if (drawTimeout) clearTimeout(drawTimeout); if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() { drawTimeout = setTimeout(function() {
@ -121,7 +121,7 @@ function draw() {
cLayout.wIcon.src = s.icon ? showIconT : getDummy; cLayout.wIcon.src = s.icon ? showIconT : getDummy;
} }
const wind = locale.speed(curr.wind).match(/^(\D*\d*)(.*)$/); const wind = locale.speed(curr.wind).match(/^(\D*\d*)(.*)$/);
cLayout.wind.label = wind[1] + " " + wind[2] + " " + (curr.wrose||'').toUpperCase(); cLayout.wind.label = wind[1] + " " + wind[2] + " " + (curr.wrose||"").toUpperCase();
} }
else{ else{
cLayout.temp.label = "Err"; cLayout.temp.label = "Err";
@ -130,7 +130,7 @@ function draw() {
} }
cLayout.clear(); cLayout.clear();
cLayout.render(); cLayout.render();
// queue draw in one minute // Queue draw in one minute
queueDraw(); queueDraw();
} }