mirror of https://github.com/espruino/BangleApps
Added mtnclock support for reading weather.json
This allows the use of owmweather or weather to provide weather updates to mtnclock.pull/2561/head
parent
f609c6d9a8
commit
f4f07806a6
|
@ -323,6 +323,11 @@ function setWeather() {
|
||||||
draw(a);
|
draw(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readWeather() {
|
||||||
|
data = require("Storage").readJSON('weather.json').weather;
|
||||||
|
require("Storage").write('mtnclock.json', data);
|
||||||
|
}
|
||||||
|
|
||||||
const _GB = global.GB;
|
const _GB = global.GB;
|
||||||
global.GB = (event) => {
|
global.GB = (event) => {
|
||||||
if (event.t==="weather") {
|
if (event.t==="weather") {
|
||||||
|
@ -340,6 +345,7 @@ function queueDraw() {
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
drawTimeout = setTimeout(function() {
|
drawTimeout = setTimeout(function() {
|
||||||
drawTimeout = undefined;
|
drawTimeout = undefined;
|
||||||
|
readWeather();
|
||||||
setWeather();
|
setWeather();
|
||||||
queueDraw();
|
queueDraw();
|
||||||
}, 60000 - (Date.now() % 60000));
|
}, 60000 - (Date.now() % 60000));
|
||||||
|
|
Loading…
Reference in New Issue