diff --git a/apps/andark/ChangeLog b/apps/andark/ChangeLog index 341868930..748f10fad 100644 --- a/apps/andark/ChangeLog +++ b/apps/andark/ChangeLog @@ -1,4 +1,6 @@ 0.01: Release 0.02: Rename app 0.03: Add type "clock" -0.04: changed update cylce, when locked +0.04: Changed update cylce, when locked +0.05: Fix support for dark theme + support widgets + + add settings for widgets, order of drawing and hour hand length diff --git a/apps/andark/README.md b/apps/andark/README.md index 3770c1017..9034677c2 100644 --- a/apps/andark/README.md +++ b/apps/andark/README.md @@ -1,10 +1,16 @@ -# Analog Clock +# Dark Analog Clock ## Features -* second hand +* second hand (only on unlocked screen) * date -* battery percantage -* no widgets +* battery percentage (showing charge status with color) +* turned off or swipeable widgets (choose in settings) ![logo](andark_screen.png) + +## Settings + +* whether to load widgets, or not; if widgets are loaded, they are swipeable from the top; if not, NO ACTIONS of widgets are available +* date and battery can be printed both below hands (as if hands were physical) and above (more readable) +* hour hand can be made slighly shorter to improve readability when minute hand is behind a number diff --git a/apps/andark/andark_screen.png b/apps/andark/andark_screen.png index 2ac54c1cd..1f0e5b089 100644 Binary files a/apps/andark/andark_screen.png and b/apps/andark/andark_screen.png differ diff --git a/apps/andark/app.js b/apps/andark/app.js index 865e3e708..2ffdd453e 100644 --- a/apps/andark/app.js +++ b/apps/andark/app.js @@ -1,78 +1,14 @@ +const defaultSettings = { + loadWidgets : false, + textAboveHands : false, + shortHrHand : false +}; +const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); + const c={"x":g.getWidth()/2,"y":g.getHeight()/2}; + let zahlpos=[]; -let unlock = false; - -function zeiger(len,dia,tim){ - const x =c.x+ Math.cos(tim)*len/2, - y =c.y + Math.sin(tim)*len/2, - d={"d":3,"x":dia/2*Math.cos(tim+Math.PI/2),"y":dia/2*Math.sin(tim+Math.PI/2)}, - pol=[c.x-d.x,c.y-d.y,c.x+d.x,c.y+d.y,x+d.x,y+d.y,x-d.x,y-d.y]; - return pol; - -} - -function draw(){ - const d=new Date(); - let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds(); - //draw black rectangle in the middle to clear screen from scale and hands - g.setColor(0,0,0); - g.fillRect(10,10,2*c.x-10,2*c.x-10); - g.setColor(1,1,1); - - if(h>12){ - h=h-12; - } - //calculates the position of the minute, second and hour hand - h=2*Math.PI/12*(h+m/60)-Math.PI/2; - //more accurate - //m=2*Math.PI/60*(m+s/60)-Math.PI/2; - m=2*Math.PI/60*(m)-Math.PI/2; - - s=2*Math.PI/60*s-Math.PI/2; - g.setFontAlign(0,0); - g.setFont("Vector",10); - let dateStr = " "+require("locale").date(d)+" "; - g.drawString(dateStr, c.x, c.y+20, true); - // g.drawString(d.getDate(),1.4*c.x,c.y,true); - g.drawString(Math.round(E.getBattery()/5)*5+"%",c.x,c.y+40,true); - drawlet(); - //g.setColor(1,0,0); - const hz = zeiger(100,5,h); - g.fillPoly(hz,true); - // g.setColor(1,1,1); - const minz = zeiger(150,5,m); - g.fillPoly(minz,true); - if (unlock){ - const sekz = zeiger(150,2,s); - g.fillPoly(sekz,true); - } - g.fillCircle(c.x,c.y,4); - - - -} -//draws the scale once the app is startet -function drawScale(){ - for(let i=-14;i<47;i++){ - const win=i*2*Math.PI/60; - let d=2; - if(i%5==0){d=5;} - g.fillPoly(zeiger(300,d,win),true); - g.setColor(0,0,0); - g.fillRect(10,10,2*c.x-10,2*c.x-10); - g.setColor(1,1,1); - } -} - -//draws the numbers on the screen - -function drawlet(){ - g.setFont("Vector",20); - for(let i = 0;i<12;i++){ - g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2]); - } -} -//calcultes the Position of the numbers when app starts and saves them in an array +//calculates the Position of the numbers when app starts and saves them in an array function setlet(){ let sk=1; for(let i=-10;i<50;i+=5){ @@ -89,36 +25,130 @@ function setlet(){ } } setlet(); + +let unlock = false; + +function zeiger(len,dia,tim){ + const x=c.x+ Math.cos(tim)*len/2, + y=c.y + Math.sin(tim)*len/2, + d={"d":3,"x":dia/2*Math.cos(tim+Math.PI/2),"y":dia/2*Math.sin(tim+Math.PI/2)}, + pol=[c.x-d.x,c.y-d.y,c.x+d.x,c.y+d.y,x+d.x,y+d.y,x-d.x,y-d.y]; + return pol; + +} + +function drawHands(d) { + let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds(); + g.setColor(1,1,1); + + if(h>12){ + h=h-12; + } + //calculates the position of the minute, second and hour hand + h=2*Math.PI/12*(h+m/60)-Math.PI/2; + //more accurate + //m=2*Math.PI/60*(m+s/60)-Math.PI/2; + m=2*Math.PI/60*(m)-Math.PI/2; + + s=2*Math.PI/60*s-Math.PI/2; + //g.setColor(1,0,0); + const hz = zeiger(settings.shortHrHand?88:100,5,h); + g.fillPoly(hz,true); + //g.setColor(1,1,1); + const minz = zeiger(150,5,m); + g.fillPoly(minz,true); + if (unlock){ + const sekz = zeiger(150,2,s); + g.fillPoly(sekz,true); + } + g.fillCircle(c.x,c.y,4); +} + +function drawText(d) { + g.setFont("Vector",10); + g.setBgColor(0,0,0); + g.setColor(1,1,1); + let dateStr = require("locale").date(d); + g.drawString(dateStr, c.x, c.y+20, true); + let batStr = Math.round(E.getBattery()/5)*5+"%"; + if (Bangle.isCharging()) { + g.setBgColor(1,0,0); + } + g.drawString(batStr, c.x, c.y+40, true); +} + +function drawNumbers() { + //draws the numbers on the screen + g.setFont("Vector",20); + g.setColor(1,1,1); + g.setBgColor(0,0,0); + for(let i = 0;i<12;i++){ + g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true); + } +} + +function draw(){ + // draw black rectangle in the middle to clear screen from scale and hands + g.setColor(0,0,0); + g.fillRect(10,10,2*c.x-10,2*c.x-10); + // prepare for drawing the text + g.setFontAlign(0,0); + // do drawing + drawNumbers(); + const d=new Date(); + if (settings.textAboveHands) { + drawHands(d); drawText(d); + } else { + drawText(d); drawHands(d); + } +} + +//draws the scale once the app is startet +function drawScale(){ + // clear the screen + g.setBgColor(0,0,0); + g.clear(); + // draw the ticks of the scale + for(let i=-14;i<47;i++){ + const win=i*2*Math.PI/60; + let d=2; + if(i%5==0){d=5;} + g.fillPoly(zeiger(300,d,win),true); + g.setColor(0,0,0); + g.fillRect(10,10,2*c.x-10,2*c.x-10); + g.setColor(1,1,1); + } +} + +//// main running sequence //// + +if (settings.loadWidgets) { + // Prepare widgets + Bangle.loadWidgets(); + require("widget_utils").swipeOn(); +} // Clear the screen once, at startup -g.setBgColor(0,0,0); -g.clear(); drawScale(); draw(); -let secondInterval= setInterval(draw, 1000); -// Stop updates when LCD is off, restart when on +let secondInterval = setInterval(draw, 1000); +// Stop updates when LCD is off, restart when on Bangle.on('lcdPower',on=>{ if (secondInterval) clearInterval(secondInterval); secondInterval = undefined; if (on) { - secondInterval = setInterval(draw, 1000); - draw(); // draw immediately + secondInterval = setInterval(draw, 1000); + draw(); // draw immediately } }); Bangle.on('lock',on=>{ + unlock = !on; if (secondInterval) clearInterval(secondInterval); - secondInterval = undefined; - if (!on) { - secondInterval = setInterval(draw, 1000); - unlock = true; - draw(); // draw immediately - }else{ - secondInterval = setInterval(draw, 60000); - unlock = false; - draw(); - } - }); + secondInterval = setInterval(draw, unlock ? 1000 : 60000); + draw(); // draw immediately +}); +Bangle.on('charging',on=>{draw();}); // Show launcher when middle button pressed Bangle.setUI("clock"); diff --git a/apps/andark/metadata.json b/apps/andark/metadata.json index 3e2b3116e..706b962e9 100644 --- a/apps/andark/metadata.json +++ b/apps/andark/metadata.json @@ -1,15 +1,18 @@ { "id": "andark", "name": "Analog Dark", "shortName":"AnDark", - "version":"0.04", + "version":"0.05", "description": "analog clock face without disturbing widgets", "icon": "andark_icon.png", "type": "clock", "tags": "clock", "supports" : ["BANGLEJS2"], + "screenshots": [{"url":"andark_screen.png"}], "readme": "README.md", "storage": [ {"name":"andark.app.js","url":"app.js"}, + {"name":"andark.settings.js","url":"settings.js"}, {"name":"andark.img","url":"app_icon.js","evaluate":true} - ] + ], + "data": [{"name":"andark.json"}] } diff --git a/apps/andark_w/settings.js b/apps/andark/settings.js similarity index 94% rename from apps/andark_w/settings.js rename to apps/andark/settings.js index a9092cc74..708913705 100644 --- a/apps/andark_w/settings.js +++ b/apps/andark/settings.js @@ -9,7 +9,7 @@ const save = () => require('Storage').write('andark.json', settings); const appMenu = { - '': {title: 'alarm'}, '< Back': back, + '': {title: 'andark'}, '< Back': back, /*LANG*/'Load widgets': { value : !!settings.loadWidgets, onchange : v => { settings.loadWidgets=v; save();} diff --git a/apps/andark_w/ChangeLog b/apps/andark_w/ChangeLog deleted file mode 100644 index 102a6612d..000000000 --- a/apps/andark_w/ChangeLog +++ /dev/null @@ -1 +0,0 @@ -0.01: Release based on andark v0.04 diff --git a/apps/andark_w/README.md b/apps/andark_w/README.md deleted file mode 100644 index bf86b52a8..000000000 --- a/apps/andark_w/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Analog Clock with widgets - -## Features - -* second hand -* date -* battery percentage -* swipeable widgets - -![logo](andark_w_screen.png) - -## Changes from the original Analog Clock (`andark`) - -* behaves correctly on the light theme (no change in the image) -* date, battery and numbers are printed above hands -* hour hand is slighly shorter to improve readability when minute hand is behind a number -* widgets are loaded and are swipeable from the top diff --git a/apps/andark_w/andark_w_icon.png b/apps/andark_w/andark_w_icon.png deleted file mode 100644 index ab9cb0ac3..000000000 Binary files a/apps/andark_w/andark_w_icon.png and /dev/null differ diff --git a/apps/andark_w/andark_w_screen.png b/apps/andark_w/andark_w_screen.png deleted file mode 100644 index 1f0e5b089..000000000 Binary files a/apps/andark_w/andark_w_screen.png and /dev/null differ diff --git a/apps/andark_w/app.js b/apps/andark_w/app.js deleted file mode 100644 index 2120d75a3..000000000 --- a/apps/andark_w/app.js +++ /dev/null @@ -1,148 +0,0 @@ -const defaultSettings = { - loadWidgets : false, - textAboveHands : false, - shortHrHand : false -} -const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); - -const c={"x":g.getWidth()/2,"y":g.getHeight()/2}; - -let zahlpos=[]; -//calculates the Position of the numbers when app starts and saves them in an array -function setlet(){ - let sk=1; - for(let i=-10;i<50;i+=5){ - let win=i*2*Math.PI/60; - let xsk =c.x+2+Math.cos(win)*(c.x-10), - ysk =c.y+2+Math.sin(win)*(c.x-10); - if(sk==3){xsk-=10;} - if(sk==6){ysk-=10;} - if(sk==9){xsk+=10;} - if(sk==12){ysk+=10;} - if(sk==10){xsk+=3;} - zahlpos.push([sk,xsk,ysk]); - sk+=1; - } -} -setlet(); - -let unlock = false; - -function zeiger(len,dia,tim){ - const x=c.x+ Math.cos(tim)*len/2, - y=c.y + Math.sin(tim)*len/2, - d={"d":3,"x":dia/2*Math.cos(tim+Math.PI/2),"y":dia/2*Math.sin(tim+Math.PI/2)}, - pol=[c.x-d.x,c.y-d.y,c.x+d.x,c.y+d.y,x+d.x,y+d.y,x-d.x,y-d.y]; - return pol; - -} - -function drawHands(d) { - let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds(); - //draw black rectangle in the middle to clear screen from scale and hands - g.setColor(0,0,0); - g.fillRect(10,10,2*c.x-10,2*c.x-10); - g.setColor(1,1,1); - - if(h>12){ - h=h-12; - } - //calculates the position of the minute, second and hour hand - h=2*Math.PI/12*(h+m/60)-Math.PI/2; - //more accurate - //m=2*Math.PI/60*(m+s/60)-Math.PI/2; - m=2*Math.PI/60*(m)-Math.PI/2; - - s=2*Math.PI/60*s-Math.PI/2; - //g.setColor(1,0,0); - const hz = zeiger(settings.shortHrHand?88:100,5,h); - g.fillPoly(hz,true); - // g.setColor(1,1,1); - const minz = zeiger(150,5,m); - g.fillPoly(minz,true); - if (unlock){ - const sekz = zeiger(150,2,s); - g.fillPoly(sekz,true); - } - g.fillCircle(c.x,c.y,4); -} - -function drawText(d) { - g.setFontAlign(0,0); - g.setFont("Vector",10); - g.setBgColor(0,0,0); - g.setColor(1,1,1); - let dateStr = require("locale").date(d); - g.drawString(dateStr, c.x, c.y+20, true); - // g.drawString(d.getDate(),1.4*c.x,c.y,true); - let batStr = Math.round(E.getBattery()/5)*5+"%"; - if (Bangle.isCharging()) { - g.setColor(1,0,0); - } - g.drawString(batStr, c.x, c.y+40, true); - - //draws the numbers on the screen - g.setFont("Vector",20); - g.setColor(1,1,1); - for(let i = 0;i<12;i++){ - g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true); - } -} - -function draw(){ - const d=new Date(); - if (settings.textAboveHands) { - drawHands(); drawText(); - } else { - drawText(); drawHands(); - } -} - -//draws the scale once the app is startet -function drawScale(){ - // clear the screen - g.setBgColor(0,0,0); - g.clear(); - // draw the ticks of the scale - for(let i=-14;i<47;i++){ - const win=i*2*Math.PI/60; - let d=2; - if(i%5==0){d=5;} - g.fillPoly(zeiger(300,d,win),true); - g.setColor(0,0,0); - g.fillRect(10,10,2*c.x-10,2*c.x-10); - g.setColor(1,1,1); - } -} - -//// main running sequence //// - -if (settings.loadWidgets) { - // Prepare widgets - Bangle.loadWidgets(); - require("widget_utils").swipeOn(); -} -// Clear the screen once, at startup -drawScale(); -draw(); - -let secondInterval = setInterval(draw, 1000); - -// Stop updates when LCD is off, restart when on -Bangle.on('lcdPower',on=>{ - if (secondInterval) clearInterval(secondInterval); - secondInterval = undefined; - if (on) { - secondInterval = setInterval(draw, 1000); - draw(); // draw immediately - } -}); -Bangle.on('lock',on=>{ - unlock = !on; - if (secondInterval) clearInterval(secondInterval); - secondInterval = setInterval(draw, unlock ? 1000 : 60000); - draw(); // draw immediately -}); - -// Show launcher when middle button pressed -Bangle.setUI("clock"); diff --git a/apps/andark_w/app_icon.js b/apps/andark_w/app_icon.js deleted file mode 100644 index e755d50f8..000000000 --- a/apps/andark_w/app_icon.js +++ /dev/null @@ -1 +0,0 @@ -require("heatshrink").decompress(atob("mEwxH+CiHXAhARMADoiHFRAzVJMQrMF7pseAH630RWw2Q67+EAAQnRMSYoFAYQwPNrAnGF9wuXP4xUHAY4tKZR4NEF54hRF6xNCJ4QFFF8bVXF6rmVF/avJGC7LNDqIaYF/4v/DUgvZDAQcTCYkHh0Og4FEhwMCAoovfEYQvpEYoECMwQ1GF9abCF8IkBAYQ2CBQgYEFyYvGKgYDDF4omSeCQoDGQgviXYiSERw4vjGxAvoS4guceBIvsMAaHDF8YwFAE4vvSA4v/SHgjCABgkkF74waX9zxuGYYw/GGAA==")) diff --git a/apps/andark_w/metadata.json b/apps/andark_w/metadata.json deleted file mode 100644 index 522da2430..000000000 --- a/apps/andark_w/metadata.json +++ /dev/null @@ -1,18 +0,0 @@ -{ "id": "andark_w", - "name": "Analog Dark with widgets support", - "shortName":"AnDarkW", - "version":"0.01", - "description": "analog clock face with swipeable widgets", - "icon": "andark_w_icon.png", - "type": "clock", - "tags": "clock", - "supports" : ["BANGLEJS2"], - "screenshots": [{"url":"andark_w_screen.png"}], - "readme": "README.md", - "storage": [ - {"name":"andark_w.app.js","url":"app.js"}, - {"name":"andark_w.settings.js","url":"settings.js"}, - {"name":"andark_w.img","url":"app_icon.js","evaluate":true} - ] - "data": [{"name":"andark.json"}] -}