mirror of https://github.com/espruino/BangleApps
[ codestyle ] Move state updating function decl out of init sequence
parent
8ebd66d99f
commit
d1232261f1
|
@ -88,6 +88,22 @@ let drawTimeout;
|
||||||
let queueMillis = 1000;
|
let queueMillis = 1000;
|
||||||
let unlock = true;
|
let unlock = true;
|
||||||
|
|
||||||
|
const updateState = function() {
|
||||||
|
if (Bangle.isLCDOn()) {
|
||||||
|
if (!Bangle.isLocked()) {
|
||||||
|
queueMillis = 1000;
|
||||||
|
unlock = true;
|
||||||
|
} else {
|
||||||
|
queueMillis = 60000;
|
||||||
|
unlock = false;
|
||||||
|
}
|
||||||
|
draw();
|
||||||
|
} else {
|
||||||
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
|
drawTimeout = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const queueDraw = function() {
|
const queueDraw = function() {
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
drawTimeout = setTimeout(function() {
|
drawTimeout = setTimeout(function() {
|
||||||
|
@ -151,22 +167,6 @@ if (settings.loadWidgets) {
|
||||||
require("widget_utils").swipeOn();
|
require("widget_utils").swipeOn();
|
||||||
} else if (global.WIDGETS) require("widget_utils").hide();
|
} else if (global.WIDGETS) require("widget_utils").hide();
|
||||||
|
|
||||||
const updateState = function() {
|
|
||||||
if (Bangle.isLCDOn()) {
|
|
||||||
if (!Bangle.isLocked()) {
|
|
||||||
queueMillis = 1000;
|
|
||||||
unlock = true;
|
|
||||||
} else {
|
|
||||||
queueMillis = 60000;
|
|
||||||
unlock = false;
|
|
||||||
}
|
|
||||||
draw();
|
|
||||||
} else {
|
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
|
||||||
drawTimeout = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Stop updates when LCD is off, restart when on
|
// Stop updates when LCD is off, restart when on
|
||||||
Bangle.on('lcdPower', updateState);
|
Bangle.on('lcdPower', updateState);
|
||||||
Bangle.on('lock', updateState);
|
Bangle.on('lock', updateState);
|
||||||
|
|
Loading…
Reference in New Issue