Bar clock 0.03: Fix dates drawing over each other at midnight

master
Richard de Boer 2020-04-01 11:51:06 +02:00
parent 7647c03a95
commit fb20174508
3 changed files with 8 additions and 8 deletions

View File

@ -919,7 +919,7 @@
{ "id": "barclock",
"name": "Bar Clock",
"icon": "clock-bar.png",
"version":"0.02",
"version":"0.03",
"description": "A simple digital clock showing seconds as a bar",
"tags": "clock",
"type":"clock",

View File

@ -1,2 +1,3 @@
0.01: Created Bar Clock
0.02: Apply locale, 12-hour setting
0.03: Fix dates drawing over each other at midnight

View File

@ -59,7 +59,7 @@
g.setFont(timeFont, timeFontSize)
g.drawString(timeTexts.time, screenCenter, timeY, true)
if (timeTexts.ampm !== '') {
g.setFontAlign(1, -1)
g.setFontAlign(1, -1) // right top
g.setFont(timeFont, ampmFontSize)
g.drawString(timeTexts.ampm,
// at right edge of screen , aligned with time bottom
@ -78,11 +78,10 @@
const fraction = seconds / SECONDS_PER_MINUTE
g.fillRect(0, barY, fraction * screenSize, barY + barThickness)
}
function eraseBar() {
const color = g.getColor()
g.setColor(g.getBgColor())
g.fillRect(0, barY, screenSize, barY + barThickness)
g.setColor(color)
function clearScreen() {
g.setColor(0)
g.fillRect(0, timeY - (timeFontSize * 4), screenSize, screenSize)
g.setColor(-1)
}
let lastSeconds
@ -92,7 +91,7 @@
const seconds = date.getSeconds()
if (lastSeconds > seconds) {
// new minute
eraseBar()
clearScreen()
drawDateTime(date)
}
drawBar(date)