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", { "id": "barclock",
"name": "Bar Clock", "name": "Bar Clock",
"icon": "clock-bar.png", "icon": "clock-bar.png",
"version":"0.02", "version":"0.03",
"description": "A simple digital clock showing seconds as a bar", "description": "A simple digital clock showing seconds as a bar",
"tags": "clock", "tags": "clock",
"type":"clock", "type":"clock",

View File

@ -1,2 +1,3 @@
0.01: Created Bar Clock 0.01: Created Bar Clock
0.02: Apply locale, 12-hour setting 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.setFont(timeFont, timeFontSize)
g.drawString(timeTexts.time, screenCenter, timeY, true) g.drawString(timeTexts.time, screenCenter, timeY, true)
if (timeTexts.ampm !== '') { if (timeTexts.ampm !== '') {
g.setFontAlign(1, -1) g.setFontAlign(1, -1) // right top
g.setFont(timeFont, ampmFontSize) g.setFont(timeFont, ampmFontSize)
g.drawString(timeTexts.ampm, g.drawString(timeTexts.ampm,
// at right edge of screen , aligned with time bottom // at right edge of screen , aligned with time bottom
@ -78,11 +78,10 @@
const fraction = seconds / SECONDS_PER_MINUTE const fraction = seconds / SECONDS_PER_MINUTE
g.fillRect(0, barY, fraction * screenSize, barY + barThickness) g.fillRect(0, barY, fraction * screenSize, barY + barThickness)
} }
function eraseBar() { function clearScreen() {
const color = g.getColor() g.setColor(0)
g.setColor(g.getBgColor()) g.fillRect(0, timeY - (timeFontSize * 4), screenSize, screenSize)
g.fillRect(0, barY, screenSize, barY + barThickness) g.setColor(-1)
g.setColor(color)
} }
let lastSeconds let lastSeconds
@ -92,7 +91,7 @@
const seconds = date.getSeconds() const seconds = date.getSeconds()
if (lastSeconds > seconds) { if (lastSeconds > seconds) {
// new minute // new minute
eraseBar() clearScreen()
drawDateTime(date) drawDateTime(date)
} }
drawBar(date) drawBar(date)