mirror of https://github.com/espruino/BangleApps
Added barwatch
parent
5c110a89fb
commit
28421a5e87
|
@ -0,0 +1 @@
|
||||||
|
0.01: First version
|
|
@ -0,0 +1,5 @@
|
||||||
|
# BarWatch - an experimental watch
|
||||||
|
|
||||||
|
For too long the watches have shown the time with digits or hands. No more!
|
||||||
|
With this stylish watch the time is represented by bars. Up to 24 as the day goes by.
|
||||||
|
Practical? Not really, but a different look!
|
|
@ -0,0 +1 @@
|
||||||
|
E.toArrayBuffer(atob("l0uwkE/4A/AH4A/AB0gicQmUB+EPgEigExh8gj8A+ECAgMQn4WCgcACyotWC34W/C34W/CycACw0wgYWFBYIWCAAc/+YGHCAgNFACkxl8hGYwAMLYUvCykQC34WycoIW/C34W0gAWTmUjkUzkbmSAFY="))
|
|
@ -0,0 +1,80 @@
|
||||||
|
// timeout used to update every minute
|
||||||
|
var drawTimeout;
|
||||||
|
|
||||||
|
// schedule a draw for the next minute
|
||||||
|
function queueDraw() {
|
||||||
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
|
drawTimeout = setTimeout(function() {
|
||||||
|
drawTimeout = undefined;
|
||||||
|
draw();
|
||||||
|
}, 60000 - (Date.now() % 60000));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
g.reset();
|
||||||
|
g.setBgColor(0, 1, 1);
|
||||||
|
|
||||||
|
// work out how to display the current time
|
||||||
|
var d = new Date();
|
||||||
|
var h = d.getHours(), m = d.getMinutes();
|
||||||
|
//h = 13;
|
||||||
|
//m = 59;
|
||||||
|
|
||||||
|
var battery = E.getBattery() / 100;
|
||||||
|
g.setColor(1-battery,0+battery,0);
|
||||||
|
//console.log(battery);
|
||||||
|
g.setColor(1,1,1);
|
||||||
|
|
||||||
|
var bx_offset = 10, by_offset = 35;
|
||||||
|
var b_width = 8, b_height = 60;
|
||||||
|
var b_space = 5;
|
||||||
|
|
||||||
|
// hour bars
|
||||||
|
for(var i=0; i<h; i++){
|
||||||
|
if(i > 11){
|
||||||
|
by_offset = 105;
|
||||||
|
}
|
||||||
|
var iter = i % 12;
|
||||||
|
//console.log(iter);
|
||||||
|
g.fillRect(bx_offset+(b_width*(iter+1))+(b_space*iter),
|
||||||
|
by_offset,
|
||||||
|
bx_offset+(b_width*iter)+(b_space*iter),
|
||||||
|
by_offset+b_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// minute bar
|
||||||
|
if(h > 11){
|
||||||
|
by_offset = 105;
|
||||||
|
}
|
||||||
|
var m_bar = h % 12;
|
||||||
|
if(m != 0){
|
||||||
|
g.fillRect(bx_offset+(b_width*(m_bar+1))+(b_space*m_bar),
|
||||||
|
by_offset+b_height-m,
|
||||||
|
bx_offset+(b_width*m_bar)+(b_space*m_bar),
|
||||||
|
by_offset+b_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// queue draw in one minute
|
||||||
|
queueDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
Bangle.loadWidgets();
|
||||||
|
|
||||||
|
// Clear the screen once, at startup
|
||||||
|
g.clear();
|
||||||
|
// draw immediately at first
|
||||||
|
draw();
|
||||||
|
// Stop updates when LCD is off, restart when on
|
||||||
|
Bangle.on('lcdPower',on=>{
|
||||||
|
if (on) {
|
||||||
|
draw(); // draw immediately, queue redraw
|
||||||
|
} else { // stop draw timer
|
||||||
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
|
drawTimeout = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Bangle.drawWidgets();
|
||||||
|
Bangle.setUI("clock");
|
Binary file not shown.
After Width: | Height: | Size: 973 B |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"id": "barwatch",
|
||||||
|
"name": "BarWatch",
|
||||||
|
"shortName":"BarWatch",
|
||||||
|
"version":"0.01",
|
||||||
|
"description": "A watch that displays the time using bars. One bar for each hour.",
|
||||||
|
"readme": "README.md",
|
||||||
|
"icon": "barwatch.png",
|
||||||
|
"tags": "clock",
|
||||||
|
"type": "clock",
|
||||||
|
"allow_emulator":true,
|
||||||
|
"screenshots" : [ { "url": "screenshot.png" } ],
|
||||||
|
"supports" : ["BANGLEJS2"],
|
||||||
|
"storage": [
|
||||||
|
{"name":"barwatch.app.js","url":"app.js"},
|
||||||
|
{"name":"barwatch.img","url":"app-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue