mirror of https://github.com/espruino/BangleApps
Fixed buttons at startup, app visibility, added AM/PM support
parent
90988a309b
commit
8550b1a09a
|
@ -3318,17 +3318,16 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ "id": "hcclock",
|
{ "id": "hcclock",
|
||||||
"name": "High Contrast Clock",
|
"name": "Hi-Contrast Clock",
|
||||||
"icon": "hcclock-icon.png",
|
"icon": "hcclock-icon.png",
|
||||||
"version":"0.01",
|
"version":"0.01",
|
||||||
"description": "High Contrast Clock : A simple yet very bold clock that aims to be readable in high luninosity environments. Uses big 10x5 pixel digits. Use BTN 1 to switch background and foreground colors.",
|
"description": "Hi-Contrast Clock : A simple yet very bold clock that aims to be readable in high luninosity environments. Uses big 10x5 pixel digits. Use BTN 1 to switch background and foreground colors.",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"hcclock.app.js","url":"hcclock.app.js"},
|
{"name":"hcclock.app.js","url":"hcclock.app.js"},
|
||||||
{"name":"hcclock.img","url":"hcclock-icon.js","evaluate":true}
|
{"name":"hcclock.img","url":"hcclock-icon.js","evaluate":true}
|
||||||
],
|
]
|
||||||
"sortorder" : -9
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// Numbers Rect order (left, top, right, bottom)
|
// Numbers Rect order (left, top, right, bottom)
|
||||||
// Each number defines a set of rects to draw
|
// Each number defines a set of rects to draw
|
||||||
|
@ -72,6 +72,8 @@ const months = [ "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY",
|
||||||
const interval = 1000; // in ms
|
const interval = 1000; // in ms
|
||||||
const top = 32;
|
const top = 32;
|
||||||
|
|
||||||
|
let ampm = (require("Storage").readJSON("setting.json",1)||{})["12hour"];
|
||||||
|
|
||||||
let bg = 255;
|
let bg = 255;
|
||||||
let fg = 0;
|
let fg = 0;
|
||||||
|
|
||||||
|
@ -94,7 +96,7 @@ function updateTime()
|
||||||
let h = now.getHours();
|
let h = now.getHours();
|
||||||
let mo = now.getMonth();
|
let mo = now.getMonth();
|
||||||
let y = now.getFullYear();
|
let y = now.getFullYear();
|
||||||
let d = now.getDay();
|
let d = now.getDate();
|
||||||
|
|
||||||
if(h != hour)
|
if(h != hour)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +104,9 @@ function updateTime()
|
||||||
g.setColor(bg,bg,bg);
|
g.setColor(bg,bg,bg);
|
||||||
g.fillRect(0,60,240,110);
|
g.fillRect(0,60,240,110);
|
||||||
g.setColor(fg,fg,fg);
|
g.setColor(fg,fg,fg);
|
||||||
drawDigits(60, hour);
|
if(ampm)
|
||||||
|
h = h%12;
|
||||||
|
drawDigits(60, h);
|
||||||
}
|
}
|
||||||
if(m != mins)
|
if(m != mins)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +121,7 @@ function updateTime()
|
||||||
day = d;
|
day = d;
|
||||||
g.setFont("6x8", 2);
|
g.setFont("6x8", 2);
|
||||||
g.setFontAlign(0, -1, 0);
|
g.setFontAlign(0, -1, 0);
|
||||||
g.drawString(fmtDate(d,mo,y), 120, 120);
|
g.drawString(fmtDate(d,mo,y,hour), 120, 120);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +158,17 @@ function lerp(a,b,t)
|
||||||
return a + t*(b-a);
|
return a + t*(b-a);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtDate(day,month,year)
|
function fmtDate(day,month,year,hour)
|
||||||
{
|
{
|
||||||
return months[month] + " " + day + " " + year;
|
if(ampm)
|
||||||
|
{
|
||||||
|
let ap = "(AM)";
|
||||||
|
if(hour == 0 || hour > 12)
|
||||||
|
ap = "(PM)";
|
||||||
|
return months[month] + " " + day + " " + year + " "+ ap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return months[month] + " " + day + " " + year;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles Flipping colors, then refreshes the UI
|
// Handles Flipping colors, then refreshes the UI
|
||||||
|
@ -188,4 +200,3 @@ setInterval(updateTime, interval);
|
||||||
setWatch(flipColors, BTN1, true);
|
setWatch(flipColors, BTN1, true);
|
||||||
setWatch(Bangle.showLauncher, BTN2, false);
|
setWatch(Bangle.showLauncher, BTN2, false);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue