mirror of https://github.com/espruino/BangleApps
barclock: use theme colors
parent
44aa03e428
commit
a786726622
|
@ -1381,7 +1381,7 @@
|
||||||
{ "id": "barclock",
|
{ "id": "barclock",
|
||||||
"name": "Bar Clock",
|
"name": "Bar Clock",
|
||||||
"icon": "clock-bar.png",
|
"icon": "clock-bar.png",
|
||||||
"version":"0.07",
|
"version":"0.08",
|
||||||
"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",
|
||||||
|
|
|
@ -5,3 +5,4 @@
|
||||||
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.06: Improve accuracy
|
||||||
0.07: Update to use Bangle.setUI instead of setWatch
|
0.07: Update to use Bangle.setUI instead of setWatch
|
||||||
|
0.08: Use theme colors
|
|
@ -28,7 +28,6 @@ const screen = {
|
||||||
// hardcoded "settings"
|
// hardcoded "settings"
|
||||||
const settings = {
|
const settings = {
|
||||||
time: {
|
time: {
|
||||||
color: -1,
|
|
||||||
font: '6x8',
|
font: '6x8',
|
||||||
size: (is12Hour && locale.hasMeridian) ? 6 : 8,
|
size: (is12Hour && locale.hasMeridian) ? 6 : 8,
|
||||||
middle: screen.middle,
|
middle: screen.middle,
|
||||||
|
@ -40,14 +39,12 @@ const settings = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
color: -1,
|
|
||||||
font: 'Vector',
|
font: 'Vector',
|
||||||
size: 20,
|
size: 20,
|
||||||
middle: screen.height - 20, // at bottom of screen
|
middle: screen.height - 20, // at bottom of screen
|
||||||
center: screen.center,
|
center: screen.center,
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
color: -1,
|
|
||||||
top: 155, // just below time
|
top: 155, // just below time
|
||||||
thickness: 6, // matches 24h time "pixel" size
|
thickness: 6, // matches 24h time "pixel" size
|
||||||
},
|
},
|
||||||
|
@ -82,13 +79,11 @@ const dateText = function (date) {
|
||||||
|
|
||||||
const drawDateTime = function (date) {
|
const drawDateTime = function (date) {
|
||||||
const t = settings.time
|
const t = settings.time
|
||||||
g.setColor(t.color)
|
|
||||||
g.setFont(t.font, t.size)
|
g.setFont(t.font, t.size)
|
||||||
g.setFontAlign(0, 0) // centered
|
g.setFontAlign(0, 0) // centered
|
||||||
g.drawString(timeText(date), t.center, t.middle, true)
|
g.drawString(timeText(date), t.center, t.middle, true)
|
||||||
if (is12Hour && locale.hasMeridian) {
|
if (is12Hour && locale.hasMeridian) {
|
||||||
const a = settings.time.ampm
|
const a = settings.time.ampm
|
||||||
g.setColor(a.color)
|
|
||||||
g.setFont(a.font, a.size)
|
g.setFont(a.font, a.size)
|
||||||
g.setFontAlign(1, -1) // right top
|
g.setFontAlign(1, -1) // right top
|
||||||
// at right edge of screen, aligned with time bottom
|
// at right edge of screen, aligned with time bottom
|
||||||
|
@ -98,7 +93,6 @@ const drawDateTime = function (date) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const d = settings.date
|
const d = settings.date
|
||||||
g.setColor(d.color)
|
|
||||||
g.setFont(d.font, d.size)
|
g.setFont(d.font, d.size)
|
||||||
g.setFontAlign(0, 0) // centered
|
g.setFontAlign(0, 0) // centered
|
||||||
g.drawString(dateText(date), d.center, d.middle, true)
|
g.drawString(dateText(date), d.center, d.middle, true)
|
||||||
|
@ -113,14 +107,12 @@ const drawBar = function (date) {
|
||||||
}
|
}
|
||||||
const fraction = seconds / SECONDS_PER_MINUTE,
|
const fraction = seconds / SECONDS_PER_MINUTE,
|
||||||
width = fraction * screen.width
|
width = fraction * screen.width
|
||||||
g.setColor(b.color)
|
g.setColor(g.theme.fg2).fillRect(0, b.top, width, b.top + b.thickness)
|
||||||
g.fillRect(0, b.top, width, b.top + b.thickness)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearScreen = function () {
|
const clearScreen = function () {
|
||||||
g.setColor(0)
|
|
||||||
const timeTop = settings.time.middle - (settings.time.size * 4)
|
const timeTop = settings.time.middle - (settings.time.size * 4)
|
||||||
g.fillRect(0, timeTop, screen.width, screen.height)
|
g.clearRect(0, timeTop, screen.width, screen.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastSeconds, tTick
|
let lastSeconds, tTick
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 6.3 KiB |
Loading…
Reference in New Issue