Update lcars.app.js

pull/1703/head
Ronin0000 2022-04-13 16:15:49 -07:00 committed by GitHub
parent e272e71841
commit 69496ba1a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 12 deletions

View File

@ -171,11 +171,16 @@ Graphics.prototype.setFontAntonioLarge = function(scale) {
*/
var drawTimeout;
function queueDraw() {
// Faster updates during alarm to ensure that it is
// shown correctly...
var timeout = isAlarmEnabled() ? 10000 : 60000;
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, 60000 - (Date.now() % 60000));
}, timeout - (Date.now() % timeout));
}
/**
@ -527,9 +532,6 @@ function draw(){
// Queue draw first to ensure that its called in one minute again.
queueDraw();
// First handle alarm to show this correctly afterwards
handleAlarm();
// Next draw the watch face
g.reset();
g.clearRect(0, 0, g.getWidth(), g.getHeight());
@ -608,8 +610,18 @@ function getWeather(){
/*
* Handle alarm
*/
function getCurrentTimeInMinutes(){
return Math.floor(Date.now() / (1000*60));
function isAlarmEnabled(){
try{
var alarm = require('sched');
var alarmObj = alarm.getAlarm(TIMER_IDX);
if(alarmObj===undefined || !alarmObj.on){
return false;
}
return true;
} catch(ex){ }
return false;
}
function getAlarmMinutes(){
@ -640,13 +652,13 @@ function decreaseAlarm(){
var alarm = require('sched')
alarm.setAlarm(TIMER_IDX, undefined);
}
if(minutes > 0){
alarm.setAlarm(TIMER_IDX, {
timer : minutes*60*1000,
});
}
if(minutes > 0){
alarm.setAlarm(TIMER_IDX, {
timer : minutes*60*1000,
});
}
alarm.reload();
} catch(ex){ }