Simplify scheduling code since it wasn't playing well with widgets
parent
7633f9e275
commit
f5ae409a92
|
|
@ -498,23 +498,12 @@ let locked = false,
|
||||||
var interval = 30,
|
var interval = 30,
|
||||||
timeout;
|
timeout;
|
||||||
|
|
||||||
function setupInterval() {
|
function setupInterval(force) {
|
||||||
if (timeout)
|
if (timeout)
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
if (!locked || charging)
|
let stopped = locked && !charging;
|
||||||
tick(locked);
|
timeout = setTimeout(setupInterval, stopped ? 60000 : 30);
|
||||||
let trigger;
|
tick(stopped && !force);
|
||||||
let schedule = interval => {
|
|
||||||
timeout = setTimeout(trigger, interval | 0);
|
|
||||||
// print(interval);
|
|
||||||
};
|
|
||||||
trigger = _ => {
|
|
||||||
if (!locked || charging) interval = 30;
|
|
||||||
else interval -= (interval - 130) * 0.15;
|
|
||||||
tick(locked);
|
|
||||||
schedule(interval > 120 ? 60000 : interval);
|
|
||||||
};
|
|
||||||
schedule(interval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(addr, y) {
|
function test(addr, y) {
|
||||||
|
|
@ -581,7 +570,7 @@ function probe() {
|
||||||
print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride);
|
print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride);
|
||||||
gfx.init(start, stride, E.getAddressOf(sintable, true));
|
gfx.init(start, stride, E.getAddressOf(sintable, true));
|
||||||
gfx.setCamera(0, 0, -300 << 8);
|
gfx.setCamera(0, 0, -300 << 8);
|
||||||
setupInterval();
|
setupInterval(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue