Skip to content

Commit f071817

Browse files
committed
lcdclocks Allow - and . in clockinfo menus (fix espruino#4007)
Use slightly narrower clockinfo font
1 parent 11407c8 commit f071817

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

apps/lcdclock/ChangeLog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
0.04: clock_info is loaded before widgets to match other clocks
55
0.05: fix alignment of clock items caused by 0.04 (fix #2970)
66
0.06: Minor code improvements
7-
0.07: fix special characters in clockinfo menus
7+
0.07: fix special characters in clockinfo menus
8+
0.08: Allow - and . in clockinfo menus (fix #4007)
9+
Use slightly narrower clockinfo font

apps/lcdclock/app.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Graphics.prototype.setFont7Seg = function() {
2-
return this.setFontCustom(atob("AAAAAAAAAAAACAQCAAAAAAIAd0BgMBdwAAAAAAAADuAAAB0RiMRcAAAAAiMRiLuAAAcAQCAQdwAADgiMRiIOAAAd0RiMRBwAAAAgEAgDuAAAd0RiMRdwAADgiMRiLuAAAABsAAAd0QiEQdwAADuCIRCIOAAAd0BgMBAAAAAOCIRCLuAAAd0RiMRAAAADuiEQiAAAAAd0BgMBBwAADuCAQCDuAAAdwAAAAAAAAAAAIBALuAAAdwQCAQdwAADuAIBAIAAAAd0AgEAcEAgEAdwAd0AgEAdwAADugMBgLuAAAd0QiEQcAAADgiEQiDuAAAd0AgEAAAAADgiMRiIOAAAAEAgEAdwAADuAIBALuAAAdwBAIBdwAADuAIBAIOAIBALuADuCAQCDuAAAcAQCAQdwAAAOiMRiLgAAAA=="), 32, atob("BwAAAAAAAAAAAAAAAAcCAAcHBwcHBwcHBwcEAAAAAAAABwcHBwcHBwcHBwcHCgcHBwcHBwcHBwoHBwc="), 9);
3-
}
2+
return this.setFontCustom(atob("AAAAAAAAACAQAAAAIAd0BgLuAAAAAAdwAB0RiLgAAAiMRdwAcAQCDuADgiMRBwAd0RiIOAAAgEAdwAd0RiLuADgiMRdwAABsADuiEQdwAdwRCIOADugMBAAABwRCLuADuiMRAAAd0QiAAADugMBBwAdwQCDuADuAAAAAAAABALuADuCAQdwAdwBAIAADugEAcEAdwAd0AgDuADugMBdwAd0QiDgADgiEQdwAd0AgAAADgiMRBwAAEAgDuADuAIBdwAdwBALuADuAIBBwBdwAdwQCDuADgCAQdwAB0RiLgAA="), 32, atob("BQAAAAAAAAAAAAAAAAUCAAUFBQUFBQUFBQUDAAAAAAAABQUFBQUFBQUFBQUFBwUFBQUFBQUFBQcFBQU="), 9);
3+
};
4+
/* font created with:
5+
require("sevenseg_font_tools").createFont({
6+
img : `
7+
aa j
8+
f b i
9+
fx b i
10+
fx b i
11+
gg
12+
ex c i
13+
ex c i
14+
e c i
15+
odd h`,
16+
width : 5, // width +1 for empty column
17+
colonWidth : 3, // width of colon
18+
doubleWidth : 7, // width for double-size (eg 'W' and 'M')
19+
height : 9,
20+
export : "alphanum"
21+
});
22+
*/
423

524

625
{ // must be inside our own scope here so that when we are unloaded everything disappears
@@ -38,7 +57,7 @@ let clockInfoDraw = (itm, info, options) => {
3857

3958
if (info.img) g.drawImage(info.img, options.x+2, options.y+2);
4059
var title = clockInfoItems[options.menuA].name;
41-
var text = info.text.toString().toUpperCase().replace(/[^A-Z0-9]/g, "");
60+
var text = info.text.toString().toUpperCase().replace(/[^A-Z0-9-.]/g, "");
4261
if (title!="Bangle") g.setFontAlign(1,0).drawString(title.toUpperCase(), options.x+options.w-2, options.y+14);
4362
if (g.setFont("7Seg:2").stringWidth(text)+8>options.w) g.setFont("7Seg");
4463
g.setFontAlign(0,0).drawString(text, options.x+options.w/2, options.y+40);
@@ -83,3 +102,5 @@ let clockInfoItems = require("clock_info").load();
83102
let clockInfoMenu = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:R.x, y:R.y, w:midX-2, h:barY-R.y-2, draw : clockInfoDraw});
84103
let clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:midX+2, y:R.y, w:midX-3, h:barY-R.y-2, draw : clockInfoDraw});
85104
}
105+
106+

apps/lcdclock/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ "id": "lcdclock",
22
"name": "LCD Clock",
3-
"version": "0.07",
3+
"version": "0.08",
44
"description": "A Casio-style clock, with ClockInfo areas at the top and bottom. Tap them and swipe up/down to toggle between different information",
55
"icon": "app.png",
66
"screenshots": [{"url":"screenshot.png"}],

apps/lcdclockplus/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
0.01: New App!
22
0.02: Minor code improvements
33
0.03: fix special characters in clockinfo menus
4+
0.04: Allow - and . in clockinfo menus (fix #4007)
5+
Use slightly narrower clockinfo font

apps/lcdclockplus/app.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Graphics.prototype.setFont7Seg = function() {
2-
return this.setFontCustom(atob("AAAAAAAAAAAACAQCAAAAAAIAd0BgMBdwAAAAAAAADuAAAB0RiMRcAAAAAiMRiLuAAAcAQCAQdwAADgiMRiIOAAAd0RiMRBwAAAAgEAgDuAAAd0RiMRdwAADgiMRiLuAAAABsAAAd0QiEQdwAADuCIRCIOAAAd0BgMBAAAAAOCIRCLuAAAd0RiMRAAAADuiEQiAAAAAd0BgMBBwAADuCAQCDuAAAdwAAAAAAAAAAAIBALuAAAdwQCAQdwAADuAIBAIAAAAd0AgEAcEAgEAdwAd0AgEAdwAADugMBgLuAAAd0QiEQcAAADgiEQiDuAAAd0AgEAAAAADgiMRiIOAAAAEAgEAdwAADuAIBALuAAAdwBAIBdwAADuAIBAIOAIBALuADuCAQCDuAAAcAQCAQdwAAAOiMRiLgAAAA=="), 32, atob("BwAAAAAAAAAAAAAAAAcCAAcHBwcHBwcHBwcEAAAAAAAABwcHBwcHBwcHBwcHCgcHBwcHBwcHBwoHBwc="), 9);
2+
return this.setFontCustom(atob("AAAAAAAAACAQAAAAIAd0BgLuAAAAAAdwAB0RiLgAAAiMRdwAcAQCDuADgiMRBwAd0RiIOAAAgEAdwAd0RiLuADgiMRdwAABsADuiEQdwAdwRCIOADugMBAAABwRCLuADuiMRAAAd0QiAAADugMBBwAdwQCDuADuAAAAAAAABALuADuCAQdwAdwBAIAADugEAcEAdwAd0AgDuADugMBdwAd0QiDgADgiEQdwAd0AgAAADgiMRBwAAEAgDuADuAIBdwAdwBALuADuAIBBwBdwAdwQCDuADgCAQdwAB0RiLgAA="), 32, atob("BQAAAAAAAAAAAAAAAAUCAAUFBQUFBQUFBQUDAAAAAAAABQUFBQUFBQUFBQUFBwUFBQUFBQUFBQcFBQU="), 9);
33
};
4+
/* font created with:
5+
require("sevenseg_font_tools").createFont({
6+
img : `
7+
aa j
8+
f b i
9+
fx b i
10+
fx b i
11+
gg
12+
ex c i
13+
ex c i
14+
e c i
15+
odd h`,
16+
width : 5, // width +1 for empty column
17+
colonWidth : 3, // width of colon
18+
doubleWidth : 7, // width for double-size (eg 'W' and 'M')
19+
height : 9,
20+
export : "alphanum"
21+
});
22+
*/
423

524

625
{ // must be inside our own scope here so that when we are unloaded everything disappears
@@ -48,10 +67,8 @@ let clockInfoDraw = (itm, info, options) => {
4867
if (options.focus) g.setBgColor("#FF0");
4968
g.clearRect({x:options.x,y:options.y,w:options.w,h:options.h,r:8});
5069

51-
if (info.img) {
52-
g.drawImage(info.img, options.x+1,options.y+2);
53-
}
54-
var text = info.text.toString().toUpperCase().replace(/[^A-Z0-9]/g, "");
70+
if (info.img) g.drawImage(info.img, options.x+1,options.y+2);
71+
var text = info.text.toString().toUpperCase().replace(/[^A-Z0-9-.]/g, "");
5572
if (g.setFont("7Seg:2").stringWidth(text)+24-2>options.w) g.setFont("7Seg");
5673
g.setFontAlign(0,-1).drawString(text, options.x+options.w/2+13, options.y+6);
5774
};

apps/lcdclockplus/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ "id": "lcdclockplus",
22
"name": "LCD Clock Plus",
3-
"version": "0.03",
3+
"version": "0.04",
44
"description": "A Casio-style clock, with four ClockInfo areas at the top and bottom. Tap them and swipe up/down and left/right to toggle between different information.",
55
"icon": "app.png",
66
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot2.png"}],

0 commit comments

Comments
 (0)