[widalarmeta] move "Only on clock" check to top of draw
parent
d31c6ca12a
commit
7fc876237d
|
|
@ -39,6 +39,13 @@
|
||||||
} // getNextAlarm
|
} // getNextAlarm
|
||||||
|
|
||||||
function draw(_w, fromInterval) {
|
function draw(_w, fromInterval) {
|
||||||
|
|
||||||
|
// If only show on clock and not on clock
|
||||||
|
if (config.whenToShow === 1 && !Bangle.CLOCK) {
|
||||||
|
this.nextAlarm = undefined; // make sure to reload later
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.nextAlarm === undefined) {
|
if (this.nextAlarm === undefined) {
|
||||||
let alarm = getNextAlarm();
|
let alarm = getNextAlarm();
|
||||||
if (alarm === undefined) {
|
if (alarm === undefined) {
|
||||||
|
|
@ -56,49 +63,45 @@
|
||||||
let calcWidth = 0;
|
let calcWidth = 0;
|
||||||
let drawSeconds = false;
|
let drawSeconds = false;
|
||||||
|
|
||||||
// If always showing, or the clock is visible
|
// Determine text and width
|
||||||
if (config.whenToShow === 1 && !Bangle.CLOCK)
|
if (next > 0 && next <= config.maxhours*60*60*1000) {
|
||||||
return;
|
const hours = Math.floor((next-1) / 3600000).toString();
|
||||||
// Determine text and width
|
const minutes = Math.floor(((next-1) % 3600000) / 60000).toString();
|
||||||
if (next > 0 && next <= config.maxhours*60*60*1000) {
|
const seconds = Math.floor(((next-1) % 60000) / 1000).toString();
|
||||||
const hours = Math.floor((next-1) / 3600000).toString();
|
drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60);
|
||||||
const minutes = Math.floor(((next-1) % 3600000) / 60000).toString();
|
|
||||||
const seconds = Math.floor(((next-1) % 60000) / 1000).toString();
|
|
||||||
drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60);
|
|
||||||
|
|
||||||
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
||||||
g.setFontAlign(-1,0); // center font in y direction
|
g.setFontAlign(-1,0); // center font in y direction
|
||||||
g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23);
|
g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23);
|
||||||
|
|
||||||
var text = "";
|
var text = "";
|
||||||
if (config.padHours) {
|
if (config.padHours) {
|
||||||
text += hours.padStart(2, '0');
|
text += hours.padStart(2, '0');
|
||||||
} else {
|
} else {
|
||||||
text += hours;
|
text += hours;
|
||||||
}
|
}
|
||||||
text += ":" + minutes.padStart(2, '0');
|
text += ":" + minutes.padStart(2, '0');
|
||||||
if (drawSeconds) {
|
if (drawSeconds) {
|
||||||
text += ":" + seconds.padStart(2, '0');
|
text += ":" + seconds.padStart(2, '0');
|
||||||
}
|
}
|
||||||
if (config.font == 0) {
|
if (config.font == 0) {
|
||||||
g.setFont("5x9Numeric7Seg:1x2");
|
g.setFont("5x9Numeric7Seg:1x2");
|
||||||
} else if (config.font == 1) {
|
} else if (config.font == 1) {
|
||||||
g.setFont("Teletext5x9Ascii:1x2");
|
g.setFont("Teletext5x9Ascii:1x2");
|
||||||
} else {
|
} else {
|
||||||
// Default to this if no other font is set.
|
// Default to this if no other font is set.
|
||||||
g.setFont("6x8:1x2");
|
g.setFont("6x8:1x2");
|
||||||
}
|
}
|
||||||
g.drawString(text, this.x+1, this.y+12);
|
g.drawString(text, this.x+1, this.y+12);
|
||||||
|
|
||||||
calcWidth = g.stringWidth(text) + 2; // One pixel on each side
|
calcWidth = g.stringWidth(text) + 2; // One pixel on each side
|
||||||
this.bellVisible = false;
|
this.bellVisible = false;
|
||||||
} else if (config.drawBell && this.numActiveAlarms > 0) {
|
} else if (config.drawBell && this.numActiveAlarms > 0) {
|
||||||
calcWidth = 24;
|
calcWidth = 24;
|
||||||
// next alarm too far in future, draw only widalarm bell
|
// next alarm too far in future, draw only widalarm bell
|
||||||
if (this.bellVisible !== true || fromInterval !== true) {
|
if (this.bellVisible !== true || fromInterval !== true) {
|
||||||
g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y);
|
g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y);
|
||||||
this.bellVisible = true;
|
this.bellVisible = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue