diff --git a/apps/widanclk/ChangeLog b/apps/widanclk/ChangeLog new file mode 100644 index 000000000..115067b80 --- /dev/null +++ b/apps/widanclk/ChangeLog @@ -0,0 +1 @@ +0.01: New app diff --git a/apps/widanclk/metadata.json b/apps/widanclk/metadata.json new file mode 100644 index 000000000..07200d92d --- /dev/null +++ b/apps/widanclk/metadata.json @@ -0,0 +1,13 @@ +{ + "id": "widanclk", + "name": "Analog clock widget", + "version": "0.01", + "description": "A simple analog clock widget that appears when not showing a fullscreen clock", + "icon": "widget.png", + "type": "widget", + "tags": "widget,clock", + "supports": ["BANGLEJS","BANGLEJS2"], + "storage": [ + {"name":"widanclk.wid.js","url":"widget.js"} + ] +} diff --git a/apps/widanclk/widget.js b/apps/widanclk/widget.js new file mode 100644 index 000000000..85d970cdf --- /dev/null +++ b/apps/widanclk/widget.js @@ -0,0 +1,24 @@ +/* Simple analog clock that appears in the widget bar if no other clock +is running. We update once per minute, but don't bother stopping +if the */ +WIDGETS["wdanclk"]={area:"tl",width:Bangle.CLOCK?0:24,draw:function() { + if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not... + this.width = Bangle.CLOCK?0:24; + return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw + } + if (!this.width) return; // if size not right, return + g.reset(); + let d = new Date(); + let x=this.x+12, y=this.y+12, + ah = (d.getHours()+d.getMinutes()/60)*Math.PI/6, + am = d.getMinutes()*Math.PI/30; + g.drawCircle(x, y, 11). + drawLine(x,y, x+Math.sin(ah)*7, y-Math.cos(ah)*7). + drawLine(x,y, x+Math.sin(am)*9, y-Math.cos(am)*9); + // queue draw in one minute + if (this.drawTimeout) clearTimeout(this.drawTimeout); + this.drawTimeout = setTimeout(()=>{ + this.drawTimeout = undefined; + this.draw(); + }, 60000 - (Date.now() % 60000)); +}}; diff --git a/apps/widanclk/widget.png b/apps/widanclk/widget.png new file mode 100644 index 000000000..9e4b37c39 Binary files /dev/null and b/apps/widanclk/widget.png differ diff --git a/apps/widclk/metadata.json b/apps/widclk/metadata.json index b7bc74e11..e4d7d76d1 100644 --- a/apps/widclk/metadata.json +++ b/apps/widclk/metadata.json @@ -2,7 +2,7 @@ "id": "widclk", "name": "Digital clock widget", "version": "0.07", - "description": "A simple digital clock widget", + "description": "A simple digital clock widget that appears when not showing a fullscreen clock", "icon": "widget.png", "type": "widget", "tags": "widget,clock",