mirror of https://github.com/espruino/BangleApps
Merge pull request #758 from rigrig/barclock
barclock: use timeout instead of interval, add screenshotspull/760/head
commit
5e16929733
|
@ -1312,10 +1312,11 @@
|
|||
{ "id": "barclock",
|
||||
"name": "Bar Clock",
|
||||
"icon": "clock-bar.png",
|
||||
"version":"0.05",
|
||||
"version":"0.06",
|
||||
"description": "A simple digital clock showing seconds as a bar",
|
||||
"tags": "clock",
|
||||
"type":"clock",
|
||||
"readme": "README.md",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
{"name":"barclock.app.js","url":"clock-bar.js"},
|
||||
|
@ -3212,7 +3213,6 @@
|
|||
"readme": "README.md",
|
||||
"description": "An Omnitrix Showpiece",
|
||||
"tags": "game",
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"omnitrix.app.js","url":"omnitrix.app.js"},
|
||||
{"name":"omnitrix.img","url":"omnitrix.icon.js","evaluate":true}
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
0.02: Apply locale, 12-hour setting
|
||||
0.03: Fix dates drawing over each other at midnight
|
||||
0.04: Small bugfix
|
||||
0.05: Clock does not start if app Languages is not installed
|
||||
0.05: Clock does not start if app Languages is not installed
|
||||
0.06: Improve accuracy
|
|
@ -0,0 +1,6 @@
|
|||
# Bar Clock
|
||||
A simple digital clock showing seconds as a horizontal bar.
|
||||
|
||||
| 24hr style | 12hr style |
|
||||
| --- | --- |
|
||||
|  |  |
|
|
@ -12,12 +12,12 @@
|
|||
date.setMonth(1, 3) // februari: months are zero-indexed
|
||||
const localized = locale.date(date, true)
|
||||
locale.dayFirst = /3.*2/.test(localized)
|
||||
|
||||
|
||||
locale.hasMeridian = false
|
||||
if(typeof locale.meridian === 'function') { // function does not exists if languages app is not installed
|
||||
locale.hasMeridian = (locale.meridian(date) !== '')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
const screen = {
|
||||
width: g.getWidth(),
|
||||
|
@ -124,7 +124,7 @@
|
|||
g.fillRect(0, timeTop, screen.width, screen.height)
|
||||
}
|
||||
|
||||
let lastSeconds
|
||||
let lastSeconds, tTick
|
||||
const tick = function () {
|
||||
g.reset()
|
||||
const date = new Date()
|
||||
|
@ -136,20 +136,20 @@
|
|||
}
|
||||
// the bar only gets larger, so drawing on top of the previous one is fine
|
||||
drawBar(date)
|
||||
|
||||
lastSeconds = seconds
|
||||
// schedule next update
|
||||
const millis = date.getMilliseconds()
|
||||
tTick = setTimeout(tick, 1000-millis)
|
||||
}
|
||||
|
||||
let iTick
|
||||
const start = function () {
|
||||
lastSeconds = 99 // force redraw
|
||||
tick()
|
||||
iTick = setInterval(tick, 1000)
|
||||
}
|
||||
const stop = function () {
|
||||
if (iTick) {
|
||||
clearInterval(iTick)
|
||||
iTick = undefined
|
||||
if (tTick) {
|
||||
clearTimeout(tTick)
|
||||
tTick = undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue