Skip to content

Commit 8adfc42

Browse files
authored
Use pixel doubled font with border
1 parent a62c74f commit 8adfc42

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

apps/bigclkinfo/app.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// TODO:
2-
// Add setting to decide if the app shoud set Bangle.CLOCK=1 ?
3-
// Make an updating analog clock info entry to use as start card. (update clkinfoclk or make a new one?)
4-
51
let isClock = true; // TODO: make optional via setting.
62
if (isClock) {
73
Bangle.setUI("clock");
@@ -10,11 +6,15 @@ if (isClock) {
106
// once at the start
117
let background = require("clockbg");
128
let clock_info = require("clock_info");
9+
const R = Bangle.appRect;
10+
let txtg = Graphics.createArrayBuffer(R.w>>1, 32, 2);
11+
txtg.transparent = 0;
12+
txtg.palette = new Uint16Array([0,g.theme.bg,g.theme.bg,g.theme.fg]);
1313

1414
// Load the clock infos
1515
let clockInfoItems = clock_info.load();
16-
let clockInfoClockIdx = clockInfoItems[0].items.findIndex(c => c.name=="Clock");
17-
if (clockInfoClockIdx>0) { // pull the clock to the front (if it exists and not there already)
16+
let clockInfoClockIdx = clockInfoItems[0].items.findIndex(c => c.name=="HRM");
17+
if (clockInfoClockIdx>=0) { // pull the clock to the front
1818
let clockInfoClock = clockInfoItems[0].items[clockInfoClockIdx];
1919
clockInfoItems[0].items.splice(clockInfoClockIdx,1); // remove
2020
clockInfoItems[0].items.unshift(clockInfoClock); // add to front
@@ -23,7 +23,7 @@ if (clockInfoClockIdx>0) { // pull the clock to the front (if it exists and not
2323
let clockInfoMenu = clock_info.addInteractive(clockInfoItems, {
2424
app: "bigclkinfo",
2525
// Add the dimensions we're rendering to here - these are used to detect taps on the clock info area
26-
x : 0, y: 0, w: Bangle.appRect.w, h: Bangle.appRect.h, // You can add other information here you want to be passed into 'options' in 'draw'
26+
x : 0, y: 0, w: R.w, h: R.h, // You can add other information here you want to be passed into 'options' in 'draw'
2727
// This function draws the info
2828
draw : (itm, info, options) => {
2929
// itm: the item containing name/hasRange/etc
@@ -38,27 +38,31 @@ let clockInfoMenu = clock_info.addInteractive(clockInfoItems, {
3838
var midx = options.x+options.w/2;
3939
let scale = 4;
4040
if (info.img) clock_info.drawBorderedImage(info.img, midx-12*scale,options.y+10, {scale:scale}); // draw the image
41-
let foundFontText = g.findFont(info.text, {
42-
w : options.w-9, // optional: width available (default = screen width)
43-
h : options.h*2/5, // optional: height available (default = screen height)
41+
let foundFontText = txtg.findFont(info.text, {
42+
w : txtg.getWidth()-4, // optional: width available (default = screen width)
43+
h : txtg.getHeight()-4, // optional: height available (default = screen height)
4444
min : 10, // optional: min font height
45-
max : 60, // optional: max font height
45+
max : 24, // optional: max font height
4646
wrap : true, // optional: allow word wrap?
4747
trim : true // optional: trim to the specified height, add '...'
4848
}); // TODO: g.findFont returns max size 28px. Would be nice with bigger font if there's room.
4949
//print(foundFontText);
50-
g.setFont(foundFontText.font).setFontAlign(0,1);
51-
let y = options.y+165;
52-
// draw the text with a background
53-
g.setColor(g.theme.bg).drawString(foundFontText.text, midx-2, y)
54-
.drawString(foundFontText.text, midx+2, y)
55-
.drawString(foundFontText.text, midx, y-2)
56-
.drawString(foundFontText.text, midx, y+2);
57-
g.setColor(g.theme.fg).drawString(foundFontText.text, midx, y);
50+
txtg.clear(1);
51+
txtg.setFont(foundFontText.font).setFontAlign(0,1);
52+
txtg.drawString(foundFontText.text, txtg.getWidth()/2, txtg.getHeight()-2);
53+
txtg.filter([ // a gaussian filter
54+
0, 1, 1, 1, 0,
55+
1, 1, 1, 1, 1,
56+
1, 1, 1, 1, 1,
57+
1, 1, 1, 1, 1,
58+
0, 1, 1, 1, 0,
59+
], { w:5, h:5, div:1, max:1, filter:"max" });
60+
g.drawImage(txtg, 0, R.h - txtg.getHeight()*2-4, {scale:2});
5861
}
5962
});
63+
6064
Bangle.on("lock", function(locked) {
61-
// ensure that when unlocked, we automatically focus the clockinfo by faking a tap on it
65+
// ensure that when unlocked, we automaticlly focus the clockinfo
6266
if (!locked && !clockInfoMenu.focus)
6367
Bangle.emit("touch",0,{x:100,y:100});
6468
});

0 commit comments

Comments
 (0)