analog clock
parent
7eed118055
commit
ff75d91266
12
apps.json
12
apps.json
|
|
@ -48,6 +48,18 @@
|
||||||
{"name":"*wclock","url":"clock-word-icon.js","evaluate":true}
|
{"name":"*wclock","url":"clock-word-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{ "id": "aclock",
|
||||||
|
"name": "Analog Clock",
|
||||||
|
"icon": "clock-analog.png",
|
||||||
|
"description": "An Analog Clock",
|
||||||
|
"tags": "clock",
|
||||||
|
"type":"clock",
|
||||||
|
"storage": [
|
||||||
|
{"name":"+aclock","url":"clock-analog.json"},
|
||||||
|
{"name":"-aclock","url":"clock-analog.js"},
|
||||||
|
{"name":"*aclock","url":"clock-analog-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
},
|
||||||
{ "id": "trex",
|
{ "id": "trex",
|
||||||
"name": "T-Rex",
|
"name": "T-Rex",
|
||||||
"icon": "trex.png",
|
"icon": "trex.png",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
require("heatshrink").decompress(atob("mEwghC/AE8IxAAEwAWVDB4WIDBwWJAAIWPmf//8zDBpFDwYVBAAc4JJYWJDAoXKn4SC+EPAgXzC5JGCx4qDC4n//BIIEIRCEC4v/GBBdHC4xhCIw5dDC5BhCJAgXCRQoXGJAQXEUhAXHJAyNGC5KRCC7p2FC5B4CC5kggQXOBwvyBQMvSA4XL+EIwCoIC8ZHCgYXNO44LBBIiPPCAIwFC5DXGAAMwGAjvPGA4XIwYXHGALBDnAXFhCQHGAaOFwAXGPA4bFC4xIMIxIXDJBJGEC4xICSJCNEIwowEMJBdCFwwXEMJBdCC5BICDA4WDIw4wEAAMzCoMzBAgWIDAwAGCxRJEAAxFJDBgWNDBAWPAH4AYA=="))
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
g.clear();
|
||||||
|
|
||||||
|
var minuteDate = new Date();
|
||||||
|
var secondDate = new Date();
|
||||||
|
|
||||||
|
function line(angle, r1,r2) {
|
||||||
|
var a = angle*Math.PI/180;
|
||||||
|
g.drawLine(
|
||||||
|
120+Math.sin(a)*r1,
|
||||||
|
120-Math.cos(a)*r1,
|
||||||
|
120+Math.sin(a)*r2,
|
||||||
|
120-Math.cos(a)*r2);
|
||||||
|
}
|
||||||
|
function hand(angle, r1,r2) {
|
||||||
|
var a = angle*Math.PI/180;
|
||||||
|
var r3 = 3;
|
||||||
|
var p = Math.PI/2;
|
||||||
|
g.fillPoly([
|
||||||
|
120+Math.sin(a)*r1,
|
||||||
|
120-Math.cos(a)*r1,
|
||||||
|
120+Math.sin(a+p)*r3,
|
||||||
|
120-Math.cos(a+p)*r3,
|
||||||
|
120+Math.sin(a)*r2,
|
||||||
|
120-Math.cos(a)*r2,
|
||||||
|
120+Math.sin(a-p)*r3,
|
||||||
|
120-Math.cos(a-p)*r3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawAll() {
|
||||||
|
g.clear();
|
||||||
|
g.setColor(0,0,0.3);
|
||||||
|
for (var i=0;i<60;i++)
|
||||||
|
line(360*i/60, 92, 95);
|
||||||
|
secondDate = minuteDate = new Date();
|
||||||
|
onSecond();
|
||||||
|
onMinute();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSecond() {
|
||||||
|
g.setColor(0,0,0.3);
|
||||||
|
line(360*secondDate.getSeconds()/60, 92, 95);
|
||||||
|
g.setColor(1,0,0);
|
||||||
|
secondDate = new Date();
|
||||||
|
line(360*secondDate.getSeconds()/60, 92, 95);
|
||||||
|
g.setColor(1,1,1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMinute() {
|
||||||
|
g.setColor(0,0,0);
|
||||||
|
hand(360*minuteDate.getHours()/12, -10, 50);
|
||||||
|
hand(360*minuteDate.getMinutes()/60, -10, 85);
|
||||||
|
oldMinute = new Date();
|
||||||
|
g.setColor(1,1,1);
|
||||||
|
hand(360*minuteDate.getHours()/12, -10, 50);
|
||||||
|
hand(360*minuteDate.getMinutes()/60, -10, 85);
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(onSecond,1000);
|
||||||
|
setInterval(onMinute,60*1000);
|
||||||
|
drawAll();
|
||||||
|
|
||||||
|
Bangle.on('lcdPower',function(on) {
|
||||||
|
if (on) {
|
||||||
|
g.clear();
|
||||||
|
drawAll();
|
||||||
|
drawWidgets();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name":"Analog Clock","type":"clock",
|
||||||
|
"icon":"*aclock",
|
||||||
|
"src":"-aclock",
|
||||||
|
"sortorder":-10
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,4 +1,3 @@
|
||||||
// Enable 'Set Current Time' in Settings -> Communications before sending
|
|
||||||
(function(){ // make our own scope so this is GC'd when intervals are cleared
|
(function(){ // make our own scope so this is GC'd when intervals are cleared
|
||||||
// Offscreen buffer
|
// Offscreen buffer
|
||||||
var buf = Graphics.createArrayBuffer(240,86,1,{msb:true});
|
var buf = Graphics.createArrayBuffer(240,86,1,{msb:true});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue