Add imprecise word clock.
parent
950e6dfdbb
commit
1223184ee0
13
apps.json
13
apps.json
|
|
@ -163,6 +163,19 @@
|
|||
{"name":"wclock.img","url":"clock-word-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{ "id": "impwclock",
|
||||
"name": "Imprecise Word Clock",
|
||||
"icon": "clock-impword.png",
|
||||
"version":"0.01",
|
||||
"description": "Imprecise word clock for vacations, weekends, and those who never need accurate time.",
|
||||
"tags": "clock",
|
||||
"type":"clock",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
{"name":"impwclock.app.js","url":"clock-impword.js"},
|
||||
{"name":"impwclock.img","url":"clock-impword-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{ "id": "aclock",
|
||||
"name": "Analog Clock",
|
||||
"icon": "clock-analog.png",
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwwkEIf4A3iIBEn8ggP//8wgX/+cQl8Agc/BQPyCokQgHzmEB+ET+EfmMj+AXCmABBF4MBiIABiEC+PxC4Uwn4NB+QXMBAMzI4UxmYOBC5sfCgIvBgPzF4cfC5BgCFAMPkPwiXzL4cPmMvkAXDPAnzEgMxR4wDCGITl/AH4ApgUQbIICBAgXwBYMD+UAYoP/l4CBiUhd4QXFgIXCh73BfQUfAgIPBC4cQiIACC4cvj4PBC5AuCC48zgcwC4ZHBC5sBCAIEBF5EAC4RgDCQItCPAIXLCoQBBFgM/IoZHER4QA/AH4Anj8wgXzgX/+cQWoPyYQK9Bn/zj/wb4MTCAMf+MDAYMxkfwj8BmYXBmEzCYMf+cDmPzkMvj8zAIM/eoPyC4fy+IXDl8TmfwI4UvmYABAwIXB//xgPwBIIXCgYFBmEP/8fh/yF4sDC4QjBC4RvBF4UPB4JUBL4kAn8ROIJbBC4IIBL4hDBmaPEgBuB+EB+aPCUQUjCALn/AH4A/A"))
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/* Imprecise Word Clock - A. Blanton
|
||||
A remix of word clock
|
||||
by Gordon Williams https://github.com/gfwilliams
|
||||
- Changes the representation of time to be more general
|
||||
- Shows accurate digital time when button 1 is pressed
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
const allWords = [
|
||||
"AEARLYDN",
|
||||
"LATEYRZO",
|
||||
"MORNINGO",
|
||||
"KMIDDLEN",
|
||||
"AFTERDAY",
|
||||
"OFDZTHEC",
|
||||
"EVENINGR",
|
||||
"ORMNIGHT"
|
||||
];
|
||||
|
||||
|
||||
const timeOfDay = {
|
||||
0: ["", 0, 0],
|
||||
1: ["EARLYMORNING", 10, 11, 12, 13, 14, 02, 12, 22, 32, 42, 52, 62],
|
||||
2: ["MORNING", 02, 12, 22, 32, 42, 52, 62],
|
||||
3: ["LATEMORNING", 01, 11, 21, 31, 02, 12, 22, 32, 42, 52, 62],
|
||||
4: ["MIDDAY", 13, 23, 33, 54, 64, 74],
|
||||
5: ["EARLYAFTERNOON", 10, 20, 30, 40, 50, 04, 14, 24, 34, 44, 70, 71, 72, 73],
|
||||
6: ["AFTERNOON", 04, 14, 24, 34, 44, 70, 71, 72, 73],
|
||||
7: ["LATEAFTERNOON", 01, 11, 21, 31, 04, 14, 24, 34, 44, 70, 71, 72, 73],
|
||||
8: ["EARLYEVENING", 10, 20, 30, 40, 50, 06, 16, 26, 36, 46, 56, 66],
|
||||
9: ["EVENING", 06, 16, 26, 36, 46, 56, 66],
|
||||
10: ["NIGHT", 37, 47, 57, 67, 77],
|
||||
11: ["MIDDLEOFTHENIGHT", 32, 33, 34, 35, 36, 37, 50, 51, 54, 55, 56, 73,74,75,76,77 ],
|
||||
};
|
||||
|
||||
|
||||
// offsets and increments
|
||||
const xs = 35;
|
||||
const ys = 31;
|
||||
const dy = 22;
|
||||
const dx = 25;
|
||||
|
||||
// font size and color
|
||||
const fontSize = 3; // "6x8"
|
||||
const passivColor = 0x3186 /*grey*/ ;
|
||||
const activeColorNight = 0xF800 /*red*/ ;
|
||||
const activeColorDay = 0xFFFF /* white */;
|
||||
|
||||
function drawWordClock() {
|
||||
|
||||
|
||||
// get time
|
||||
var t = new Date();
|
||||
var h = t.getHours();
|
||||
var m = t.getMinutes();
|
||||
var time = ("0" + h).substr(-2) + ":" + ("0" + m).substr(-2);
|
||||
var day = t.getDay();
|
||||
|
||||
var hidx;
|
||||
|
||||
var activeColor = activeColorDay;
|
||||
if(h < 7 || h > 19) {activeColor = activeColorNight;}
|
||||
|
||||
g.setFont("6x8",fontSize);
|
||||
g.setColor(passivColor);
|
||||
g.setFontAlign(0, -1, 0);
|
||||
|
||||
// draw allWords
|
||||
var c;
|
||||
var y = ys;
|
||||
var x = xs;
|
||||
allWords.forEach((line) => {
|
||||
x = xs;
|
||||
for (c in line) {
|
||||
g.drawString(line[c], x, y);
|
||||
x += dx;
|
||||
}
|
||||
y += dy;
|
||||
});
|
||||
|
||||
|
||||
// Switch case isn't good for this in Js apparently so...
|
||||
if(h < 3){
|
||||
// Middle of the Night
|
||||
hidx = 11;
|
||||
}
|
||||
else if (h < 7){
|
||||
// Early Morning
|
||||
hidx = 1;
|
||||
}
|
||||
else if (h < 10){
|
||||
// Morning
|
||||
hidx = 2;
|
||||
}
|
||||
else if (h < 12){
|
||||
// Late Morning
|
||||
hidx = 3;
|
||||
}
|
||||
else if (h < 13){
|
||||
// Midday
|
||||
hidx = 4;
|
||||
}
|
||||
else if (h < 14){
|
||||
// Early afternoon
|
||||
hidx = 5;
|
||||
}
|
||||
else if (h < 16){
|
||||
// Afternoon
|
||||
hidx = 6;
|
||||
}
|
||||
else if (h < 17){
|
||||
// Late Afternoon
|
||||
hidx = 7;
|
||||
}
|
||||
else if (h < 19){
|
||||
// Early evening
|
||||
hidx = 8;
|
||||
}
|
||||
else if (h < 21){
|
||||
// evening
|
||||
hidx = 9;
|
||||
}
|
||||
else if (h < 24){
|
||||
// Night
|
||||
hidx = 10;
|
||||
}
|
||||
|
||||
// write hour in active color
|
||||
g.setColor(activeColor);
|
||||
timeOfDay[hidx][0].split('').forEach((c, pos) => {
|
||||
x = xs + (timeOfDay[hidx][pos + 1] / 10 | 0) * dx;
|
||||
y = ys + (timeOfDay[hidx][pos + 1] % 10) * dy;
|
||||
g.drawString(c, x, y);
|
||||
});
|
||||
|
||||
|
||||
// Display digital time while button 1 is pressed
|
||||
if (BTN1.read()){
|
||||
g.setColor(activeColor);
|
||||
g.clearRect(0, 215, 240, 240);
|
||||
g.drawString(time, 120, 215);
|
||||
} else { g.clearRect(0, 215, 240, 240); }
|
||||
|
||||
}
|
||||
|
||||
Bangle.on('lcdPower', function(on) {
|
||||
if (on) drawWordClock();
|
||||
});
|
||||
|
||||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
setInterval(drawWordClock, 1E4);
|
||||
drawWordClock();
|
||||
|
||||
// Show digital time while top button is pressed
|
||||
setWatch(drawWordClock, BTN1, {repeat:true,edge:"both"});
|
||||
|
||||
// Show launcher when middle button pressed
|
||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Loading…
Reference in New Issue