From 615a384acfd1d3078cc9311e3f4e2722238e5ffa Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 12:19:26 +0100 Subject: [PATCH 001/104] Create cliock.app.js --- apps/cliock/cliock.app.js | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 apps/cliock/cliock.app.js diff --git a/apps/cliock/cliock.app.js b/apps/cliock/cliock.app.js new file mode 100644 index 000000000..6fd2574b8 --- /dev/null +++ b/apps/cliock/cliock.app.js @@ -0,0 +1,51 @@ +var line; +var fontsize = 2; +var locale = require("locale"); +var marginTop = 40; +var flag = false; + +var WeekDays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; + +function updateTime(){ + if (!Bangle.isLCDOn()) return; + line = 0; + var now = new Date(); + var date = locale.date(now,false); + var h = now.getHours(); + var m = now.getMinutes(); + h = h>10?h:"0"+h; + m = m>10?m:"0"+m; + g.clear(); + Bangle.loadWidgets(); + Bangle.drawWidgets(); + g.setFont("6x8",fontsize); + g.setColor("#00ff00"); + writeLine(h+":"+m); + writeLine(WeekDays[now.getDay()]); + writeLine(date); + if(flag){ + writeLine(""); + flag = false; + } + else{ + writeLine("_"); + flag = true; + } +} +function writeLineStart(){ + g.drawString(">",4,marginTop+line*20); +} +function writeLine(str){ + writeLineStart(); + g.drawString(str,17,marginTop+line*20); + line++; +} + +Bangle.on('lcdPower',function(on) { + if (on) + updateTime(); +}); +var click = setInterval(updateTime, 1000); + + + From 576bdece48379084ebcb46d50dadc3d7eeb8004a Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 12:20:53 +0100 Subject: [PATCH 002/104] Update cliock.app.js --- apps/cliock/cliock.app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/cliock/cliock.app.js b/apps/cliock/cliock.app.js index 6fd2574b8..a51f98c6b 100644 --- a/apps/cliock/cliock.app.js +++ b/apps/cliock/cliock.app.js @@ -45,6 +45,7 @@ Bangle.on('lcdPower',function(on) { if (on) updateTime(); }); +setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); var click = setInterval(updateTime, 1000); From 5031edbe6224bea354239a323278f546278b693f Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 12:46:02 +0100 Subject: [PATCH 003/104] Rename cliock.app.js to cliock.js --- apps/cliock/{cliock.app.js => cliock.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/cliock/{cliock.app.js => cliock.js} (100%) diff --git a/apps/cliock/cliock.app.js b/apps/cliock/cliock.js similarity index 100% rename from apps/cliock/cliock.app.js rename to apps/cliock/cliock.js From 8148cb02f6092c06622aeb766d9cdb7fead9f6f2 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 12:46:14 +0100 Subject: [PATCH 004/104] Rename cliock.js to app.js --- apps/cliock/{cliock.js => app.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/cliock/{cliock.js => app.js} (100%) diff --git a/apps/cliock/cliock.js b/apps/cliock/app.js similarity index 100% rename from apps/cliock/cliock.js rename to apps/cliock/app.js From 87c19f99c294fe14f05e16249f89a9df988be06d Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 12:51:23 +0100 Subject: [PATCH 005/104] Add files via upload --- apps/cliock/app.js.png | Bin 0 -> 305 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/cliock/app.js.png diff --git a/apps/cliock/app.js.png b/apps/cliock/app.js.png new file mode 100644 index 0000000000000000000000000000000000000000..4ad2d056daeb21b44ea8e6de6a57e7995bdf0b33 GIT binary patch literal 305 zcmV-10nYx3P)PpT>|_c>&L0FLoZl(#Csu14IsDVd()pglEvT zwz4x=FeF6QWtCs!zGTDXW0?Jz9TLFdXqlcyi<{iDU-M>#3=H>l-6?~%vz_ih-Ln96 zyaWF+13zQH10vuGC?FK=l@m#;CuK~<EY8 Date: Fri, 27 Mar 2020 12:54:03 +0100 Subject: [PATCH 006/104] Delete app.js.png --- apps/cliock/app.js.png | Bin 305 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/cliock/app.js.png diff --git a/apps/cliock/app.js.png b/apps/cliock/app.js.png deleted file mode 100644 index 4ad2d056daeb21b44ea8e6de6a57e7995bdf0b33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 305 zcmV-10nYx3P)PpT>|_c>&L0FLoZl(#Csu14IsDVd()pglEvT zwz4x=FeF6QWtCs!zGTDXW0?Jz9TLFdXqlcyi<{iDU-M>#3=H>l-6?~%vz_ih-Ln96 zyaWF+13zQH10vuGC?FK=l@m#;CuK~<EY8 Date: Fri, 27 Mar 2020 12:56:44 +0100 Subject: [PATCH 007/104] Create app-icon.js --- apps/cliock/app-icon.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/cliock/app-icon.js diff --git a/apps/cliock/app-icon.js b/apps/cliock/app-icon.js new file mode 100644 index 000000000..3ce4e4559 --- /dev/null +++ b/apps/cliock/app-icon.js @@ -0,0 +1 @@ +E.toArrayBuffer((atob("kEgwkBiIA/ACBhLB6gqKB6g//B6I4DiDqCB40QB4MBAoIXDB40BAIIPNG44PLAoQvMB5RPEB5JvEBAav1f7wA/ABoA==")) From 57be790c8191c6c5492d381f0a0593ef68cc0ec4 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 13:00:29 +0100 Subject: [PATCH 008/104] Update apps.json --- apps.json | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 15acb3b20..bf4f6d060 100644 --- a/apps.json +++ b/apps.json @@ -836,5 +836,19 @@ {"name":"marioclock.app.js","url":"marioclock-app.js"}, {"name":"marioclock.img","url":"marioclock-icon.js","evaluate":true} ] - } + }, + { "id": "cliock", + "name": "Commandline-Clock", + "shortName":"CLI-Clock", + "icon": "app.png", + "version":"0.01", + "description": "Simple CLI-Styled Clock", + "tags": "cli,command,bash,shell", + "type": "clock", + "allow_emulator":true, + "storage": [ + {"name":"cliock.app.js","url":"app.js"}, + {"name":"cliock.img","url":"app-icon.js","evaluate":true} + ] +} ] From 28cbad640a7e48b9dd19ef3c65290cd90a09a8de Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 13:01:21 +0100 Subject: [PATCH 009/104] Add files via upload --- apps/cliock/app.png | Bin 0 -> 305 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/cliock/app.png diff --git a/apps/cliock/app.png b/apps/cliock/app.png new file mode 100644 index 0000000000000000000000000000000000000000..4ad2d056daeb21b44ea8e6de6a57e7995bdf0b33 GIT binary patch literal 305 zcmV-10nYx3P)PpT>|_c>&L0FLoZl(#Csu14IsDVd()pglEvT zwz4x=FeF6QWtCs!zGTDXW0?Jz9TLFdXqlcyi<{iDU-M>#3=H>l-6?~%vz_ih-Ln96 zyaWF+13zQH10vuGC?FK=l@m#;CuK~<EY8 Date: Fri, 27 Mar 2020 13:04:56 +0100 Subject: [PATCH 010/104] Update app-icon.js --- apps/cliock/app-icon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cliock/app-icon.js b/apps/cliock/app-icon.js index 3ce4e4559..fab023339 100644 --- a/apps/cliock/app-icon.js +++ b/apps/cliock/app-icon.js @@ -1 +1 @@ -E.toArrayBuffer((atob("kEgwkBiIA/ACBhLB6gqKB6g//B6I4DiDqCB40QB4MBAoIXDB40BAIIPNG44PLAoQvMB5RPEB5JvEBAav1f7wA/ABoA==")) +require("heatshrink").decompress(atob("kEgwkBiIA/ACBhLB6gqKB6g//B6I4DiDqCB40QB4MBAoIXDB40BAIIPNG44PLAoQvMB5RPEB5JvEBAav1f7wA/ABoA==")) From 09b25f0ab8f62f557eae6b1e846924ba384198fe Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 13:06:02 +0100 Subject: [PATCH 011/104] Update app.js --- apps/cliock/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index a51f98c6b..47dbb7ec4 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -4,7 +4,7 @@ var locale = require("locale"); var marginTop = 40; var flag = false; -var WeekDays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; +var WeekDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; function updateTime(){ if (!Bangle.isLCDOn()) return; From a8d04e35527c5b6ebd0825591109b53ee8a711bd Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 13:06:33 +0100 Subject: [PATCH 012/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index bf4f6d060..70c76b41a 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.01", + "version":"0.02", "description": "Simple CLI-Styled Clock", "tags": "cli,command,bash,shell", "type": "clock", From c6d4de79feb14a361fec65da88a947f0e47b4352 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 16:31:18 +0100 Subject: [PATCH 013/104] Update app.js --- apps/cliock/app.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 47dbb7ec4..b4fd7d7e2 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -3,9 +3,16 @@ var fontsize = 2; var locale = require("locale"); var marginTop = 40; var flag = false; +var WeekDays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; -var WeekDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; - +function drawAll(){ + g.clear(); + Bangle.loadWidgets(); + Bangle.drawWidgets(); + g.setFont("6x8",fontsize); + g.setColor("#00ff00"); + updateTime(); +} function updateTime(){ if (!Bangle.isLCDOn()) return; line = 0; @@ -15,11 +22,6 @@ function updateTime(){ var m = now.getMinutes(); h = h>10?h:"0"+h; m = m>10?m:"0"+m; - g.clear(); - Bangle.loadWidgets(); - Bangle.drawWidgets(); - g.setFont("6x8",fontsize); - g.setColor("#00ff00"); writeLine(h+":"+m); writeLine(WeekDays[now.getDay()]); writeLine(date); @@ -36,17 +38,15 @@ function writeLineStart(){ g.drawString(">",4,marginTop+line*20); } function writeLine(str){ + g.clearRect(0,marginTop+line*20,(str.length*15+15),marginTop+20+line*20); writeLineStart(); g.drawString(str,17,marginTop+line*20); line++; } +drawAll(); Bangle.on('lcdPower',function(on) { if (on) - updateTime(); + drawAll(); }); -setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); var click = setInterval(updateTime, 1000); - - - From 3894a12033ff827cf48eca11d3c7e8d8fb334a74 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 16:31:42 +0100 Subject: [PATCH 014/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 70c76b41a..9b984376a 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.02", + "version":"0.03", "description": "Simple CLI-Styled Clock", "tags": "cli,command,bash,shell", "type": "clock", From b0f5c94789aa545bb3fd91b864f47a37f9561148 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 17:01:58 +0100 Subject: [PATCH 015/104] Update app.js --- apps/cliock/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index b4fd7d7e2..9ea1f011a 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -22,6 +22,8 @@ function updateTime(){ var m = now.getMinutes(); h = h>10?h:"0"+h; m = m>10?m:"0"+m; + g.setFont("6x8",fontsize); + g.setColor("#00ff00"); writeLine(h+":"+m); writeLine(WeekDays[now.getDay()]); writeLine(date); @@ -40,7 +42,7 @@ function writeLineStart(){ function writeLine(str){ g.clearRect(0,marginTop+line*20,(str.length*15+15),marginTop+20+line*20); writeLineStart(); - g.drawString(str,17,marginTop+line*20); + g.drawString(str,20,marginTop+line*20); line++; } From b45c89ee0d87b88e26163f49a978a77ea933e819 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 17:02:22 +0100 Subject: [PATCH 016/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 9b984376a..692979fdd 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.03", + "version":"0.04", "description": "Simple CLI-Styled Clock", "tags": "cli,command,bash,shell", "type": "clock", From 563c445cabf530c4347170a2afa3db4b64a4d13c Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 18:04:46 +0100 Subject: [PATCH 017/104] Update app.js --- apps/cliock/app.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 9ea1f011a..48b225b07 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -3,14 +3,12 @@ var fontsize = 2; var locale = require("locale"); var marginTop = 40; var flag = false; -var WeekDays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; +var WeekDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; function drawAll(){ g.clear(); Bangle.loadWidgets(); Bangle.drawWidgets(); - g.setFont("6x8",fontsize); - g.setColor("#00ff00"); updateTime(); } function updateTime(){ @@ -23,7 +21,8 @@ function updateTime(){ h = h>10?h:"0"+h; m = m>10?m:"0"+m; g.setFont("6x8",fontsize); - g.setColor("#00ff00"); + g.setColor(0,1,0); + g.setFontAlign(-1,0); writeLine(h+":"+m); writeLine(WeekDays[now.getDay()]); writeLine(date); From b40f873108421a0f6db0e8e77098de4abe539760 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 18:05:12 +0100 Subject: [PATCH 018/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 692979fdd..70c76b41a 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.04", + "version":"0.02", "description": "Simple CLI-Styled Clock", "tags": "cli,command,bash,shell", "type": "clock", From bcdd8c7be1f29493a34e79ee0d38c7da0c8aaaa7 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 19:00:12 +0100 Subject: [PATCH 019/104] Update app.js --- apps/cliock/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 48b225b07..e17df9788 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -39,7 +39,7 @@ function writeLineStart(){ g.drawString(">",4,marginTop+line*20); } function writeLine(str){ - g.clearRect(0,marginTop+line*20,(str.length*15+15),marginTop+20+line*20); + g.clearRect(0,marginTop+line*20,((str.length+1)*15+15),marginTop+20+line*20); writeLineStart(); g.drawString(str,20,marginTop+line*20); line++; @@ -51,3 +51,4 @@ Bangle.on('lcdPower',function(on) { drawAll(); }); var click = setInterval(updateTime, 1000); +setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); From d21bb41c093ff31441328ffc669a6252b721e590 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 19:00:31 +0100 Subject: [PATCH 020/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 70c76b41a..9b984376a 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.02", + "version":"0.03", "description": "Simple CLI-Styled Clock", "tags": "cli,command,bash,shell", "type": "clock", From c07a7baeb96155eadf968528215a5f6f49bd32a9 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 19:34:15 +0100 Subject: [PATCH 021/104] Update app.js --- apps/cliock/app.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index e17df9788..056a7a949 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -1,5 +1,5 @@ var line; -var fontsize = 2; +var fontsize = 3; var locale = require("locale"); var marginTop = 40; var flag = false; @@ -18,8 +18,8 @@ function updateTime(){ var date = locale.date(now,false); var h = now.getHours(); var m = now.getMinutes(); - h = h>10?h:"0"+h; - m = m>10?m:"0"+m; + h = h>=10?h:"0"+h; + m = m>=10?m:"0"+m; g.setFont("6x8",fontsize); g.setColor(0,1,0); g.setFontAlign(-1,0); @@ -36,12 +36,12 @@ function updateTime(){ } } function writeLineStart(){ - g.drawString(">",4,marginTop+line*20); + g.drawString(">",4,marginTop+line*25); } function writeLine(str){ - g.clearRect(0,marginTop+line*20,((str.length+1)*15+15),marginTop+20+line*20); + g.clearRect(0,marginTop+line*25,((str.length+1)*15+15),marginTop+20+line*25); writeLineStart(); - g.drawString(str,20,marginTop+line*20); + g.drawString(str,25,marginTop+line*25); line++; } From e6274f267dcfa4da564eac2a164c26ecd1a45b63 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 19:34:36 +0100 Subject: [PATCH 022/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 9b984376a..692979fdd 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.03", + "version":"0.04", "description": "Simple CLI-Styled Clock", "tags": "cli,command,bash,shell", "type": "clock", From be1d8e76ce3213233b5b92e4de7ceae95e8aa49a Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Fri, 27 Mar 2020 19:42:23 +0100 Subject: [PATCH 023/104] Update app.js --- apps/cliock/app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 056a7a949..607993f63 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -22,12 +22,12 @@ function updateTime(){ m = m>=10?m:"0"+m; g.setFont("6x8",fontsize); g.setColor(0,1,0); - g.setFontAlign(-1,0); + g.setFontAlign(-1,-1); writeLine(h+":"+m); writeLine(WeekDays[now.getDay()]); writeLine(date); if(flag){ - writeLine(""); + writeLine(" "); flag = false; } else{ @@ -36,12 +36,12 @@ function updateTime(){ } } function writeLineStart(){ - g.drawString(">",4,marginTop+line*25); + g.drawString(">",4,marginTop+line*30); } function writeLine(str){ - g.clearRect(0,marginTop+line*25,((str.length+1)*15+15),marginTop+20+line*25); + g.clearRect(0,marginTop+line*30,((str.length+1)*20),marginTop+25+line*30); writeLineStart(); - g.drawString(str,25,marginTop+line*25); + g.drawString(str,25,marginTop+line*30); line++; } From b7b5d6764b357649fc258c3530c88dec25c168e6 Mon Sep 17 00:00:00 2001 From: Simon Weis Date: Thu, 26 Mar 2020 22:30:34 +0100 Subject: [PATCH 024/104] Adds gbridge call notification and refactor widget --- apps.json | 8 +- apps/gbridge/ChangeLog | 1 + apps/gbridge/gbridge-call-ico.js | 1 + apps/gbridge/gbridge-music-ico.js | 1 + apps/gbridge/gbridge-off-ico.js | 1 + apps/gbridge/gbridge-on-ico.js | 1 + apps/gbridge/widget.js | 356 ++++++++++++++++++++---------- 7 files changed, 250 insertions(+), 119 deletions(-) create mode 100644 apps/gbridge/gbridge-call-ico.js create mode 100644 apps/gbridge/gbridge-music-ico.js create mode 100644 apps/gbridge/gbridge-off-ico.js create mode 100644 apps/gbridge/gbridge-on-ico.js diff --git a/apps.json b/apps.json index d5b079f7a..b5350d349 100644 --- a/apps.json +++ b/apps.json @@ -66,13 +66,17 @@ { "id": "gbridge", "name": "Gadgetbridge", "icon": "app.png", - "version":"0.04", + "version":"0.05", "description": "The default notification handler for Gadgetbridge notifications from Android", "tags": "tool,system,android,widget", "storage": [ {"name":"gbridge.app.js","url":"app.js"}, {"name":"gbridge.img","url":"app-icon.js","evaluate":true}, - {"name":"gbridge.wid.js","url":"widget.js"} + {"name":"gbridge.wid.js","url":"widget.js"}, + {"name":"gbridge-music-ico.img","url":"gbridge-music-ico.js","evaluate":true}, + {"name":"gbridge-off-ico.img","url":"gbridge-off-ico.js","evaluate":true}, + {"name":"gbridge-on-ico.img","url":"gbridge-on-ico.js","evaluate":true}, + {"name":"gbridge-call-ico.img","url":"gbridge-call-ico.js","evaluate":true} ] }, { "id": "mclock", diff --git a/apps/gbridge/ChangeLog b/apps/gbridge/ChangeLog index 28789ec04..3a6dd3bfd 100644 --- a/apps/gbridge/ChangeLog +++ b/apps/gbridge/ChangeLog @@ -2,3 +2,4 @@ 0.02: Increase contrast (darker notification background, white text) 0.03: Gadgetbridge widget now shows connection state 0.04: Tweaks for variable size widget system +0.05: Show incoming call notification \ No newline at end of file diff --git a/apps/gbridge/gbridge-call-ico.js b/apps/gbridge/gbridge-call-ico.js new file mode 100644 index 000000000..ce722a9a8 --- /dev/null +++ b/apps/gbridge/gbridge-call-ico.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw=")) \ No newline at end of file diff --git a/apps/gbridge/gbridge-music-ico.js b/apps/gbridge/gbridge-music-ico.js new file mode 100644 index 000000000..ff8f80883 --- /dev/null +++ b/apps/gbridge/gbridge-music-ico.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")) \ No newline at end of file diff --git a/apps/gbridge/gbridge-off-ico.js b/apps/gbridge/gbridge-off-ico.js new file mode 100644 index 000000000..1a722f372 --- /dev/null +++ b/apps/gbridge/gbridge-off-ico.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("i0WwQFC1WgAgYFDAgIFClQFCwEK1W/AoIPB1f+CAMq1f7/WqwQPB/fq1Gq1/+/4dC/2/CAIaB/YbBAAO///qAoX/B4QbBDQQ7BDQQrBAAWoIIIACIIIVC0ECB4cACAZiBAoRtCAoIDBA")) \ No newline at end of file diff --git a/apps/gbridge/gbridge-on-ico.js b/apps/gbridge/gbridge-on-ico.js new file mode 100644 index 000000000..f40c4149f --- /dev/null +++ b/apps/gbridge/gbridge-on-ico.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("i0WwgHExAABCIwJCBYwJEBYkIBQ2ACgvzCwoECx/z/AKDD4WD+YLBEIYKCx//+cvnAKCBwU/mc4/8/HYv//Ev+Y4EEAePn43DBQkzn4rCEIoABBIwKHO4cjmczK42I6mqlqEEBQeIBQaDED4IgDUhi6KaBbmIA==")) \ No newline at end of file diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index a787d7e0b..151dd3ad3 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -1,125 +1,247 @@ -(function() { - var musicState = "stop"; - var musicInfo = {"artist":"","album":"","track":""}; - var scrollPos = 0; - function gb(j) { - Bluetooth.println(JSON.stringify(j)); - } - function show(size,render) { - var oldMode = Bangle.getLCDMode(); - Bangle.setLCDMode("direct"); - g.setClipRect(0,240,239,319); - g.setColor("#222222"); - g.fillRect(1,241,238,318); - render(320-size); - g.setColor("#ffffff"); - g.fillRect(0,240,1,319); - g.fillRect(238,240,239,319); - g.fillRect(2,318,238,319); - Bangle.setLCDPower(1); // light up - Bangle.setLCDMode(oldMode); // clears cliprect - function anim() { - scrollPos-=2; - if (scrollPos<-size) scrollPos=-size; - Bangle.setLCDOffset(scrollPos); - if (scrollPos>-size) setTimeout(anim,10); - } - anim(); - } - function hide() { - function anim() { - scrollPos+=4; - if (scrollPos>0) scrollPos=0; - Bangle.setLCDOffset(scrollPos); - if (scrollPos<0) setTimeout(anim,10); - } - anim(); - } +(() => { - Bangle.on('touch',function() { - if (scrollPos) hide(); - }); - Bangle.on('swipe',function(dir) { - if (musicState=="play") { - gb({t:"music",n:dir>0?"next":"previous"}); - } - }); - gb({t:"status",bat:E.getBattery()}); + const gb = { + musicState: { + STOP: "stop", + PLAY: "play", + PAUSE: "pause" + }, - global.GB = function(j) { - switch (j.t) { - case "notify": - show(80,function(y) { - // TODO: icon based on src? - var x = 120; - g.setFontAlign(0,0); - g.setFont("6x8",1); - g.setColor("#40d040"); - g.drawString(j.src,x,y+7); - g.setColor("#ffffff"); - g.setFont("6x8",2); - g.drawString(j.title,x,y+25); - g.setFont("6x8",1); - g.setColor("#ffffff"); - // split text up a word boundaries - var txt = j.body.split("\n"); - var MAXCHARS = 38; - for (var i=0;iMAXCHARS) { - var p = MAXCHARS; - while (p>MAXCHARS-8 && !" \t-_".includes(l[p])) - p--; - if (p==MAXCHARS-8) p=MAXCHARS; - txt[i] = l.substr(0,p); - txt.splice(i+1,0,l.substr(p)); - } - } - g.setFontAlign(-1,-1); - g.drawString(txt.join("\n"),10,y+40); - Bangle.buzz(); - }); - break; - case "musicinfo": - musicInfo = j; - break; - case "musicstate": - musicState = j.state; - if (musicState=="play") - show(40,function(y) { - g.setColor("#ffffff"); - g.drawImage( require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")),8,y+8); - g.setFontAlign(-1,-1); - g.setFont("6x8",1); - var x = 40; - g.setFont("4x6",2); - g.setColor("#ffffff"); - g.drawString(musicInfo.artist,x,y+8); - g.setFont("6x8",1); - g.setColor("#ffffff"); - g.drawString(musicInfo.track,x,y+22); - }); - if (musicState=="pause") - hide(); - break; + muiscControl: { + NEXT: "next", + PREV: "previous" + }, + + callCommands: { + UNDEFINED: "undefined", + ACCEPT: "accept", + INCOMING: "incoming", + OUTGOING: "outgoing", + REJECT: "reject", + START: "start", + END: "end" + }, + + send: (message) => { + Bluetooth.println(JSON.stringify(message)); + }, + + controlMusic: (operation) => { + gb.send({ t: "music", n: operation }); + }, + + reportBatteryLevel: () => { + gb.send({ t: "status", bat: E.getBattery() }); + }, + }; + + const state = { + music: gb.musicState.STOP, + + musicInfo: { + artist: "", + album: "", + track: "" + }, + debug: false, + }; + + const notification = { + + backgroundColor: "#222222", + frameColor: "#ffffff", + titleColor: "#40d040", + contentColor: "#ffffff", + scrollPos: 0, + + show: (size, content) => { + var oldMode = Bangle.getLCDMode(); + Bangle.setLCDMode("direct"); + + g.setClipRect(0, 240, 239, 319); + g.setColor(notification.backgroundColor); + g.fillRect(1, 241, 238, 318); + + notification.drawContent(320 - size, content); + + g.setColor(notification.frameColor); + g.fillRect(0, 240, 1, 319); + g.fillRect(238, 240, 239, 319); + g.fillRect(2, 318, 238, 319); + + Bangle.setLCDPower(1); // light up + Bangle.setLCDMode(oldMode); // clears cliprect + + function anim() { + notification.scrollPos -= 2; + if (notification.scrollPos < -size) notification.scrollPos = -size; + Bangle.setLCDOffset(notification.scrollPos); + if (notification.scrollPos > -size) setTimeout(anim, 10); + } + anim(); + }, + + drawContent: (y, content) => { + + if (content.icon !== undefined) { + g.setColor(notification.contentColor); + const icon = require("Storage").read(content.icon); + g.drawImage(icon, 8, y + 8); + } + + var x = 120; + g.setFontAlign(0, 0); + + g.setFont("6x8", 1); + g.setColor(notification.titleColor); + g.drawString(content.title, x, y + 7); + + g.setColor(notification.contentColor); + g.setFont("6x8", 2); + g.drawString(content.header, x, y + 25); + + g.setFont("6x8", 1); + g.setColor(notification.contentColor); + g.setFontAlign(-1, -1); + g.drawString(content.body, 10, y + 40); + }, + + hide: () => { + function anim() { + notification.scrollPos += 4; + if (notification.scrollPos > 0) notification.scrollPos = 0; + Bangle.setLCDOffset(notification.scrollPos); + if (notification.scrollPos < 0) setTimeout(anim, 10); + } + anim(); + }, + + isVisible: () => { + return notification.scrollPos != 0; } }; -function draw() { - g.setColor(-1); - if (NRF.getSecurityStatus().connected) - g.drawImage(require("heatshrink").decompress(atob("i0WwgHExAABCIwJCBYwJEBYkIBQ2ACgvzCwoECx/z/AKDD4WD+YLBEIYKCx//+cvnAKCBwU/mc4/8/HYv//Ev+Y4EEAePn43DBQkzn4rCEIoABBIwKHO4cjmczK42I6mqlqEEBQeIBQaDED4IgDUhi6KaBbmIA==")),this.x+1,this.y+1); - else - g.drawImage(require("heatshrink").decompress(atob("i0WwQFC1WgAgYFDAgIFClQFCwEK1W/AoIPB1f+CAMq1f7/WqwQPB/fq1Gq1/+/4dC/2/CAIaB/YbBAAO///qAoX/B4QbBDQQ7BDQQrBAAWoIIIACIIIVC0ECB4cACAZiBAoRtCAoIDBA")),this.x+1,this.y+1); -} -function changed() { - WIDGETS["gbridgew"].draw(); - g.flip();// turns screen on -} -NRF.on('connected',changed); -NRF.on('disconnected',changed); + function showNotification(src, title, body) { -WIDGETS["gbridgew"]={area:"tl",width:24,draw:draw}; + // split text up at word boundaries + var txt = body.split("\n"); + var MAXCHARS = 38; + for (var i = 0; i < txt.length; i++) { + txt[i] = txt[i].trim(); + var l = txt[i]; + if (l.length > MAXCHARS) { + var p = MAXCHARS; + while (p > MAXCHARS - 8 && !" \t-_".includes(l[p])) + p--; + if (p == MAXCHARS - 8) p = MAXCHARS; + txt[i] = l.substr(0, p); + txt.splice(i + 1, 0, l.substr(p)); + } + } + var content = { + title: src, + header: title, + body: txt.join("\n") + }; + + notification.show(80, content); + Bangle.buzz(); + } + + function updateMusicInfo() { + if (state.music == gb.musicState.PLAY) { + + var content = { + title: "Now playing", + icon: "gbridge-music-ico.img", + header: state.musicInfo.artist, + body: state.musicInfo.track + }; + + notification.show(40, content); + } else { + notification.hide(); + } + } + + function handleCall(cmd, name, number) { + switch(cmd) { + + case gb.callCommands.ACCEPT: + notification.show(80, { + title: "Call incoming", + icon: "gbridge-call-ico.img", + header: name, + body: number + }); + Bangle.buzz(); + break; + + default: + if (state.debug) { + showNotification(cmd, name, number); + } + } + } + + global.GB = (event) => { + switch (event.t) { + case "notify": + showNotification(event.src, event.title, event.body); + break; + case "musicinfo": + state.musicInfo = event; + break; + case "musicstate": + state.musicInfo = event.state; + updateMusicInfo(); + break; + case "call": + handleCall(event.cmd, event.name, event.number); + break; + default: + if (state.debug) { + showNotification("Gadgetbridge", event.t, JSON.stringify(event)); + } + } + }; + + // Touch control + Bangle.on("touch", () => { + if (notification.isVisible()) { + notification.hide(); + } + }); + + Bangle.on("swipe", (dir) => { + if (state.music == gb.musicState.PLAY) { + gb.controlMusic(dir > 0 ? gb.muiscControl.NEXT : gb.muiscControl.PREV); + } + }); + + function drawIcon() { + g.setColor(-1); + + let icon; + if (NRF.getSecurityStatus().connected) { + icon = require("Storage").read("gbridge-on-ico.img"); + } else { + icon = require("Storage").read("gbridge-off-ico.img"); + } + + g.drawImage(icon, this.x + 1, this.y + 1); + } + + function changedConnectionState() { + WIDGETS["gbridgew"].draw(); + g.flip(); // turns screen on + } + + NRF.on("connected", changedConnectionState); + NRF.on("disconnected", changedConnectionState); + + WIDGETS["gbridgew"] = { area: "tl", width: 24, draw: drawIcon }; + + gb.reportBatteryLevel(); })(); From 33a88627d9876ce48fe8d26ffa5d973289fe0c1a Mon Sep 17 00:00:00 2001 From: Simon Weis Date: Sat, 28 Mar 2020 13:30:13 +0100 Subject: [PATCH 025/104] Fix music notifications --- apps/gbridge/widget.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index 151dd3ad3..0b68d3e1b 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -153,10 +153,10 @@ if (state.music == gb.musicState.PLAY) { var content = { - title: "Now playing", + title: state.musicInfo.artist, icon: "gbridge-music-ico.img", - header: state.musicInfo.artist, - body: state.musicInfo.track + header: state.musicInfo.track, + body:"" }; notification.show(40, content); @@ -194,7 +194,7 @@ state.musicInfo = event; break; case "musicstate": - state.musicInfo = event.state; + state.music = event.state; updateMusicInfo(); break; case "call": From b1585366c5945ba74912b84da917fac6da43b753 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Tue, 31 Mar 2020 20:13:35 +0200 Subject: [PATCH 026/104] Update app.js --- apps/cliock/app.js | 47 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 607993f63..48cc24f22 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -1,4 +1,3 @@ -var line; var fontsize = 3; var locale = require("locale"); var marginTop = 40; @@ -10,39 +9,39 @@ function drawAll(){ Bangle.loadWidgets(); Bangle.drawWidgets(); updateTime(); + updateRest(new Date(),true); +} + +function updateRest(now,force){ + Bangle.loadWidgets(); + Bangle.drawWidgets(); + if (now.getMinutes() != 0 && force) return; + let date = locale.date(now,false); + writeLine(WeekDays[now.getDay()],1); + writeLine(date,2); } function updateTime(){ if (!Bangle.isLCDOn()) return; - line = 0; - var now = new Date(); - var date = locale.date(now,false); - var h = now.getHours(); - var m = now.getMinutes(); + let now = new Date(); + let h = now.getHours(); + let m = now.getMinutes(); h = h>=10?h:"0"+h; m = m>=10?m:"0"+m; + writeLine(h+":"+m,0); + writeLine(flag?" ":"_",3); + flag = !flag; + updateRest(now,false); +} +function writeLineStart(line){ + g.drawString(">",4,marginTop+line*30); +} +function writeLine(str,line){ g.setFont("6x8",fontsize); g.setColor(0,1,0); g.setFontAlign(-1,-1); - writeLine(h+":"+m); - writeLine(WeekDays[now.getDay()]); - writeLine(date); - if(flag){ - writeLine(" "); - flag = false; - } - else{ - writeLine("_"); - flag = true; - } -} -function writeLineStart(){ - g.drawString(">",4,marginTop+line*30); -} -function writeLine(str){ g.clearRect(0,marginTop+line*30,((str.length+1)*20),marginTop+25+line*30); - writeLineStart(); + writeLineStart(line); g.drawString(str,25,marginTop+line*30); - line++; } drawAll(); From ad33990965e71417626fba5ff4a0bb4125a1cc47 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Tue, 31 Mar 2020 20:15:39 +0200 Subject: [PATCH 027/104] Update apps.json --- apps.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps.json b/apps.json index 692979fdd..c8c9aaad2 100644 --- a/apps.json +++ b/apps.json @@ -841,10 +841,10 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.04", + "version":"0.05", "description": "Simple CLI-Styled Clock", - "tags": "cli,command,bash,shell", - "type": "clock", + "tags": "clock,cli,command,bash,shell", + "type":"clock" "allow_emulator":true, "storage": [ {"name":"cliock.app.js","url":"app.js"}, From 61c8d255e71003502539a7e4d2cddcf75852e2d0 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Tue, 31 Mar 2020 20:17:26 +0200 Subject: [PATCH 028/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index c8c9aaad2..8e3f7ec15 100644 --- a/apps.json +++ b/apps.json @@ -844,7 +844,7 @@ "version":"0.05", "description": "Simple CLI-Styled Clock", "tags": "clock,cli,command,bash,shell", - "type":"clock" + "type":"clock", "allow_emulator":true, "storage": [ {"name":"cliock.app.js","url":"app.js"}, From 7d78869647f1e0ba6893e68c60d73d5dc076f53a Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Tue, 31 Mar 2020 20:21:09 +0200 Subject: [PATCH 029/104] Update app.js --- apps/cliock/app.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 48cc24f22..f73815a69 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -13,8 +13,6 @@ function drawAll(){ } function updateRest(now,force){ - Bangle.loadWidgets(); - Bangle.drawWidgets(); if (now.getMinutes() != 0 && force) return; let date = locale.date(now,false); writeLine(WeekDays[now.getDay()],1); From 706a97a7b62bbe79560a3b9cf1d94dd407406cba Mon Sep 17 00:00:00 2001 From: MaBecker Date: Tue, 31 Mar 2020 20:22:56 +0200 Subject: [PATCH 030/104] app widget tiniy battery --- apps.json | 11 +++++++++++ apps/widtbat/ChangeLog | 1 + apps/widtbat/widget.js | 18 ++++++++++++++++++ apps/widtbat/widget.png | Bin 0 -> 911 bytes 4 files changed, 30 insertions(+) create mode 100644 apps/widtbat/ChangeLog create mode 100644 apps/widtbat/widget.js create mode 100644 apps/widtbat/widget.png diff --git a/apps.json b/apps.json index 9bef19fef..7fc272235 100644 --- a/apps.json +++ b/apps.json @@ -888,5 +888,16 @@ {"name":"barclock.app.js","url":"clock-bar.js"}, {"name":"barclock.img","url":"clock-bar-icon.js","evaluate":true} ] + }, + { "id": "widtbat", + "name": "Tiny Battery Widget", + "icon": "widget.png", + "version":"0.01", + "description": "Tiny blueish battery widget, vibs and changes level coler when charging", + "tags": "widget,tool,system", + "type":"widget", + "storage": [ + {"name":"widtbat.wid.js","url":"widget.js"} + ] } ] diff --git a/apps/widtbat/ChangeLog b/apps/widtbat/ChangeLog new file mode 100644 index 000000000..79c4b410d --- /dev/null +++ b/apps/widtbat/ChangeLog @@ -0,0 +1 @@ +001 New widget diff --git a/apps/widtbat/widget.js b/apps/widtbat/widget.js new file mode 100644 index 000000000..f60034300 --- /dev/null +++ b/apps/widtbat/widget.js @@ -0,0 +1,18 @@ +/* jshint esversion: 6 */ +(() => { + const CBS = 0x41f, CBC = 0x07E0; + var batS = require("heatshrink").decompress(atob("j0TwIHEv///kD////EfAYPwuEAgPB4EAg/HCgMfzgDBvwOC/IOC84ONDoUcFgc/AYOAHYRDE")); + var xo = 6, xl = 22, yo = 9, h = 17; + + function draw() { + g.reset().setColor(CBS).drawImage(batS, this.x + 1, this.y + 4); + g.setColor(0).fillRect(this.x + xo, this.y + yo, this.x + xl, this.y + h); + var cbc = (Bangle.isCharging()) ? CBC : CBS; + g.setColor(cbc).fillRect(this.x + xo, this.y + yo, this.x + (xl - xo) / 100 * E.getBattery() + xo, this.y + h); + } + Bangle.on('charging', function(charging) { + if (charging) Bangle.buzz(); + Bangle.drawWidgets(); + }); + WIDGETS["widtbat"] = { area:"tr", width:32, draw: draw }; +})(); diff --git a/apps/widtbat/widget.png b/apps/widtbat/widget.png new file mode 100644 index 0000000000000000000000000000000000000000..4294f0ca32299687f44c631a14109629f857f4a1 GIT binary patch literal 911 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC#^NA%Cx&(BWL^R}0jUw5X}-P; zT0k}j0~4bV12aeo5Hhr9GO&Qz3=C>Ont_3N0V6_o0TW!-U;#6N4N`dWm6H(AkjTuC zh>{3jAFJg2T)o7U{G?R9irfN_0tTB3D*7iAWdWaj57fXq!y$}cUk zRZ;?31P2gzmSmu1yMhW`HkzTTSoaJ~2f8+kKR6OrFMCe`Z3#?B8 zC49*z`DeL<{|n(yEW*2#>kN&)@-iK7o}>EZyS}siuHP4aO2{#|b+YeT#Q0>l@TS?U z-Aq$V>eZY@m1ibibT(C-EV=!^vgEPuBgal1dB(`on$ebYVzQRQSqH^a%uB2$%z8DE z>HW$2WB(=7FJIlJG`oKy`vg^X$>_F+_K$r^%z0J$4H%3Uf0^)&Vb^2FKZ>Hvi{%c8 zF){0!&1!K=Za5?$k>$y;xZYrj&4(F{orb)&huCVPI|2^(Yw!ygvDk*ZIC=b8qrU_D zf!{11YaOe0ai@u|sP7R^IL*BK!>a|WRUYR#T}!NZa6kT-*Meo`Ehd*7|H&FNC$lP6 z8`u=+ML*@cApFdsH@o47vLbVa!hgXV%VUoI`al2PNuH;-O$_R Date: Tue, 31 Mar 2020 20:29:51 +0200 Subject: [PATCH 031/104] Update app.js --- apps/cliock/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index f73815a69..5362f52ce 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -13,7 +13,7 @@ function drawAll(){ } function updateRest(now,force){ - if (now.getMinutes() != 0 && force) return; + if (now.getMinutes() != 0 && !force) return; let date = locale.date(now,false); writeLine(WeekDays[now.getDay()],1); writeLine(date,2); From e79aef56c95858c51640d50541be0cd4ef77ebbd Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Tue, 31 Mar 2020 20:31:13 +0200 Subject: [PATCH 032/104] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 8e3f7ec15..268a81a68 100644 --- a/apps.json +++ b/apps.json @@ -841,7 +841,7 @@ "name": "Commandline-Clock", "shortName":"CLI-Clock", "icon": "app.png", - "version":"0.05", + "version":"0.07", "description": "Simple CLI-Styled Clock", "tags": "clock,cli,command,bash,shell", "type":"clock", From bef9da2ff6ce375e7eba94fc789d8015da95a965 Mon Sep 17 00:00:00 2001 From: MaBecker Date: Tue, 31 Mar 2020 20:37:10 +0200 Subject: [PATCH 033/104] app widget tiniy battery --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 7fc272235..be3ac925e 100644 --- a/apps.json +++ b/apps.json @@ -893,7 +893,7 @@ "name": "Tiny Battery Widget", "icon": "widget.png", "version":"0.01", - "description": "Tiny blueish battery widget, vibs and changes level coler when charging", + "description": "Tiny blueish battery widget, vibs and changes level color when charging", "tags": "widget,tool,system", "type":"widget", "storage": [ From b5bc339b168391784b456b8da8b06416c4f4e491 Mon Sep 17 00:00:00 2001 From: Pascal Gollnick <33615872+unnamed1337@users.noreply.github.com> Date: Tue, 31 Mar 2020 21:13:52 +0200 Subject: [PATCH 034/104] Bugfix --- apps/cliock/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/cliock/app.js b/apps/cliock/app.js index 5362f52ce..20086464e 100644 --- a/apps/cliock/app.js +++ b/apps/cliock/app.js @@ -9,11 +9,10 @@ function drawAll(){ Bangle.loadWidgets(); Bangle.drawWidgets(); updateTime(); - updateRest(new Date(),true); + updateRest(new Date()); } -function updateRest(now,force){ - if (now.getMinutes() != 0 && !force) return; +function updateRest(now){ let date = locale.date(now,false); writeLine(WeekDays[now.getDay()],1); writeLine(date,2); @@ -28,7 +27,8 @@ function updateTime(){ writeLine(h+":"+m,0); writeLine(flag?" ":"_",3); flag = !flag; - updateRest(now,false); + if(now.getMinutes() == 0) + updateRest(now); } function writeLineStart(line){ g.drawString(">",4,marginTop+line*30); From e8138d1665a8ab79e90f61960edd56262b5e4171 Mon Sep 17 00:00:00 2001 From: Simon Weis Date: Tue, 31 Mar 2020 22:05:39 +0200 Subject: [PATCH 035/104] Documents gadgetbrigde protocol --- apps/gbridge/PROTOCOL.md | 178 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 apps/gbridge/PROTOCOL.md diff --git a/apps/gbridge/PROTOCOL.md b/apps/gbridge/PROTOCOL.md new file mode 100644 index 000000000..1fd0ddb4a --- /dev/null +++ b/apps/gbridge/PROTOCOL.md @@ -0,0 +1,178 @@ +# Watch -> Phone + +## show toast + +``` +{ "t": "info", "msg": "message" } +``` + +t can be one of "info", "warn", "error" + +## report battery level + +``` +{ "t": "status", "bat": 30, "volt": 30 } +``` + +* bat is in range 0 to 100 +* volt is optional and should be greater than 0 + +## find phone + +``` +{ "t": "findPhone", "n": true } +``` + +n is an boolean and toggles the find phone function + +## control music player + +``` +{ "t": "music", "n": "play" } +``` + +n can be one of "play", "pause", "playpause", "next", "previous", "volumeup", "volumedown", "forward", "rewind" + +## control phone call + +``` +{ "t": "call", "n": "accept"} +``` + +n can be one of "accept", "end", "incoming", "outcoming", "reject", "start", "ignore" + +## react to notifications + +Send a response to a notification from phone + +``` +{ + "t": "notify", + "n": "dismiss", + "id": 2, + "tel": "+491234", + "msg": "message", +} +``` + +* n can be one of "dismiss", "dismiss all", "open", "mute", "reply" +* id, tel and message are optional + +# Phone -> Watch + +## show notification + +``` +{ + "t": "notify", + "id": 2, + "src": "app", + "title": "titel", + "subject": "subject", + "body": "message body", + "sender": "sender", + "tel": "+491234" + } +``` + +## notification deleted + +This event is send when the user skipped a notification + +``` +{ "t": "notify-", "id": 2 } +``` + +## set alarm + +``` +{ + "t": "alarm", + "d": [ + { "h": 13, "m": 37 }, + { "h": 8, "m": 0 } + ] +} +``` + +## call state changed + +``` +{ + "t": "call", + "cmd": "accept", + "name": "name", + "number": "+491234" +} +``` + +cmd can be one of "", "undefined", "accept", "incoming", "outgoing", "reject", "start", "end" + +## music state changed + +``` +{ + "t": "musicstate", + "state": "play", + "position": 40, + "shuffle": 0, + "repeat": 1 +} +``` + +## set music info + +``` +{ + "t": "musicinfo", + "artist": "artist", + "album": "album", + "track": "track", + "dur": 1, + "c": 2, + "n" 3 +} +``` + +* dur is the duration of the track +* c is the track count +* n is the track number + +## find device + +``` +{ + "t": "find", + "n": true +} +``` + +n toggles find device functionality + +## set constant vibration + +``` +{ + "t": "vibrate", + "n": 2 +} +``` + +n is the intensity + +## send weather + +``` +{ + "t": "weather", + "temp": 10, + "hum": 71, + "txt": "condition", + "wind": 13, + "loc": "location" +} +``` + +* hum is the humidity +* txt is the weather condition +* loc is the location From 175c46fa2867284e2b18ef64cd744961cb02cabf Mon Sep 17 00:00:00 2001 From: Purple-Tentacle <59914607+Purple-Tentacle@users.noreply.github.com> Date: Tue, 31 Mar 2020 23:16:36 +0200 Subject: [PATCH 036/104] Create ChangeLog --- apps/daysl/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/daysl/ChangeLog diff --git a/apps/daysl/ChangeLog b/apps/daysl/ChangeLog new file mode 100644 index 000000000..4c21f3ace --- /dev/null +++ b/apps/daysl/ChangeLog @@ -0,0 +1 @@ +0.01: New Widget! From b3da3806b26dd31030f27242e03b37a2cae6b0e1 Mon Sep 17 00:00:00 2001 From: Purple-Tentacle <59914607+Purple-Tentacle@users.noreply.github.com> Date: Tue, 31 Mar 2020 23:17:46 +0200 Subject: [PATCH 037/104] Add files via upload --- apps/daysl/app-icon.js | 1 + apps/daysl/app.js | 67 +++++++++++++++++++++++++++++++++++++++++ apps/daysl/app.png | Bin 0 -> 287 bytes apps/daysl/widget.js | 33 ++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 apps/daysl/app-icon.js create mode 100644 apps/daysl/app.js create mode 100644 apps/daysl/app.png create mode 100644 apps/daysl/widget.js diff --git a/apps/daysl/app-icon.js b/apps/daysl/app-icon.js new file mode 100644 index 000000000..485478c58 --- /dev/null +++ b/apps/daysl/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwMB//D/4CgwHDFYPDgICBAoQCB/4CKADmAAgcBIARCCAqQAXF/4v24CtDgYFR")) \ No newline at end of file diff --git a/apps/daysl/app.js b/apps/daysl/app.js new file mode 100644 index 000000000..56f85e615 --- /dev/null +++ b/apps/daysl/app.js @@ -0,0 +1,67 @@ +g.clear(); +Bangle.loadWidgets(); +Bangle.drawWidgets(); + +const storage = require('Storage'); +let settings; + +function updateSettings() { + storage.write('daysleft.json', settings); +} + +function resetSettings() { + settings = { + day : 17, + month : 6, + year: 1981 + }; + updateSettings(); +} + +settings = storage.readJSON('daysleft.json',1); +if (!settings) resetSettings(); + +function showMenu() { + const datemenu = { + '': { + 'title': 'Set Date', + 'predraw': function() { + datemenu.Date.value = settings.day; + datemenu.Month.value = settings.month; + datemenu.Year.value = settings.year; + } + }, + 'Day': { + value: settings.day, + min: 1, + max: 31, + step: 1, + onchange: v => { + settings.day = v; + updateSettings(); + } + }, + 'Month': { + value: settings.month, + min: 1, + max: 12, + step: 1, + onchange: v => { + settings.month = v; + updateSettings(); + } + }, + 'Year': { + value: settings.year, + step: 1, + onchange: v => { + settings.year = v; + updateSettings(); + } + } + }; + datemenu['-Exit-'] = ()=>{load();}; + return E.showMenu(datemenu); +} + +showMenu(); \ No newline at end of file diff --git a/apps/daysl/app.png b/apps/daysl/app.png new file mode 100644 index 0000000000000000000000000000000000000000..703e5c366c7bf7ad21000427fcda514c599770e9 GIT binary patch literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCwj^(N7l!{JxM1({$v}}So-U3d z8I5me#&R7p5NO#Sa({0_`o~!QM>A{tzh7V%b-AVTw>V}dKa+0mG|6diL}q0?|5iBP z?M>|3y6qb})+aM(sNkBS}c2hbYH*&({pXdV!AtoieEjy zqOicMf4Y&u%DNxM7cMo5I9lls3Wq0ILOq^~M<+Qy%=WYrg*P-hA)%`}SKf zFXYTmuzqy+mSp7bO8tk{3Cvk@K(_T3JM{9dDCAqQkZ f><_XV7){G>e{|lg^4F>a=syNeS3j3^P6<)Rx literal 0 HcmV?d00001 diff --git a/apps/daysl/widget.js b/apps/daysl/widget.js new file mode 100644 index 000000000..5a3c170c2 --- /dev/null +++ b/apps/daysl/widget.js @@ -0,0 +1,33 @@ +const storage = require('Storage'); +let settings; + +function updateSettings() { + storage.write('daysleft.json', settings); + } + + function resetSettings() { + settings = { + day : 17, + month : 6, + year: 1981 + }; + updateSettings(); + } + + settings = storage.readJSON('daysleft.json',1); + if (!settings) resetSettings(); + + var dd = settings.day+1, + mm = settings.month-1, + yy = settings.year; + + const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds + const targetDate = new Date(yy, mm, dd); + const today = new Date(); + const diffDays = Math.round(Math.abs((targetDate - today) / oneDay)); + +WIDGETS["daysl"]={area:"tl",width:40,draw:function(){ + + g.setFont("6x8", 1); + g.drawString(diffDays,this.x+12,this.y+12); +}}; \ No newline at end of file From 87d5bfa915e7a6942c41507e86375236bd4e09c0 Mon Sep 17 00:00:00 2001 From: Purple-Tentacle <59914607+Purple-Tentacle@users.noreply.github.com> Date: Tue, 31 Mar 2020 23:19:44 +0200 Subject: [PATCH 038/104] Update apps.json --- apps.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps.json b/apps.json index 90194b1c3..31921d745 100644 --- a/apps.json +++ b/apps.json @@ -12,6 +12,19 @@ ], "sortorder" : -10 }, + { "id": "daysl", + "name": "Days left", + "icon": "app.png", + "version":"0.01", + "description": "Shows you the days left until a certain date. Date can be set with a settings app and is written to a file.", + "tags": "", + "allow_emulator":false, + "storage": [ + {"name":"daysl.app.js","url":"app.js"}, + {"name":"daysl.img","url":"app-icon.js","evaluate":true}, + {"name":"daysl.wid.js","url":"widget.js"} + ] + }, { "id": "launch", "name": "Default Launcher", "shortName":"Launcher", From 140b1458d82bc6d954c9954be05cb798bddd8d53 Mon Sep 17 00:00:00 2001 From: Purple-Tentacle <59914607+Purple-Tentacle@users.noreply.github.com> Date: Tue, 31 Mar 2020 23:30:42 +0200 Subject: [PATCH 039/104] Create ChangeLog --- apps/moonphase/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/moonphase/ChangeLog diff --git a/apps/moonphase/ChangeLog b/apps/moonphase/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/moonphase/ChangeLog @@ -0,0 +1 @@ +0.01: New App! From 389f566dde601f8912c5aaf6774eb20edb967351 Mon Sep 17 00:00:00 2001 From: Purple-Tentacle <59914607+Purple-Tentacle@users.noreply.github.com> Date: Tue, 31 Mar 2020 23:31:24 +0200 Subject: [PATCH 040/104] Add files via upload --- apps/moonphase/app-icon.js | 1 + apps/moonphase/app.js | 296 +++++++++++++++++++++++++++++++++++++ apps/moonphase/app.png | Bin 0 -> 1722 bytes 3 files changed, 297 insertions(+) create mode 100644 apps/moonphase/app-icon.js create mode 100644 apps/moonphase/app.js create mode 100644 apps/moonphase/app.png diff --git a/apps/moonphase/app-icon.js b/apps/moonphase/app-icon.js new file mode 100644 index 000000000..b083b07e5 --- /dev/null +++ b/apps/moonphase/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwgIifh/wAod//wECgP//+AAoMHAoPgCwQFBDAUfw///AFBjkD//8AoMYgPnEgUQgPB/4qCgeB/YFDwHxGAeA+AFEvHAAocdAoQCBh4CBgJFBh4CBAoNwg4FBhHA+AIBgkcgJSBAoMIg5SBAoIpB/E58EGAoP8n4FD/8f8EDAoQvBgfANYOfAYPwAoP/4AtBAoWAgP4SARfBAoZYB/0/Aod/AgKJCBQSVCj4FBUIStFXIrFFaIrdGADYA==")) \ No newline at end of file diff --git a/apps/moonphase/app.js b/apps/moonphase/app.js new file mode 100644 index 000000000..ecd4be05d --- /dev/null +++ b/apps/moonphase/app.js @@ -0,0 +1,296 @@ +//Icons from https://icons8.com +//Sun and Moon calculations from https://github.com/mourner/suncalc and https://gist.github.com/endel/dfe6bb2fbe679781948c + +//pictures +function getImg(i) { + var data = { + "NewMoon": "AD8AAH/4AHwPgDwA8BwADg4AAcMAADHAAA5gAAGYAABsAAAPAAADwAAA8AAAPAAADwAAA2AAAZgAAGcAADjAAAw4AAcHAAOA8APAHwPgAf/gAA/AAA==", + "WaxingCrescentNorth" : "AD8AAH/4AHw/gDwH8BwA/g4AH8MAB/HAAf5gAD+YAA/sAAP/AAD/wAA/8AAP/AAD/wAA/2AAP5gAD+cAB/jAAfw4AH8HAD+A8B/AHw/gAf/gAA/AAA==", + "WaningCrescentSouth" : "AD8AAH/4AHw/gDwH8BwA/g4AH8MAB/HAAf5gAD+YAA/sAAP/AAD/wAA/8AAP/AAD/wAA/2AAP5gAD+cAB/jAAfw4AH8HAD+A8B/AHw/gAf/gAA/AAA==", + "FirstQuarterNorth" : "AD8AAH/4AHx/gDwf8BwH/g4B/8MAf/HAH/5gB/+YAf/sAH//AB//wAf/8AH//AB//wAf/2AH/5gB/+cAf/jAH/w4B/8HAf+A8H/AHx/gAf/gAA/AAA==", + "FirstQuarterSouth" : "AD8AAH/4AH+PgD/g8B/4Dg/+AcP/gDH/4A5/+AGf/gBv/4AP/+AD//gA//4AP/+AD//gA3/4AZ/+AGf/gDj/4Aw/+AcH/gOA/4PAH+PgAf/gAA/AAA==", + "WaxingGibbousNorth" : "AD8AAH/4AH3/gDz/8Bw//g4f/8MH//HB//5g//+YP//sD///A///wP//8D///A///wP//2D//5g//+cH//jB//w4f/8HD/+A8//AH3/gAf/gAA/AAA==", + "WaxingGibbousSouth" : "AD8AAH/4AH/vgD/88B//Dg//4cP/+DH//g5//8Gf//Bv//wP//8D///A///wP//8D///A3//wZ//8Gf/+Dj//gw//4cH/8OA//PAH/vgAf/gAA/AAA==", + "FullMoon" : "AD8AAH/4AH//gD//8B///g///8P///H///5///+f///v/////////////////////////3///5///+f///j///w///8H//+A///AH//gAf/gAA/AAA==", + "WaningGibbousNorth" : "AD8AAH/4AH/vgD/88B//Dg//4cP/+DH//g5//8Gf//Bv//wP//8D///A///wP//8D///A3//wZ//8Gf/+Dj//gw//4cH/8OA//PAH/vgAf/gAA/AAA==", + "WaningGibbousSouth" : "AD8AAH/4AH3/gDz/8Bw//g4f/8MH//HB//5g//+YP//sD///A///wP//8D///A///wP//2D//5g//+cH//jB//w4f/8HD/+A8//AH3/gAf/gAA/AAA==", + "LastQuarterNorth" : "AD8AAH/4AH+PgD/g8B/4Dg/+AcP/gDH/4A5/+AGf/gBv/4AP/+AD//gA//4AP/+AD//gA3/4AZ/+AGf/gDj/4Aw/+AcH/gOA/4PAH+PgAf/gAA/AAA==", + "LastQuarterSouth" : "AD8AAH/4AHx/gDwf8BwH/g4B/8MAf/HAH/5gB/+YAf/sAH//AB//wAf/8AH//AB//wAf/2AH/5gB/+cAf/jAH/w4B/8HAf+A8H/AHx/gAf/gAA/AAA==", + "WaningCrescentNorth" : "AD8AAH/4AH8PgD+A8B/ADg/gAcP4ADH+AA5/AAGfwABv8AAP/AAD/wAA/8AAP/AAD/wAA38AAZ/AAGf4ADj+AAw/gAcH8AOA/gPAH8PgAf/gAA/AAA==", + "WaxingCrescentSouth" : "AD8AAH/4AH8PgD+A8B/ADg/gAcP4ADH+AA5/AAGfwABv8AAP/AAD/wAA/8AAP/AAD/wAA38AAZ/AAGf4ADj+AAw/gAcH8AOA/gPAH8PgAf/gAA/AAA==" +}; + return { + width : 26, height : 26, bpp : 1, + transparent : 0, + buffer : E.toArrayBuffer(atob(data[i])) + }; +} + + //coordinates (will get from GPS later on real device) + var lat = 52.96236, + lon = 7.62571; + + var PI = Math.PI, + sin = Math.sin, + cos = Math.cos, + tan = Math.tan, + asin = Math.asin, + atan = Math.atan2, + acos = Math.acos, + rad = PI / 180; + + // sun calculations are based on http://aa.quae.nl/en/reken/zonpositie.html formulas + // date/time constants and conversions + var dayMs = 1000 * 60 * 60 * 24, + J1970 = 2440588, + J2000 = 2451545; + + function toJulian(date) { return date.valueOf() / dayMs - 0.5 + J1970; } + function fromJulian(j) { return new Date((j + 0.5 - J1970) * dayMs); } + function toDays(date) { return toJulian(date) - J2000; } + + // general calculations for position + var e = rad * 23.4397; // obliquity of the Earth + function rightAscension(l, b) { return atan(sin(l) * cos(e) - tan(b) * sin(e), cos(l)); } + function declination(l, b) { return asin(sin(b) * cos(e) + cos(b) * sin(e) * sin(l)); } + function azimuth(H, phi, dec) { return atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); } + function altitude(H, phi, dec) { return asin(sin(phi) * sin(dec) + cos(phi) * cos(dec) * cos(H)); } + function siderealTime(d, lw) { return rad * (280.16 + 360.9856235 * d) - lw; } + function astroRefraction(h) { + if (h < 0) // the following formula works for positive altitudes only. + h = 0; // if h = -0.08901179 a div/0 would occur. + + // formula 16.4 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + // 1.02 / tan(h + 10.26 / (h + 5.10)) h in degrees, result in arc minutes -> converted to rad: + return 0.0002967 / Math.tan(h + 0.00312536 / (h + 0.08901179)); + } + + // general sun calculations + function solarMeanAnomaly(d) { return rad * (357.5291 + 0.98560028 * d); } + function eclipticLongitude(M) { + + var C = rad * (1.9148 * sin(M) + 0.02 * sin(2 * M) + 0.0003 * sin(3 * M)), // equation of center + P = rad * 102.9372; // perihelion of the Earth + + return M + C + P + PI; + } + + function sunCoords(d) { + + var M = solarMeanAnomaly(d), + L = eclipticLongitude(M); + + return { + dec: declination(L, 0), + ra: rightAscension(L, 0) + }; + } + + var SunCalc = {}; + + // adds a custom time to the times config + SunCalc.addTime = function (angle, riseName, setName) { + times.push([angle, riseName, setName]); + }; + + // moon calculations, based on http://aa.quae.nl/en/reken/hemelpositie.html formulas + function moonCoords(d) { // geocentric ecliptic coordinates of the moon + var L = rad * (218.316 + 13.176396 * d), // ecliptic longitude + M = rad * (134.963 + 13.064993 * d), // mean anomaly + F = rad * (93.272 + 13.229350 * d), // mean distance + l = L + rad * 6.289 * sin(M), // longitude + b = rad * 5.128 * sin(F), // latitude + dt = 385001 - 20905 * cos(M); // distance to the moon in km + + return { + ra: rightAscension(l, b), + dec: declination(l, b), + dist: dt + }; + } + + SunCalc.getMoonPosition = function (date, lat, lng) { + + var lw = rad * -lng, + phi = rad * lat, + d = toDays(date), + c = moonCoords(d), + H = siderealTime(d, lw) - c.ra, + h = altitude(H, phi, c.dec), + // formula 14.1 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + pa = atan(sin(H), tan(phi) * cos(c.dec) - sin(c.dec) * cos(H)); + h = h + astroRefraction(h); // altitude correction for refraction + return { + azimuth: azimuth(H, phi, c.dec), + altitude: h, + distance: c.dist, + parallacticAngle: pa + }; + }; + + // calculations for illumination parameters of the moon, + // based on http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mphase.pro formulas and + // Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + + SunCalc.getMoonIllumination = function (date) { + var year = date.getFullYear(); + var month = date.getMonth(); + var day = date.getDate(); + var Moon = { + phases: ['new', 'waxing-crescent', 'first-quarter', 'waxing-gibbous', 'full', 'waning-gibbous', 'last-quarter', 'waning-crescent'], + phase: function (year, month, day) { + let c = 0; + let e = 0; + let jd = 0; + let b = 0; + if (month < 3) { + year--; + month += 12; + } + ++month; + c = 365.25 * year; + e = 30.6 * month; + jd = c + e + day - 694039.09; // jd is total days elapsed + jd /= 29.5305882; // divide by the moon cycle + b = parseInt(jd); // int(jd) -> b, take integer part of jd + jd -= b; // subtract integer part to leave fractional part of original jd + b = Math.round(jd * 8); // scale fraction from 0-8 and round + if (b >= 8) b = 0; // 0 and 8 are the same so turn 8 into 0 + //print ({phase: b, name: Moon.phases[b]}); + return {phase: b, name: Moon.phases[b]}; + } + }; + return (Moon.phase(year, month, day)); + }; + + function hoursLater(date, h) { + return new Date(date.valueOf() + h * dayMs / 24); + } + + // calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article + + SunCalc.getMoonTimes = function (date, lat, lng, inUTC) { + var t = new Date(date); + if (inUTC) t.setUTCHours(0, 0, 0, 0); + else t.setHours(0, 0, 0, 0); + var hc = 0.133 * rad, + h0 = SunCalc.getMoonPosition(t, lat, lng).altitude - hc, + h1, h2, rise, set, a, b, xe, ye, d, roots, x1, x2, dx; + + // go in 2-hour chunks, each time seeing if a 3-point quadratic curve crosses zero (which means rise or set) + for (var i = 1; i <= 24; i += 2) { + h1 = SunCalc.getMoonPosition(hoursLater(t, i), lat, lng).altitude - hc; + h2 = SunCalc.getMoonPosition(hoursLater(t, i + 1), lat, lng).altitude - hc; + a = (h0 + h2) / 2 - h1; + b = (h2 - h0) / 2; + xe = -b / (2 * a); + ye = (a * xe + b) * xe + h1; + d = b * b - 4 * a * h1; + roots = 0; + if (d >= 0) { + dx = Math.sqrt(d) / (Math.abs(a) * 2); + x1 = xe - dx; + x2 = xe + dx; + if (Math.abs(x1) <= 1) roots++; + if (Math.abs(x2) <= 1) roots++; + if (x1 < -1) x1 = x2; + } + if (roots === 1) { + if (h0 < 0) rise = i + x1; + else set = i + x1; + } else if (roots === 2) { + rise = i + (ye < 0 ? x2 : x1); + set = i + (ye < 0 ? x1 : x2); + } + if (rise && set) break; + h0 = h2; + } + var result = {}; + if (rise) result.rise = hoursLater(t, rise); + if (set) result.set = hoursLater(t, set); + if (!rise && !set) result[ye > 0 ? 'alwaysUp' : 'alwaysDown'] = true; + return result; + }; + + function getMPhaseComp (offset) { + var date = new Date(); + date.setDate(date.getDate() + offset); + var dd = String(date.getDate()); + if(dd<10){dd='0'+dd;} + var mm = String(date.getMonth() + 1); + if(mm<10){mm='0'+mm;} + var yyyy = date.getFullYear(); + var phase = SunCalc.getMoonIllumination(date); + return dd + "." + mm + "." + yyyy + ": "+ phase.name; + } + + function getMPhaseSim (offset) { + var date = new Date(); + date.setDate(date.getDate() + offset); + var dd = String(date.getDate()); + if(dd<10){dd='0'+dd;} + var mm = String(date.getMonth() + 1); + if(mm<10){mm='0'+mm;} + var yyyy = date.getFullYear(); + var phase = SunCalc.getMoonIllumination(date); + return phase.name; + } + + function drawMoonPhase(offset, x, y){ + if (lat >= 0 && lat <= 90){ //Northern hemisphere + if (getMPhaseSim(offset) == "new") {g.drawImage(getImg("NewMoon"), x, y);} + if (getMPhaseSim(offset) == "waxing-crescent") {g.drawImage(getImg("WaxingCrescentNorth"), x, y);} + if (getMPhaseSim(offset) == "first-quarter") {g.drawImage(getImg("FirstQuarterNorth"), x, y);} + if (getMPhaseSim(offset) == "waxing-gibbous") {g.drawImage(getImg("WaxingGibbousNorth"), x, y);} + if (getMPhaseSim(offset) == "full") {g.drawImage(getImg("FullMoon"), x, y);} + if (getMPhaseSim(offset) == "waning-gibbous") {g.drawImage(getImg("WaningGibbousNorth"), x, y);} + if (getMPhaseSim(offset) == "last-quarter") {g.drawImage(getImg("LastQuarterNorth"), x, y);} + if (getMPhaseSim(offset) == "waning-crescent") {g.drawImage(getImg("WaningCrescentNorth"), x, y);} + } + else { //Southern hemisphere + if (getMPhaseSim(offset) == "new") {g.drawImage(getImg("NewMoon"), x, y);} + if (getMPhaseSim(offset) == "waxing-crescent") {g.drawImage(getImg("WaxingCrescentSouth"), x, y);} + if (getMPhaseSim(offset) == "first-quarter") {g.drawImage(getImg("FirstQuarterSouth"), x, y);} + if (getMPhaseSim(offset) == "waxing-gibbous") {g.drawImage(getImg("WaxingGibbousSouth"), x, y);} + if (getMPhaseSim(offset) == "full") {g.drawImage(getImg("FullMoon"), x, y);} + if (getMPhaseSim(offset) == "waning-gibbous") {g.drawImage(getImg("WaningGibbousSouth"), x, y);} + if (getMPhaseSim(offset) == "last-quarter") {g.drawImage(getImg("LastQuarterSouth"), x, y);} + if (getMPhaseSim(offset) == "waning-crescent") {g.drawImage(getImg("WaningCrescentSouth"), x, y);} + } + } + + function drawMoon(offset, x, y) { + g.setFont("6x8"); + g.clear(); + g.drawString("Key1: increase day, Key3:decrease day",10,10); + g.drawString(getMPhaseComp(offset),x,y-10); + drawMoonPhase(offset, x, y); + + g.drawString(getMPhaseComp(offset+2),x,y+40); + drawMoonPhase(offset+2, x, y+50); + + g.drawString(getMPhaseComp(offset+4),x,y+90); + drawMoonPhase(offset+4, x, y+100); + + g.drawString(getMPhaseComp(offset+6),x,y+140); + drawMoonPhase(offset+6, x, y+150); + } + + function start() { + var x = 10; + var y = 40; + var offsetMoon = 0; + drawMoon(offsetMoon, x, y); //offset, x, y + + //define button functions + setWatch(function() { + offsetMoon++; //jump to next day + drawMoon(offsetMoon, x, y); //offset, x, y + }, BTN1, {edge:"rising", debounce:50, repeat:true}); + setWatch(function() { + offsetMoon--; //jump to next day + drawMoon(offsetMoon, x, y); //offset, x, y + }, BTN3, {edge:"rising", debounce:50, repeat:true}); + } + + start(); \ No newline at end of file diff --git a/apps/moonphase/app.png b/apps/moonphase/app.png new file mode 100644 index 0000000000000000000000000000000000000000..cdad713a1f176b1e316208a897349f016c92b4aa GIT binary patch literal 1722 zcmV;r21WUaP)>Q99owlAJ8oplNlDcz1yrR{C4!AA zRd7HR2T+BSM8F|EKxOrSKyndqLr7IG(3V^Z968VfLTPfyAxJ>03R;y2MQy&CG;v#h zB=I_4KMrY(}nHFWXf#dc8?Ujy(efDmJ> znTVPJNC0vGrT|O;7$>5Ufq{XWJJIh`1#tfSd55AX?-J2R0QOsSzs(rCyt1@KYcV5bEpenX0Oo zo0~&EpV#&AcsyusZZ@TuLlMB6{r&w{YZ=xI;LMpbQBf5C0H8!75flmqOixdPhz$Ki zQA9Kv1+YF^i;IhR{P-~dpsubCe!m|!o6V?+9AoU|zP`RYMn;BfAel_sL{a<^fC2!j zs+tlHVAJ$TrBXjFo0YxcN)Oqjc2ps0btLb zJ>}n-OlC{Hs;YSO=+Tz)g@px7OiW;LaS=pxI1~yE8ugnrqos;%QBjp zn##|GLV;_yF{P@@G)=?O(h}0?G>GWa%a<=JdVT2zKtvw^Xws`UqNSy!JcWozchpo> z-4aCQx=5u`0MH}|!h3ps8BL*n(~7GQMX~&QZEela_Wu3*n3|NcVsdg4`FtLYjg9d6e6ZPU zmFwt*OP4Mk;Q8vU@VFVFk|e?5aDXv})z#JVKbFmAk-ECx z^=_&cMKK28?`l8p2nd33r1E)rc^S*g%UkT6PA3FG0AmbJr_+*P9-5|MVPS#0W{9YV z=ffQV#@GR~+hr{nW9aPcL`zEx=I7^e>((tp`*b=DP1E4_`{8gnDyuqp_S_MWWtnU2 zbUL9ZO1a_H)m0D?N~Mx+TCsoseuP3HNRos=AYdqdgIq3$$;nA9EiF|RbDg;XD2l>O zG3<7GIbj3VcZqB^i(D>Op8u7!wzi_Jt*!jb7^{^&Y~ta=hnr;aY`Cp?z24IN{QQ>S zR8@t;;m|#pHV6iTh(@E3Bxy@seSLkkFkQ?9%N>E{=H^W0UcP~ozAP*v5iQ9bbh z(B9t8O|#qD+R)kAi9jF#Ns=InB78nyr3rUi;|3r}(rhpoG!(gAd_EsKIyxW-o4elF zjuk~gBoaY18ik^4nl-b$_ViBTJK=B`vMg^)Bri#;WZ%AhICkt9_U`@vb$WJo*6`G3 zjNRpxa|0lv-y}&wcXxMr!CGNvW~Qc%EXz1_=ur9mSXo)Yy?gh#wu~`&Je~<&o!$rx z1M3T}r>6(4t*w>iYL4eEU+A2^G;P?B<<#Ju%wxQSfwQJY@0e?MtsQA{t_heN|c3 z(9i&z&BopHE2%m`O=Gv)x8y)iw0x)Mqnl1^n)VHVrRws^7Zp8tBDM=-Y`Rb=T+*x8 z4dD3k)@p$|fGsc!KFNcSR zUuTT{0G-r!2gm?;D;A6WYSzKh?Q}dIze+?e0l02enF&S#9JC@HuowUU#N+V^K@g4* z(T4z1R{c555z*q4P$#b}?e#g2XC z8yOktDwRrc#@JCJiZaI90MtF{BaQWZ{x*OSK@f&}dwcKhRNuSovdeSKe~Yq2c~&-v Q?*IS*07*qoM6N<$f--11*Z=?k literal 0 HcmV?d00001 From bdec83394814f4b6e6b53e97f143ca8dce387ae1 Mon Sep 17 00:00:00 2001 From: Purple-Tentacle <59914607+Purple-Tentacle@users.noreply.github.com> Date: Tue, 31 Mar 2020 23:33:03 +0200 Subject: [PATCH 041/104] Update apps.json --- apps.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps.json b/apps.json index 31921d745..52ec7e987 100644 --- a/apps.json +++ b/apps.json @@ -12,6 +12,18 @@ ], "sortorder" : -10 }, + { "id": "moonphase", + "name": "Moonphase", + "icon": "app.png", + "version":"0.01", + "description": "Shows current moon phase. Currently only with fixed coordinates (northern hemisphere).", + "tags": "", + "allow_emulator":true, + "storage": [ + {"name":"moonphase.app.js","url":"app.js"}, + {"name":"moonphase.img","url":"app-icon.js","evaluate":true} + ] + }, { "id": "daysl", "name": "Days left", "icon": "app.png", From 253382bfe1b825b1b933f91331750d002b8a39bb Mon Sep 17 00:00:00 2001 From: MaBecker Date: Wed, 1 Apr 2020 09:38:41 +0200 Subject: [PATCH 042/104] app widget tiniy battery --- apps/widtbat/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/widtbat/ChangeLog b/apps/widtbat/ChangeLog index 79c4b410d..4c21f3ace 100644 --- a/apps/widtbat/ChangeLog +++ b/apps/widtbat/ChangeLog @@ -1 +1 @@ -001 New widget +0.01: New Widget! From fb20174508a66c41ef207064769a8ab8c147ea68 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Wed, 1 Apr 2020 11:51:06 +0200 Subject: [PATCH 043/104] Bar clock 0.03: Fix dates drawing over each other at midnight --- apps.json | 2 +- apps/barclock/ChangeLog | 1 + apps/barclock/clock-bar.js | 13 ++++++------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps.json b/apps.json index aab3389a1..d6daa2f5c 100644 --- a/apps.json +++ b/apps.json @@ -919,7 +919,7 @@ { "id": "barclock", "name": "Bar Clock", "icon": "clock-bar.png", - "version":"0.02", + "version":"0.03", "description": "A simple digital clock showing seconds as a bar", "tags": "clock", "type":"clock", diff --git a/apps/barclock/ChangeLog b/apps/barclock/ChangeLog index a8d2f5485..89f5a1d58 100644 --- a/apps/barclock/ChangeLog +++ b/apps/barclock/ChangeLog @@ -1,2 +1,3 @@ 0.01: Created Bar Clock 0.02: Apply locale, 12-hour setting +0.03: Fix dates drawing over each other at midnight diff --git a/apps/barclock/clock-bar.js b/apps/barclock/clock-bar.js index 5ab9c433e..21d41da8a 100644 --- a/apps/barclock/clock-bar.js +++ b/apps/barclock/clock-bar.js @@ -59,7 +59,7 @@ g.setFont(timeFont, timeFontSize) g.drawString(timeTexts.time, screenCenter, timeY, true) if (timeTexts.ampm !== '') { - g.setFontAlign(1, -1) + g.setFontAlign(1, -1) // right top g.setFont(timeFont, ampmFontSize) g.drawString(timeTexts.ampm, // at right edge of screen , aligned with time bottom @@ -78,11 +78,10 @@ const fraction = seconds / SECONDS_PER_MINUTE g.fillRect(0, barY, fraction * screenSize, barY + barThickness) } - function eraseBar() { - const color = g.getColor() - g.setColor(g.getBgColor()) - g.fillRect(0, barY, screenSize, barY + barThickness) - g.setColor(color) + function clearScreen() { + g.setColor(0) + g.fillRect(0, timeY - (timeFontSize * 4), screenSize, screenSize) + g.setColor(-1) } let lastSeconds @@ -92,7 +91,7 @@ const seconds = date.getSeconds() if (lastSeconds > seconds) { // new minute - eraseBar() + clearScreen() drawDateTime(date) } drawBar(date) From edd1c0c7bb8bdd9bb09f802c657a4d4122b918ab Mon Sep 17 00:00:00 2001 From: marcocastignoli Date: Wed, 1 Apr 2020 14:16:06 +0200 Subject: [PATCH 044/104] Add timer app --- apps.json | 12 +++++++ apps/timer/app-icon.js | 1 + apps/timer/app.js | 73 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 apps/timer/app-icon.js create mode 100644 apps/timer/app.js diff --git a/apps.json b/apps.json index aab3389a1..0a901ee92 100644 --- a/apps.json +++ b/apps.json @@ -939,5 +939,17 @@ "storage": [ {"name":"widtbat.wid.js","url":"widget.js"} ] + }, + { "id": "timer", + "name": "Timer", + "shortName":"Timer", + "icon": "app.png", + "version":"0.01", + "description": "BTN1 => +5min, BTN2 => +30sec, BTN3 => +5sec, TOUCH => pause,play, BTN1(double click) => reset", + "tags": "Tools", + "storage": [ + {"name":"timer.app.js","url":"app.js"}, + {"name":"timer.img","url":"app-icon.js","evaluate":true} + ] } ] diff --git a/apps/timer/app-icon.js b/apps/timer/app-icon.js new file mode 100644 index 000000000..7388566a1 --- /dev/null +++ b/apps/timer/app-icon.js @@ -0,0 +1 @@ +var img = require("heatshrink").decompress(atob("mEwwglihGIxAWUwADBDCYTDhAXSFwQEGIxowBL4QXTx///AXWF6qnBwCTDO6EIF4KnEDwLWO/4QFx7FNdwQQEGwP4GBYUB/4QBDIYXMIgQAEDIIKCVwItJFggFEx4uKCAQUBX4QDC/B2KhASCAQP/AQQcDLpQlCLgQsCCoIGBC5IkCFon/xwxCDgIXJFwYxFHIR3ILwIkBCIeIFwQHBHgReIJAgCBOoP+MYZIHhB1EDgIRBA4ZIJC4LrEMYvoAgQXJxHvI4gtDC5OIF4QSDbYY3EC5QAKG4QXNPwg0BSBAJCIQhLCDwgXKIAwXUMo4XPFwrwKC4YOCUooVCR453DIxIXJU4IqDxwXJa45FDdgxnEC40IC4TbINQYXIRQZwDAAXv/xuBCwoXBVAgXDA4wXGSARcEC4o7BRwx4DOon+C4YiCLwxIDDAobDEYJGIGAYYBxDAD9AJDC5IwCDIYACJARGIDAapDaooWLDAZhEAoIWNMggADCqAAPA")) \ No newline at end of file diff --git a/apps/timer/app.js b/apps/timer/app.js new file mode 100644 index 000000000..82a78ae10 --- /dev/null +++ b/apps/timer/app.js @@ -0,0 +1,73 @@ +function msToTime(duration) { + var milliseconds = parseInt((duration % 1000) / 100), + seconds = Math.floor((duration / 1000) % 60), + minutes = Math.floor((duration / (1000 * 60)) % 60), + hours = Math.floor((duration / (1000 * 60 * 60)) % 24); + + hours = (hours < 10) ? "0" + hours : hours; + minutes = (minutes < 10) ? "0" + minutes : minutes; + seconds = (seconds < 10) ? "0" + seconds : seconds; + + return hours + ":" + minutes + ":" + seconds; + } + + + var counter = 0; + var started = false; + + function drawInterface() { + g.clear(); + g.setFontAlign(0,0); + g.setFont("6x8",2); + g.drawString("+5m", g.getWidth()-30, 30); + g.drawString("+30s", g.getWidth()-30, g.getHeight()/2); + g.drawString("+5s", g.getWidth()-30, g.getHeight() - 30); + + g.setFontAlign(0,0); // center font + g.setFont("6x8",3); + // draw the current counter value + + g.drawString(msToTime(counter*1000), g.getWidth()/2 - 30, g.getHeight()/2); + // optional - this keeps the watch LCD lit up + g.flip(); + } + + function countDown() { + if(counter > 0) { + if (started) { + counter--; + drawInterface(); + } + } else { + if (started) { + Bangle.buzz(); + } + } + } + + setWatch((p) => { + if (p.time - p.lastTime < 0.1) { + counter = 0; + started = false; + } else { + counter+=60*5; + } + drawInterface(); + }, BTN1, {repeat:true}); + + setWatch(() => { + counter+=30; + drawInterface(); + }, BTN2, {repeat:true}); + + setWatch(() => { + counter+=5; + drawInterface(); + }, BTN3, {repeat:true}); + + Bangle.on('touch', function(button) { + started = !started; + }); + + var interval = setInterval(countDown, 1000); + drawInterface(); \ No newline at end of file From 14faa1a4a3013d46d92d60710521968164cfd087 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Wed, 1 Apr 2020 14:16:35 +0200 Subject: [PATCH 045/104] Bar clock code cleanup --- apps/barclock/clock-bar.js | 131 ++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 47 deletions(-) diff --git a/apps/barclock/clock-bar.js b/apps/barclock/clock-bar.js index 21d41da8a..f106f8125 100644 --- a/apps/barclock/clock-bar.js +++ b/apps/barclock/clock-bar.js @@ -5,7 +5,7 @@ { // Check settings for what type our clock should be const is12Hour = (require('Storage').readJSON('setting.json', 1) || {})['12hour'] - const locale = require('locale') + let locale = require('locale') { // add some more info to locale let date = new Date() date.setFullYear(1111) @@ -14,78 +14,110 @@ locale.dayFirst = /3.*2/.test(localized) locale.hasMeridian = (locale.meridian(date) !== '') } + const screen = { + width: g.getWidth(), + height: g.getWidth(), + middle: g.getWidth() / 2, + center: g.getHeight() / 2, + } - const timeFont = '6x8' - const timeFontSize = (is12Hour && locale.hasMeridian) ? 6 : 8 - const ampmFontSize = 2 - const dateFont = 'Vector' - const dateFontSize = 20 - - const screenSize = g.getWidth() - const screenCenter = screenSize / 2 - - const timeY = screenCenter - const barY = 155 // just below time - const barThickness = 6 // matches time digit size - const dateY = screenSize - dateFontSize // at bottom of screen + // hardcoded "settings" + const settings = { + time: { + color: -1, + font: '6x8', + size: (is12Hour && locale.hasMeridian) ? 6 : 8, + middle: screen.middle, + center: screen.center, + ampm: { + color: -1, + font: '6x8', + size: 2, + }, + }, + date: { + color: -1, + font: 'Vector', + size: 20, + middle: screen.height - 20, // at bottom of screen + center: screen.center, + }, + bar: { + color: -1, + top: 155, // just below time + thickness: 6, // matches 24h time "pixel" size + }, + } const SECONDS_PER_MINUTE = 60 - - function timeText(date) { + const timeText = function (date) { if (!is12Hour) { - return {time: locale.time(date, true), ampm: ''} + return locale.time(date, true) } - const meridian = locale.meridian(date) - const hours = date.getHours() + const date12 = new Date(date.getTime()) + const hours = date12.getHours() if (hours === 0) { - date.setHours(12) + date12.setHours(12) } else if (hours > 12) { - date.setHours(hours - 12) + date12.setHours(hours - 12) } - return {time: locale.time(date, true), ampm: meridian} + return locale.time(date12, true) + } + const ampmText = function (date) { + return is12Hour ? locale.meridian(date) : '' } - function dateText(date) { + const dateText = function (date) { const dayName = locale.dow(date, true), month = locale.month(date, true), day = date.getDate() - return `${dayName} ` + (locale.dayFirst ? `${day} ${month}` : `${month} ${day}`) + const dayMonth = locale.dayFirst ? `${day} ${month}` : `${month} ${day}` + return `${dayName} ${dayMonth}` } - function drawDateTime(date) { - const timeTexts = timeText(date) + const drawDateTime = function (date) { + const t = settings.time + g.setColor(t.color) + g.setFont(t.font, t.size) g.setFontAlign(0, 0) // centered - g.setFont(timeFont, timeFontSize) - g.drawString(timeTexts.time, screenCenter, timeY, true) - if (timeTexts.ampm !== '') { + g.drawString(timeText(date), t.center, t.middle, true) + if (is12Hour && locale.hasMeridian) { + const a = settings.time.ampm + g.setColor(a.color) + g.setFont(a.font, a.size) g.setFontAlign(1, -1) // right top - g.setFont(timeFont, ampmFontSize) - g.drawString(timeTexts.ampm, - // at right edge of screen , aligned with time bottom - (screenSize - ampmFontSize * 2), (timeY + timeFontSize - ampmFontSize), - true) + // at right edge of screen, aligned with time bottom + const left = screen.width - a.size * 2, + top = t.middle + t.size - a.size + g.drawString(ampmText(date), left, top, true) } + const d = settings.date + g.setColor(d.color) + g.setFont(d.font, d.size) g.setFontAlign(0, 0) // centered - g.setFont(dateFont, dateFontSize) - g.drawString(dateText(date), screenCenter, dateY, true) + g.drawString(dateText(date), d.center, d.middle, true) } - function drawBar(date) { + const drawBar = function (date) { + const b = settings.bar const seconds = date.getSeconds() - if (seconds === 0) return; // zero-size rect stills draws one line of pixels - const fraction = seconds / SECONDS_PER_MINUTE - g.fillRect(0, barY, fraction * screenSize, barY + barThickness) + if (seconds === 0) return // zero-size rect stills draws one line of pixels + const fraction = seconds / SECONDS_PER_MINUTE, + width = fraction * screen.width + g.setColor(b.color) + g.fillRect(0, b.top, width, b.top + b.thickness) } - function clearScreen() { + + const clearScreen = function () { g.setColor(0) - g.fillRect(0, timeY - (timeFontSize * 4), screenSize, screenSize) - g.setColor(-1) + const timeTop = settings.time.middle - (settings.time.size * 4) + g.fillRect(0, timeTop, screen.width, screen.height) } let lastSeconds - function tick() { + const tick = function () { g.reset() const date = new Date() const seconds = date.getSeconds() @@ -94,18 +126,19 @@ clearScreen() drawDateTime(date) } + // the bar only gets larger, so drawing on top of the previous one is fine drawBar(date) lastSeconds = seconds } let iTick - function start() { + const start = function () { lastSeconds = 99 // force redraw tick() iTick = setInterval(tick, 1000) } - function stop() { + const stop = function () { if (iTick) { clearInterval(iTick) iTick = undefined @@ -120,7 +153,11 @@ setWatch(Bangle.showLauncher, BTN2, {repeat: false, edge: 'falling'}) Bangle.on('lcdPower', function (on) { - on ? start() : stop() + if (on) { + start() + } else { + stop() + } }) start() } From ef391cefbf59c76037244cba4f0cb51d6be166da Mon Sep 17 00:00:00 2001 From: marcocastignoli Date: Wed, 1 Apr 2020 14:22:25 +0200 Subject: [PATCH 046/104] Fix timer app --- apps.json | 6 ++-- apps/timer/app-icon.js | 1 - apps/timer/app.js | 73 --------------------------------------- apps/timer/timer-icon.js | 1 + apps/timer/timer.js | 73 +++++++++++++++++++++++++++++++++++++++ apps/timer/timer.png | Bin 0 -> 3630 bytes 6 files changed, 77 insertions(+), 77 deletions(-) delete mode 100644 apps/timer/app-icon.js delete mode 100644 apps/timer/app.js create mode 100644 apps/timer/timer-icon.js create mode 100644 apps/timer/timer.js create mode 100644 apps/timer/timer.png diff --git a/apps.json b/apps.json index 0a901ee92..cef59b0e6 100644 --- a/apps.json +++ b/apps.json @@ -943,13 +943,13 @@ { "id": "timer", "name": "Timer", "shortName":"Timer", - "icon": "app.png", + "icon": "timer.png", "version":"0.01", "description": "BTN1 => +5min, BTN2 => +30sec, BTN3 => +5sec, TOUCH => pause,play, BTN1(double click) => reset", "tags": "Tools", "storage": [ - {"name":"timer.app.js","url":"app.js"}, - {"name":"timer.img","url":"app-icon.js","evaluate":true} + {"name":"timer.app.js","url":"timer.js"}, + {"name":"timer.img","url":"timer-icon.js","evaluate":true} ] } ] diff --git a/apps/timer/app-icon.js b/apps/timer/app-icon.js deleted file mode 100644 index 7388566a1..000000000 --- a/apps/timer/app-icon.js +++ /dev/null @@ -1 +0,0 @@ -var img = require("heatshrink").decompress(atob("mEwwglihGIxAWUwADBDCYTDhAXSFwQEGIxowBL4QXTx///AXWF6qnBwCTDO6EIF4KnEDwLWO/4QFx7FNdwQQEGwP4GBYUB/4QBDIYXMIgQAEDIIKCVwItJFggFEx4uKCAQUBX4QDC/B2KhASCAQP/AQQcDLpQlCLgQsCCoIGBC5IkCFon/xwxCDgIXJFwYxFHIR3ILwIkBCIeIFwQHBHgReIJAgCBOoP+MYZIHhB1EDgIRBA4ZIJC4LrEMYvoAgQXJxHvI4gtDC5OIF4QSDbYY3EC5QAKG4QXNPwg0BSBAJCIQhLCDwgXKIAwXUMo4XPFwrwKC4YOCUooVCR453DIxIXJU4IqDxwXJa45FDdgxnEC40IC4TbINQYXIRQZwDAAXv/xuBCwoXBVAgXDA4wXGSARcEC4o7BRwx4DOon+C4YiCLwxIDDAobDEYJGIGAYYBxDAD9AJDC5IwCDIYACJARGIDAapDaooWLDAZhEAoIWNMggADCqAAPA")) \ No newline at end of file diff --git a/apps/timer/app.js b/apps/timer/app.js deleted file mode 100644 index 82a78ae10..000000000 --- a/apps/timer/app.js +++ /dev/null @@ -1,73 +0,0 @@ -function msToTime(duration) { - var milliseconds = parseInt((duration % 1000) / 100), - seconds = Math.floor((duration / 1000) % 60), - minutes = Math.floor((duration / (1000 * 60)) % 60), - hours = Math.floor((duration / (1000 * 60 * 60)) % 24); - - hours = (hours < 10) ? "0" + hours : hours; - minutes = (minutes < 10) ? "0" + minutes : minutes; - seconds = (seconds < 10) ? "0" + seconds : seconds; - - return hours + ":" + minutes + ":" + seconds; - } - - - var counter = 0; - var started = false; - - function drawInterface() { - g.clear(); - g.setFontAlign(0,0); - g.setFont("6x8",2); - g.drawString("+5m", g.getWidth()-30, 30); - g.drawString("+30s", g.getWidth()-30, g.getHeight()/2); - g.drawString("+5s", g.getWidth()-30, g.getHeight() - 30); - - g.setFontAlign(0,0); // center font - g.setFont("6x8",3); - // draw the current counter value - - g.drawString(msToTime(counter*1000), g.getWidth()/2 - 30, g.getHeight()/2); - // optional - this keeps the watch LCD lit up - g.flip(); - } - - function countDown() { - if(counter > 0) { - if (started) { - counter--; - drawInterface(); - } - } else { - if (started) { - Bangle.buzz(); - } - } - } - - setWatch((p) => { - if (p.time - p.lastTime < 0.1) { - counter = 0; - started = false; - } else { - counter+=60*5; - } - drawInterface(); - }, BTN1, {repeat:true}); - - setWatch(() => { - counter+=30; - drawInterface(); - }, BTN2, {repeat:true}); - - setWatch(() => { - counter+=5; - drawInterface(); - }, BTN3, {repeat:true}); - - Bangle.on('touch', function(button) { - started = !started; - }); - - var interval = setInterval(countDown, 1000); - drawInterface(); \ No newline at end of file diff --git a/apps/timer/timer-icon.js b/apps/timer/timer-icon.js new file mode 100644 index 000000000..580713825 --- /dev/null +++ b/apps/timer/timer-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwglihGIxAWUwADBDCYTDhAXSFwQEGIxowBL4QXTx///AXWF6qnBwCTDO6EIF4KnEDwLWO/4QFx7FNdwQQEGwP4GBYUB/4QBDIYXMIgQAEDIIKCVwItJFggFEx4uKCAQUBX4QDC/B2KhASCAQP/AQQcDLpQlCLgQsCCoIGBC5IkCFon/xwxCDgIXJFwYxFHIR3ILwIkBCIeIFwQHBHgReIJAgCBOoP+MYZIHhB1EDgIRBA4ZIJC4LrEMYvoAgQXJxHvI4gtDC5OIF4QSDbYY3EC5QAKG4QXNPwg0BSBAJCIQhLCDwgXKIAwXUMo4XPFwrwKC4YOCUooVCR453DIxIXJU4IqDxwXJa45FDdgxnEC40IC4TbINQYXIRQZwDAAXv/xuBCwoXBVAgXDA4wXGSARcEC4o7BRwx4DOon+C4YiCLwxIDDAobDEYJGIGAYYBxDAD9AJDC5IwCDIYACJARGIDAapDaooWLDAZhEAoIWNMggADCqAAPA")) \ No newline at end of file diff --git a/apps/timer/timer.js b/apps/timer/timer.js new file mode 100644 index 000000000..cd50b8a22 --- /dev/null +++ b/apps/timer/timer.js @@ -0,0 +1,73 @@ +function msToTime(duration) { + var milliseconds = parseInt((duration % 1000) / 100), + seconds = Math.floor((duration / 1000) % 60), + minutes = Math.floor((duration / (1000 * 60)) % 60), + hours = Math.floor((duration / (1000 * 60 * 60)) % 24); + + hours = (hours < 10) ? "0" + hours : hours; + minutes = (minutes < 10) ? "0" + minutes : minutes; + seconds = (seconds < 10) ? "0" + seconds : seconds; + + return hours + ":" + minutes + ":" + seconds; +} + + +var counter = 0; +var started = false; + +function drawInterface() { + g.clear(); + g.setFontAlign(0, 0); + g.setFont("6x8", 2); + g.drawString("+5m", g.getWidth() - 30, 30); + g.drawString("+30s", g.getWidth() - 30, g.getHeight() / 2); + g.drawString("+5s", g.getWidth() - 30, g.getHeight() - 30); + + g.setFontAlign(0, 0); // center font + g.setFont("6x8", 3); + // draw the current counter value + + g.drawString(msToTime(counter * 1000), g.getWidth() / 2 - 30, g.getHeight() / 2); + // optional - this keeps the watch LCD lit up + g.flip(); +} + +function countDown() { + if (counter > 0) { + if (started) { + counter--; + drawInterface(); + } + } else { + if (started) { + Bangle.buzz(); + } + } +} + +setWatch((p) => { + if (p.time - p.lastTime < 0.1) { + counter = 0; + started = false; + } else { + counter += 60 * 5; + } + drawInterface(); +}, BTN1, { repeat: true }); + +setWatch(() => { + counter += 30; + drawInterface(); +}, BTN2, { repeat: true }); + +setWatch(() => { + counter += 5; + drawInterface(); +}, BTN3, { repeat: true }); + +Bangle.on('touch', function (button) { + started = !started; +}); + +var interval = setInterval(countDown, 1000); +drawInterface(); \ No newline at end of file diff --git a/apps/timer/timer.png b/apps/timer/timer.png new file mode 100644 index 0000000000000000000000000000000000000000..c1aaf180da22407f079a2d4d2fca2600e58c3b09 GIT binary patch literal 3630 zcmV+}4$<+6P)%wuIoBr2i%=BX6Hc=gwr%<9ZV)ujx5VfHk-|e zj*d1YNz#GI0HP>9D~jUUpOI>t$QJ~m0>}d%x7lp9%a<=VN=r+Ph=_;=K@dI`1flYx zP51T!sjB)v7K`Pa$z)mpSg$s)*g5=JU>L?9L{aQ2iegVq(}HoEnwliTFy1r_W2#{o z$-wD$;!Jcn93z%4T^gR6nmSuilyV@xy@5MxXN&^|%d*_lZnq~kH8u6xzkk1J`}Xae zJ9kb}Rn_nJ`^_{bjeh~g6=GN{7E4KfetvjDLV}QWhY$Z(MMZ_Ty1H60 zo6Uc9I-QGw1DC~1lO!oTGBPrl8IK$}VhDopm-a|pPZ|xg+wF@2fk1Y8db%)v{CMkt z0RuYhTw7a9Sy`D@R8-^*1Oi_rrow|*)oUOY-ZN1S%%;5*L7W=0F<=Hslx(P zRb8a2>LUdO1-7`jH~=(FW9QDDe6VSg`{>c5%8e;0zLa6ZEZuwbkYuwNK@>SxQ^SGs z^2YK#dqjY7W5=4ava+NW@h+E(l`B{J%FD}@MT-`(Wy_YPva+&rr_(tB`2K3VIwU|< z)ddj|5s$s}(n~gn!vVmjpMGk*wsNIEre{y>zUkA|TQf2+o6SL=aU(}kxMd4n!o!1o zUsY7F@$I*L#ap+E6DLmOjyvu!TdmERvb406S6+DqK@d*6T&_VtLr1uEB#quI%kpE( zmMyb691a>A8_CPdYh3sC+rH(mzplKqd9ylt>{yyN+DoWEe;$j)5^V4N;tR@(iz!&V zSlLusYCczAuRZwCL*A;YDgefe8N8wNmGaWOORy%)o{lpWvv-~&{fE!Zx6^G%|l5)%_CC@8R5t=4V8pw1BRA2yrq7b8cG#4rq=nLpn%DlN_Q%=6DH zCex)1oSvD9+vQ^SKmHNyiyt_!RUlbW7=Qci!FFv;4N0k~d{9y%7nhU-)~#FT2S`p% zX6DS9HdR$O0~W4=b_Lk&_BoR#O;Q1hii!fF$;90Jd^5nx<;$t5t_DDoB;I)UU2gj2 zF9BG$Y84YkjbcPX0{=a39P8JtVd2uHw5*>%Ai%@-+{3=zyNQgB=B*DuwCpG?)%Wb# z13+eGrkIkF5@omB|M*h`2u)2*6Go37E&Ba_3O8&po`3met0*?R$g<2G7V{YZA}fuTeq?(KR+0FT_yVmV07W zmTlCiQ2?x3waUM3+qShXm+NahsZ})C`_w5_BaX1_(ibA8?&H6QKc224jBT#t4o*iRBkTstX<35GiQF}H2F8b;n}=AYR;Zz z=u zb@*`BzV{yeF7Do!;!x)i}K-$ouxLqz1ZoE-EeB?;*^cfWug<%-I+ltZNs|isrrbeI7CjxxDeLK%T z^9(MhlTo8b^TLW1S9GkZtYpgg@ra_x&I1RoXaiueSlC=vhNfvql7!7}CvLz1PMkOq zJXG0iHZ)DMUylI0#bUv1HskSlOaQlLWRRGYgw<+Av9!HO9yxRf)n+4Y+&DrmJ91wM zHhXJskx@}xIDcL?3R}7&eQ=LP$smO@6=FGMBqWMz%|+rn;IX z3m5YG`t>BGrnYN)B}gU{vZ81nkH@5{Dn6eNQ51b`*|)g{48xGkW-}&}35&%NaJgJp z9o#Ssp32STu6yq3F!}tsb2)zWXlqiUh^93!JFnM^D2kqI7NG08x#fHx9v<$mIeQiW zpU=mZ_uuFC^mOXJZ(VP^wR$yfr<33PAhouKA<4+qMP!ydIC#QYV}_a|Tfq zkGJLD<`j}7sov>y0uU7)t^f1nNn!^K;MFBdI9ydl{=$W=ij||^e#`5xyuv%1HzP?M zzwDSYZ5o+bS+tz7YO1SIRW)ETnaltuPMpv^9?za@766>7tE(Ff(5H8A<5e?R^D_xAy2fb#Nkm(SjT_ghf7fT9`GyQ0Yyt55{Tw`aPyw#E3qw0=!0-2eUS3}AhUQA?a8;G%d|h4e z`MgITrKY-?oV+~#dGaI$FTU7e@&G-0^`hX(C)vJb%jIM8*Nq#+jEoEuKt)9bR;%?O zP=Cz=fWIF*c1*6TtHWxwa?`M3{&lNX1$X30Q>U`xjW_5P8OdKZY(TZy_(M((`*t;d zZC%%S?&+t4!E{|`b5T*S-9J8_)rE!BUv@}<7g?OOfh@#6ptA32iC%gP-eeZ+x^3I-=91I>$Z$44Kv5-|UX zC-C_$rS$&s@!WZF+MTPZVcB!f1sIxxmv!fRTO35_uqdXH)6yHQ(SDU5Ed3DJ~?-8;Pk0eO+%8C zO;)wJ&gmN)OL#;?(9vSGVz=2yxbe~riPz(yUtC>%! z@Njdt$jD$WhvqMGIeCEOp+ke@y&ezmZ`h#EzW@HF;WynR%$haJA_xMFjg92w=^$#bH;Pw!Ue6qz80;LCMGJWsi}1B+BN9^`RAXrWXY1oKp^n4+wGpmmH$KdNdf>w zNs{idSS*X|cDp?@GgBQpbf^>;7k5p^hZcCfUUu%>$;OQvT{Sf|)lR4L0pM@f661RR zW)*;uR;%?clgV_O*XxamjErpT*RP)x7Z+!biHRX3B!tk=P#g{i9*+l)$Aj1FrM9+~ z;uT&^zyfxwqQDRA|3`u}D8FN&r-)Maf#TmS$707*qoM6N<$g4o#y A=Kufz literal 0 HcmV?d00001 From f5fde30320c54708b94d7895b5818555fc7c61ca Mon Sep 17 00:00:00 2001 From: marcocastignoli Date: Wed, 1 Apr 2020 14:25:53 +0200 Subject: [PATCH 047/104] Add description to timer app --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index cef59b0e6..add21c0cf 100644 --- a/apps.json +++ b/apps.json @@ -945,7 +945,7 @@ "shortName":"Timer", "icon": "timer.png", "version":"0.01", - "description": "BTN1 => +5min, BTN2 => +30sec, BTN3 => +5sec, TOUCH => pause,play, BTN1(double click) => reset", + "description": "Single click BTN1 to add 5 minutes. Single click BTN2 to add 30 seconds. Single click BTN3 to add 5 seconds. Tap to pause or play to timer. Double click BTN1 to reset. When timer finishes the watch vibrates.", "tags": "Tools", "storage": [ {"name":"timer.app.js","url":"timer.js"}, From 2c7696387a1e695fc4212f7679d935a25819d845 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Wed, 1 Apr 2020 14:59:06 +0200 Subject: [PATCH 048/104] Bar clock: fix SyntaxError Seems the app still works though (Snuck in during code cleanup, I'm blaming autoformat) --- apps.json | 2 +- apps/barclock/ChangeLog | 1 + apps/barclock/clock-bar.js | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index d6daa2f5c..0931d8a98 100644 --- a/apps.json +++ b/apps.json @@ -919,7 +919,7 @@ { "id": "barclock", "name": "Bar Clock", "icon": "clock-bar.png", - "version":"0.03", + "version":"0.04", "description": "A simple digital clock showing seconds as a bar", "tags": "clock", "type":"clock", diff --git a/apps/barclock/ChangeLog b/apps/barclock/ChangeLog index 89f5a1d58..2e0fd088c 100644 --- a/apps/barclock/ChangeLog +++ b/apps/barclock/ChangeLog @@ -1,3 +1,4 @@ 0.01: Created Bar Clock 0.02: Apply locale, 12-hour setting 0.03: Fix dates drawing over each other at midnight +0.04: Small bugfix diff --git a/apps/barclock/clock-bar.js b/apps/barclock/clock-bar.js index f106f8125..da436daee 100644 --- a/apps/barclock/clock-bar.js +++ b/apps/barclock/clock-bar.js @@ -103,7 +103,10 @@ const drawBar = function (date) { const b = settings.bar const seconds = date.getSeconds() - if (seconds === 0) return // zero-size rect stills draws one line of pixels + if (seconds === 0) { + // zero-size rect stills draws one line of pixels, we don't want that + return + } const fraction = seconds / SECONDS_PER_MINUTE, width = fraction * screen.width g.setColor(b.color) From 54c4e7aaf1cab8b1fedb73b01ae978599957f69e Mon Sep 17 00:00:00 2001 From: marcocastignoli Date: Wed, 1 Apr 2020 15:40:43 +0200 Subject: [PATCH 049/104] Rename timer to chrono --- apps.json | 12 ++++++------ apps/{timer/timer-icon.js => chrono/chrono-icon.js} | 0 apps/{timer/timer.js => chrono/chrono.js} | 0 apps/{timer/timer.png => chrono/chrono.png} | Bin 4 files changed, 6 insertions(+), 6 deletions(-) rename apps/{timer/timer-icon.js => chrono/chrono-icon.js} (100%) rename apps/{timer/timer.js => chrono/chrono.js} (100%) rename apps/{timer/timer.png => chrono/chrono.png} (100%) diff --git a/apps.json b/apps.json index add21c0cf..07f1b2e56 100644 --- a/apps.json +++ b/apps.json @@ -940,16 +940,16 @@ {"name":"widtbat.wid.js","url":"widget.js"} ] }, - { "id": "timer", - "name": "Timer", - "shortName":"Timer", - "icon": "timer.png", + { "id": "chrono", + "name": "Chrono", + "shortName":"Chrono", + "icon": "chrono.png", "version":"0.01", "description": "Single click BTN1 to add 5 minutes. Single click BTN2 to add 30 seconds. Single click BTN3 to add 5 seconds. Tap to pause or play to timer. Double click BTN1 to reset. When timer finishes the watch vibrates.", "tags": "Tools", "storage": [ - {"name":"timer.app.js","url":"timer.js"}, - {"name":"timer.img","url":"timer-icon.js","evaluate":true} + {"name":"chrono.app.js","url":"chrono.js"}, + {"name":"chrono.img","url":"chrono-icon.js","evaluate":true} ] } ] diff --git a/apps/timer/timer-icon.js b/apps/chrono/chrono-icon.js similarity index 100% rename from apps/timer/timer-icon.js rename to apps/chrono/chrono-icon.js diff --git a/apps/timer/timer.js b/apps/chrono/chrono.js similarity index 100% rename from apps/timer/timer.js rename to apps/chrono/chrono.js diff --git a/apps/timer/timer.png b/apps/chrono/chrono.png similarity index 100% rename from apps/timer/timer.png rename to apps/chrono/chrono.png From 143e3da6f6a3def2572425122a1ba03ab1158add Mon Sep 17 00:00:00 2001 From: Christian Hemker Date: Wed, 1 Apr 2020 20:14:07 +0200 Subject: [PATCH 050/104] test --- apps/daysl/widget.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/daysl/widget.js b/apps/daysl/widget.js index 5a3c170c2..9eaf8afca 100644 --- a/apps/daysl/widget.js +++ b/apps/daysl/widget.js @@ -27,7 +27,6 @@ function updateSettings() { const diffDays = Math.round(Math.abs((targetDate - today) / oneDay)); WIDGETS["daysl"]={area:"tl",width:40,draw:function(){ - g.setFont("6x8", 1); g.drawString(diffDays,this.x+12,this.y+12); }}; \ No newline at end of file From 40be3f0a27653f6aafa22b9c6faf02e2af9c3965 Mon Sep 17 00:00:00 2001 From: Christian Hemker Date: Wed, 1 Apr 2020 20:18:50 +0200 Subject: [PATCH 051/104] calc to end of target day , default year 2020 --- apps/daysl/widget.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/daysl/widget.js b/apps/daysl/widget.js index 9eaf8afca..f71253a3a 100644 --- a/apps/daysl/widget.js +++ b/apps/daysl/widget.js @@ -4,12 +4,12 @@ let settings; function updateSettings() { storage.write('daysleft.json', settings); } - + function resetSettings() { settings = { day : 17, month : 6, - year: 1981 + year: 2020 }; updateSettings(); } @@ -17,12 +17,12 @@ function updateSettings() { settings = storage.readJSON('daysleft.json',1); if (!settings) resetSettings(); - var dd = settings.day+1, - mm = settings.month-1, + var dd = settings.day, + mm = settings.month-1, //month is zero-based yy = settings.year; const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds - const targetDate = new Date(yy, mm, dd); + const targetDate = new Date(yy, mm, dd, 23, 59, 59); const today = new Date(); const diffDays = Math.round(Math.abs((targetDate - today) / oneDay)); From fc409e3f776f7f77cbf03cf59f8186fe15fb6f09 Mon Sep 17 00:00:00 2001 From: Christian Hemker Date: Wed, 1 Apr 2020 21:27:51 +0200 Subject: [PATCH 052/104] changed calculation --- apps/daysl/widget.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/daysl/widget.js b/apps/daysl/widget.js index f71253a3a..6fb755d1e 100644 --- a/apps/daysl/widget.js +++ b/apps/daysl/widget.js @@ -22,9 +22,16 @@ function updateSettings() { yy = settings.year; const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds - const targetDate = new Date(yy, mm, dd, 23, 59, 59); + const targetDate = new Date(yy, mm, dd); const today = new Date(); - const diffDays = Math.round(Math.abs((targetDate - today) / oneDay)); + + //create date object with today, but 00:00:00 + const currentYear = today.getFullYear(); + const currentMonth = today.getMonth(); + const currentDay = today.getDate(); + const todayMorning = new Date (currentYear, currentMonth, currentDay, 0, 0, 0); + + const diffDays = (targetDate - todayMorning) / oneDay; WIDGETS["daysl"]={area:"tl",width:40,draw:function(){ g.setFont("6x8", 1); From b0a0bf1ec04ff8de748a8a1e5c8dd40c0d01c4ef Mon Sep 17 00:00:00 2001 From: Christian Hemker Date: Wed, 1 Apr 2020 22:10:18 +0200 Subject: [PATCH 053/104] changed calculation, new image --- apps.json | 2 +- apps/daysl/ChangeLog | 1 + apps/daysl/app-icon.js | 2 +- apps/daysl/app.png | Bin 287 -> 468 bytes 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index a84a8010c..db7859e1a 100644 --- a/apps.json +++ b/apps.json @@ -27,7 +27,7 @@ { "id": "daysl", "name": "Days left", "icon": "app.png", - "version":"0.01", + "version":"0.02", "description": "Shows you the days left until a certain date. Date can be set with a settings app and is written to a file.", "tags": "", "allow_emulator":false, diff --git a/apps/daysl/ChangeLog b/apps/daysl/ChangeLog index 4c21f3ace..4e0b8e6cf 100644 --- a/apps/daysl/ChangeLog +++ b/apps/daysl/ChangeLog @@ -1 +1,2 @@ 0.01: New Widget! +0.02: Improved calculation, new image for app diff --git a/apps/daysl/app-icon.js b/apps/daysl/app-icon.js index 485478c58..22c03d87a 100644 --- a/apps/daysl/app-icon.js +++ b/apps/daysl/app-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("mEwwMB//D/4CgwHDFYPDgICBAoQCB/4CKADmAAgcBIARCCAqQAXF/4v24CtDgYFR")) \ No newline at end of file +require("heatshrink").decompress(atob("i4A/AH4A/AH4A/AH4A/AH4A/AAUAABQNdF/4v/F64JLBqMrAgMrC54vbGAIuCF54TIBp4JDCIYvNOZINPGAoRCO5wrHBp7vVF/4v/F9IlLF/6PYF9xfRlYEBlYvJBpZeITJsrEASxJBpQuIZLCnPHYovpFwwXKABINdF/4v/F6oA/AH4A/AH4A/AH4A/AH4A7A==")) \ No newline at end of file diff --git a/apps/daysl/app.png b/apps/daysl/app.png index 703e5c366c7bf7ad21000427fcda514c599770e9..42839ae59e2cf440042fd85d0ab7e20047254bc8 100644 GIT binary patch delta 425 zcmV;a0apH>0@MSLBrgGTQb$4nuFf3k00004XF*Lt006O%3;baP00009a7bBm000&x z000&x0ZCFM@R1=De*srXL_t(&L+zQrio!q;#^=Q1YKvfzz;%LYz1laiu&}=F;I7un zC$RKAd;+b6E7A!`Ar`5xyJI#Z#+dz+AWkClgC!qkXPGZESvL3r>*F7^m=0ZAix}WW z3~(a`xDf-~hyiYH&q9+v2}jn)?E2_9LRyHMCw>PCy>>%!f8L$q{I3xtNuqQR1Q5@+ zO6%5dTm_QFP9=Voya6Wz_*8IIrApjjJ|+b!@qF^8HLM0O7)y#H_coX% zNGc;uQ&QzL?j88~+>iq3PA_e!L%xZ*5d+-Fe`MT<0dB+qH)4PrF~E%&;053xq9Tsq Tou?iF00000NkvXXu0mjfigda{ delta 259 zcmV+e0sQ{d1D^trB!32COGiWi{{a60|De66lK=n!)Ja4^RA_m#C0W~(D#yOzI2Go>tAjF@W@Ex!LHFw+bL$f6PI&=U4002ov JPDHLkV1lG)cgX+% From 5829ed618d3057d90abe2406445f05545c60b625 Mon Sep 17 00:00:00 2001 From: Christian Hemker Date: Wed, 1 Apr 2020 22:23:18 +0200 Subject: [PATCH 054/104] corrected image --- apps/daysl/app-icon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/daysl/app-icon.js b/apps/daysl/app-icon.js index 22c03d87a..bdc0da744 100644 --- a/apps/daysl/app-icon.js +++ b/apps/daysl/app-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("i4A/AH4A/AH4A/AH4A/AH4A/AAUAABQNdF/4v/F64JLBqMrAgMrC54vbGAIuCF54TIBp4JDCIYvNOZINPGAoRCO5wrHBp7vVF/4v/F9IlLF/6PYF9xfRlYEBlYvJBpZeITJsrEASxJBpQuIZLCnPHYovpFwwXKABINdF/4v/F6oA/AH4A/AH4A/AH4A/AH4A7A==")) \ No newline at end of file +require("heatshrink").decompress(atob("mEwgmIAH4A/AH4A/AEEAAAgGOC/4XLAgoGIDgYXTwEIBY4JEAw8YCIOAEY4+EAwwTCL44XNO5IX/C6i6LC8YABa5AXOF67vIwA5DAw5GDMhg7HjAXWIwQLFZIoGNC/4XKAH4A/AH4A/ADoA=")) \ No newline at end of file From 22d93ef884d9b06f864a1359bbd818083cbfe221 Mon Sep 17 00:00:00 2001 From: MaBecker Date: Wed, 1 Apr 2020 22:23:33 +0200 Subject: [PATCH 055/104] widget hand wash timer --- apps.json | 11 +++++++++++ apps/widhwt/ChangeLog | 1 + apps/widhwt/widget.js | 22 ++++++++++++++++++++++ apps/widhwt/widget.png | Bin 0 -> 3574 bytes 4 files changed, 34 insertions(+) create mode 100644 apps/widhwt/ChangeLog create mode 100644 apps/widhwt/widget.js create mode 100644 apps/widhwt/widget.png diff --git a/apps.json b/apps.json index a84a8010c..ce63d3b00 100644 --- a/apps.json +++ b/apps.json @@ -951,5 +951,16 @@ {"name":"chrono.app.js","url":"chrono.js"}, {"name":"chrono.img","url":"chrono-icon.js","evaluate":true} ] + }, + { "id": "widhwt", + "name": "Hand Wash Timer", + "icon": "widget.png", + "version":"0.01", + "description": "Any swip will start your personal Bangle.js hand wash timer for 35 sec. Start washing after the short buzz and stop after the long buzz.", + "tags": "widget,tool", + "type":"widget", + "storage": [ + {"name":"widhwt.wid.js","url":"widget.js"} + ] } ] diff --git a/apps/widhwt/ChangeLog b/apps/widhwt/ChangeLog new file mode 100644 index 000000000..4c21f3ace --- /dev/null +++ b/apps/widhwt/ChangeLog @@ -0,0 +1 @@ +0.01: New Widget! diff --git a/apps/widhwt/widget.js b/apps/widhwt/widget.js new file mode 100644 index 000000000..55ffec028 --- /dev/null +++ b/apps/widhwt/widget.js @@ -0,0 +1,22 @@ +/* jshint esversion: 6 */ +(() => { + var icon = require("heatshrink").decompress(atob("jEYwIKHgwCBhwCBh4CEggPCkACBmAXDBwVZ+EB+F4gEsjl8EgMP+EChk/gEMh+ehkA+YIBxwxBnF/4HggH/wEAj0AA==")); + var color = 0x4A69; + + function draw() { + g.reset().setColor(color).drawImage(icon, this.x + 1, 0); + } + + WIDGETS["widhwt"] = { area: "tr", width: 26, draw: draw }; + + Bangle.on('swipe', function() { + color = 0x41f; + Bangle.buzz(); + Bangle.drawWidgets(); + setTimeout(() => { + color = 0x4A69; + Bangle.buzz(1E3, 1); + Bangle.drawWidgets(); + }, 35E3); + }); +})(); diff --git a/apps/widhwt/widget.png b/apps/widhwt/widget.png new file mode 100644 index 0000000000000000000000000000000000000000..0021c9fa6d81ae457c8082f5944121e39915dfd5 GIT binary patch literal 3574 zcmY*cc|4SD7oM>jSweQ2ETzQQQW#^+Zpd!z>)4l>!DNewvXpfsy9~;jEfOkQmh2;0 zB1%MK$EO`=iG~~Ah z1u2f4fM{baH9*xM-wJsX<7%nnW?%rgM87_ z9}Wco5a$7)`olqx^U2aC2f6!CrYr#dt5`tsmn~U9`7b_c6J-Q4lM}tawiOxxU|>55 zAmC9B7g^29!_*REX`rv*?B^rl=;G((DuMO!Kj{KMu?l49e&ESAal* zgM%f4WhDGiNQjiYygWow8X_$%PG*RsZ~9^!vEsgHp?^gFtE1tHc1C&lV?6wP!6&+o zPJV$HB|*WHL4Vgj=frrp{X5AQ{l^yBAmro=L`p&u@>iSO3O%VR7@|B}$&*j?VN%fF z%>S$XnFEEK4F8|Q{Nwa@m24FTf?b~zho35id20}X z3iZ9raoiPSQ@E}h&BD9^=^{1Rk-BHJ!Fy}pe+{nuhzRYy6O(YRK6i6qEm&zze*MeM z{5>Tk_phRG$0*2U|1;tRKh1L1K!#s_+!KQ?nDN06?XB%T;OxIJ&)F<8E9<(Idznp{ z$H8t>orpPsa1J4)a;}NZgdB~xUW@e`Ww%Fd=3MX+%;xkX z9Fx$zHL{i-eCgLMYic#Eo_&zA*7Y+7XISz?v}iS{GTS}(%wh7R zU;2%0FC+7KnUh^u@~~}audbseY0tEg*E^`hg`)zyT z@eR^xMZGjm$Y_j%kY8k0M^#76(!v32>8fyVPC?PDlrR>f62@>zm3fzZkO zyi(z`0QWBxOl2SjMM z<<-41fB(`W*+9>7+7UaoZ0LeWnExjU_J$R#c+Q-3d(x6EhI1Jl(eZpaOrwC_Z z*?Z%c8gmK1< zUS{Wt>+k#C<9jC6FBYV?v8uHlh{6*`8R9v!A4f~!$AgN$D1!_Vi*OSLgE+b_IkCaj z8*VCYgB6opZ1?#z6Y@R}TOE&*`iWY?HH|M6H1-BC3eglSzUP_Vp2BrY;Nl;sCEN4f zVR*H`be>JhGKdZhvgt95S|Y|?fM0r@pct_nf-K6Pd8f6m*5ig1ve)@xi!Eh4hspQn zxQ4|HggcarY3mIErp1t3ou_0$Njk$T5y`IxtFRWcA(KF*_Qi+oT;{8@8Ow^zU3|pQ z+!zZE&#P5Fx~Kr$#m&ML`+YeauKfbFyG}35Rer{dYH7Su8K)iPfK1%!cQ>idHlTqI z=yptocHi=ZuF!M6Gj-D6Q~`11`SfriY%&7Gm`HqytDx&OEH6Z2nPEl|GmTDDl*E!M z-GY$j1(F|Y-FQ8p{e4}M-$q}*YW3MmXZ&|(>nS1cO~ znpFF}_s4F9%(X7x?+CHmM2U#Ur*MV5#5W!23|oJ=u50L8T0!ALXxtC!uWOx-esCOL zQ45HQa|I7LUJW%XS}eJ;GTs^oyL9%c+quJ#WzxgK5dtK(yyDtiZww;RW=Er@ zu;^wg*o1;G%XgDX;Shj(+|_BZbDQ)?KCIDNxYF-zm;-6^$r{E^PzImHqQA``k`Ogb z1*AX1k6H?H1(tB{gg|fD)z$o>+PXjXotbTX;cYQea;4|Chtl1*!6}sR6kS?kB^{w2 zQ{CWF``M_&0$xm2K&RKk-7TUWaAgSYz;A6sXSd7FJ^wh0xUTvWne@gBClWUVyYn@$ zLaM7nR<42UGMwi?X>hIwv1?s2u8UDejGAsl(FoKJTBRORr#Ho}lFI96ZkuT&u?Q%a zRVYS=risvipD!)%%AO77U5zYd@_s^xZw?=Bgiv`+ym*m){A^}FPfUi8gf7!gDJ|%$=CMQ851eLN24o((8lNuOqA3*2=xMZ*aoWiVRT(3|gB% z0f(LlwQ7WO2gH5wB?kIOTC(cIm|@(^pF^>7wbjbKI(*2khSP5_}0xfJqew%T7q5g8Q|fC-t}%{0IjQ1AckVX*b$0%eA7oPTMI`oZ!2d~IApE?(qi=3 z0N*tt4T)Mbs);g;97DSo9=*;>{+yZ#(7sBMmL911Y3wTD$y=C5R!c%Ul;_K!?#1z; z`7CSI$IZQkZ9(|0-O(`99qF^Sw!@U^874m18F1Wg4{S4LVP`2s=z8 zxiYSNmI#`4yndRsNxnKob9j)C*9qm_6e#+7E)i;}>P)o$Fy7##fqqFvXkULAERK8l z)u?3qkTUVm0ZBQ*Vq&>PA)rmKo<`fcTaqqLyTzBAIdZN=w2-&{vRt5#_4XK1)jby! z!38Avb8Aj{HQ#l6;wHq?`Qra$^vP!sSTgsW9 zuG%_1vKNG|zXc9H$Iz7B;itNDc!Q*BF}zAFm3piF_{iDo^yO?xjsoL_;+)9Da4P?) z!p`}G*W$$SRMv10b+F2INR*t!Yz&-OlBfHwM)z`Be6GICJc9`13@*WTA3sdDy#3t!Kqvsua%b8O0)?#c}|ZS}#Wzc__Z&$qphEiT#4f2oO|bk|3R zz1Zm6wm-CK68)4ckaQ2F;ss;9%~W;v&B9m9ZBvY&oaSAt$PE2YIMPvjaO_s*7N_S^ em%P@8$3TP6a2rl0sQJmykIr?tMwObw?f(D`#ZtTg literal 0 HcmV?d00001 From 2c84fbd3ae808d7206e6926d36df2378a5ecd605 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Thu, 2 Apr 2020 00:12:48 +0200 Subject: [PATCH 056/104] Battery Widget: make color depend on level --- apps.json | 2 +- apps/widbat/ChangeLog | 1 + apps/widbat/widget.js | 13 ++++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps.json b/apps.json index a84a8010c..a022d590b 100644 --- a/apps.json +++ b/apps.json @@ -326,7 +326,7 @@ { "id": "widbat", "name": "Battery Level Widget", "icon": "widget.png", - "version":"0.04", + "version":"0.05", "description": "Show the current battery level and charging status in the top right of the clock", "tags": "widget,battery", "type":"widget", diff --git a/apps/widbat/ChangeLog b/apps/widbat/ChangeLog index cd9993c02..38c3b767e 100644 --- a/apps/widbat/ChangeLog +++ b/apps/widbat/ChangeLog @@ -1,3 +1,4 @@ 0.02: Now refresh battery monitor every minute if LCD on 0.03: Tweaks for variable size widget system 0.04: Ensure redrawing works with variable size widget system +0.05: Change color depending on battery level diff --git a/apps/widbat/widget.js b/apps/widbat/widget.js index 2f1f29802..e1cc8baff 100644 --- a/apps/widbat/widget.js +++ b/apps/widbat/widget.js @@ -1,5 +1,10 @@ (function(){ -var CHARGING = 0x07E0; +const levelColor = (l) => { + if (Bangle.isCharging()) return 0x07E0; // "Green" + if (l >= 50) return 0x05E0; // slightly darker green + if (l >= 15) return 0xFD20; // "Orange" + return 0xF800; // "Red" +} function setWidth() { WIDGETS["bat"].width = 40 + (Bangle.isCharging()?16:0); @@ -7,15 +12,17 @@ function setWidth() { function draw() { var s = 39; var x = this.x, y = this.y; + const l = E.getBattery(), c = levelColor(l); if (Bangle.isCharging()) { - g.setColor(CHARGING).drawImage(atob("DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y); + g.setColor(c).drawImage(atob( + "DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y); x+=16; } g.setColor(-1); g.fillRect(x,y+2,x+s-4,y+21); g.clearRect(x+2,y+4,x+s-6,y+19); g.fillRect(x+s-3,y+10,x+s,y+14); - g.setColor(CHARGING).fillRect(x+4,y+6,x+4+E.getBattery()*(s-12)/100,y+17); + g.setColor(c).fillRect(x+4,y+6,x+4+l*(s-12)/100,y+17); g.setColor(-1); } Bangle.on('charging',function(charging) { From 09fc1f7d3e9bd8652d410c83b27d23e88609caec Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Thu, 2 Apr 2020 00:16:46 +0200 Subject: [PATCH 057/104] Battery Widget: Show battery percentage as text --- apps.json | 2 +- apps/widbat/ChangeLog | 1 + apps/widbat/widget.js | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps.json b/apps.json index a022d590b..032b0b7d7 100644 --- a/apps.json +++ b/apps.json @@ -326,7 +326,7 @@ { "id": "widbat", "name": "Battery Level Widget", "icon": "widget.png", - "version":"0.05", + "version":"0.06", "description": "Show the current battery level and charging status in the top right of the clock", "tags": "widget,battery", "type":"widget", diff --git a/apps/widbat/ChangeLog b/apps/widbat/ChangeLog index 38c3b767e..55464e390 100644 --- a/apps/widbat/ChangeLog +++ b/apps/widbat/ChangeLog @@ -2,3 +2,4 @@ 0.03: Tweaks for variable size widget system 0.04: Ensure redrawing works with variable size widget system 0.05: Change color depending on battery level +0.06: Show battery percentage as text diff --git a/apps/widbat/widget.js b/apps/widbat/widget.js index e1cc8baff..7100dc111 100644 --- a/apps/widbat/widget.js +++ b/apps/widbat/widget.js @@ -24,6 +24,15 @@ function draw() { g.fillRect(x+s-3,y+10,x+s,y+14); g.setColor(c).fillRect(x+4,y+6,x+4+l*(s-12)/100,y+17); g.setColor(-1); + g.setFontAlign(-1,-1); + if (l >= 100) { + g.setFont('4x6', 2); + g.drawString(l, x + 6, y + 7); + } else { + if (l < 10) x+=6; + g.setFont('6x8', 2); + g.drawString(l, x + 6, y + 4); + } } Bangle.on('charging',function(charging) { if(charging) Bangle.buzz(); From 257a8b26626b34db7f874b8ef379849977ec6534 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 2 Apr 2020 08:34:47 +0100 Subject: [PATCH 058/104] Copied widbat changes to new widget --- apps.json | 13 ++++++++- apps/widbat/ChangeLog | 2 -- apps/widbat/widget.js | 22 ++------------- apps/widbatpc/ChangeLog | 5 ++++ apps/widbatpc/widget.js | 59 +++++++++++++++++++++++++++++++++++++++ apps/widbatpc/widget.png | Bin 0 -> 297 bytes 6 files changed, 79 insertions(+), 22 deletions(-) create mode 100644 apps/widbatpc/ChangeLog create mode 100644 apps/widbatpc/widget.js create mode 100644 apps/widbatpc/widget.png diff --git a/apps.json b/apps.json index 8c819298d..019573266 100644 --- a/apps.json +++ b/apps.json @@ -326,7 +326,7 @@ { "id": "widbat", "name": "Battery Level Widget", "icon": "widget.png", - "version":"0.06", + "version":"0.04", "description": "Show the current battery level and charging status in the top right of the clock", "tags": "widget,battery", "type":"widget", @@ -334,6 +334,17 @@ {"name":"widbat.wid.js","url":"widget.js"} ] }, + { "id": "widbatpc", + "name": "Battery Level Widget (with percentage)", + "icon": "widget.png", + "version":"0.06", + "description": "Show the current battery level and charging status in the top right of the clock, with charge percentage", + "tags": "widget,battery", + "type":"widget", + "storage": [ + {"name":"widbatpc.wid.js","url":"widget.js"} + ] + }, { "id": "widbt", "name": "Bluetooth Widget", "icon": "widget.png", diff --git a/apps/widbat/ChangeLog b/apps/widbat/ChangeLog index 55464e390..cd9993c02 100644 --- a/apps/widbat/ChangeLog +++ b/apps/widbat/ChangeLog @@ -1,5 +1,3 @@ 0.02: Now refresh battery monitor every minute if LCD on 0.03: Tweaks for variable size widget system 0.04: Ensure redrawing works with variable size widget system -0.05: Change color depending on battery level -0.06: Show battery percentage as text diff --git a/apps/widbat/widget.js b/apps/widbat/widget.js index 7100dc111..2f1f29802 100644 --- a/apps/widbat/widget.js +++ b/apps/widbat/widget.js @@ -1,10 +1,5 @@ (function(){ -const levelColor = (l) => { - if (Bangle.isCharging()) return 0x07E0; // "Green" - if (l >= 50) return 0x05E0; // slightly darker green - if (l >= 15) return 0xFD20; // "Orange" - return 0xF800; // "Red" -} +var CHARGING = 0x07E0; function setWidth() { WIDGETS["bat"].width = 40 + (Bangle.isCharging()?16:0); @@ -12,27 +7,16 @@ function setWidth() { function draw() { var s = 39; var x = this.x, y = this.y; - const l = E.getBattery(), c = levelColor(l); if (Bangle.isCharging()) { - g.setColor(c).drawImage(atob( - "DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y); + g.setColor(CHARGING).drawImage(atob("DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y); x+=16; } g.setColor(-1); g.fillRect(x,y+2,x+s-4,y+21); g.clearRect(x+2,y+4,x+s-6,y+19); g.fillRect(x+s-3,y+10,x+s,y+14); - g.setColor(c).fillRect(x+4,y+6,x+4+l*(s-12)/100,y+17); + g.setColor(CHARGING).fillRect(x+4,y+6,x+4+E.getBattery()*(s-12)/100,y+17); g.setColor(-1); - g.setFontAlign(-1,-1); - if (l >= 100) { - g.setFont('4x6', 2); - g.drawString(l, x + 6, y + 7); - } else { - if (l < 10) x+=6; - g.setFont('6x8', 2); - g.drawString(l, x + 6, y + 4); - } } Bangle.on('charging',function(charging) { if(charging) Bangle.buzz(); diff --git a/apps/widbatpc/ChangeLog b/apps/widbatpc/ChangeLog new file mode 100644 index 000000000..3988729c3 --- /dev/null +++ b/apps/widbatpc/ChangeLog @@ -0,0 +1,5 @@ +0.02: Now refresh battery monitor every minute if LCD on +0.03: Tweaks for variable size widget system +0.04: Ensure redrawing works with variable size widget system +0.05: Change color depending on battery level, cloned from widbat +0.06: Show battery percentage as text diff --git a/apps/widbatpc/widget.js b/apps/widbatpc/widget.js new file mode 100644 index 000000000..7100dc111 --- /dev/null +++ b/apps/widbatpc/widget.js @@ -0,0 +1,59 @@ +(function(){ +const levelColor = (l) => { + if (Bangle.isCharging()) return 0x07E0; // "Green" + if (l >= 50) return 0x05E0; // slightly darker green + if (l >= 15) return 0xFD20; // "Orange" + return 0xF800; // "Red" +} + +function setWidth() { + WIDGETS["bat"].width = 40 + (Bangle.isCharging()?16:0); +} +function draw() { + var s = 39; + var x = this.x, y = this.y; + const l = E.getBattery(), c = levelColor(l); + if (Bangle.isCharging()) { + g.setColor(c).drawImage(atob( + "DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y); + x+=16; + } + g.setColor(-1); + g.fillRect(x,y+2,x+s-4,y+21); + g.clearRect(x+2,y+4,x+s-6,y+19); + g.fillRect(x+s-3,y+10,x+s,y+14); + g.setColor(c).fillRect(x+4,y+6,x+4+l*(s-12)/100,y+17); + g.setColor(-1); + g.setFontAlign(-1,-1); + if (l >= 100) { + g.setFont('4x6', 2); + g.drawString(l, x + 6, y + 7); + } else { + if (l < 10) x+=6; + g.setFont('6x8', 2); + g.drawString(l, x + 6, y + 4); + } +} +Bangle.on('charging',function(charging) { + if(charging) Bangle.buzz(); + setWidth(); + Bangle.drawWidgets(); // relayout widgets + g.flip(); +}); +var batteryInterval; +Bangle.on('lcdPower', function(on) { + if (on) { + WIDGETS["bat"].draw(); + // refresh once a minute if LCD on + if (!batteryInterval) + batteryInterval = setInterval(draw, 60000); + } else { + if (batteryInterval) { + clearInterval(batteryInterval); + batteryInterval = undefined; + } + } +}); +WIDGETS["bat"]={area:"tr",width:40,draw:draw}; +setWidth(); +})() diff --git a/apps/widbatpc/widget.png b/apps/widbatpc/widget.png new file mode 100644 index 0000000000000000000000000000000000000000..630692e38e3b9ba5fbb62b2bc3a33cd61be04836 GIT binary patch literal 297 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCwj^(N7l!{JxM1({$v}~No-U3d z8I5l*8*&|T5O90A-O*#FR_q#)BTkNvUwGt>Trz%PXw%s%enD+*Q(4(O$7{!;ZftnH z;OBlT>zT*Z6fWiIJ=^fB#+Gq&KYwNU9G>d#i1%lbc&mQzv1$1Hd4@jEzQ$ig(U1P} ztw_>iy0bUgRQAhv#r8w_3THnth|Y_Bu~2P(K-W{of(yL1!oTHzSg}U@{@LL7qVaI@ z+@$_vb^q8z5_}o2;UU)6GFFD!1nXQXDJyW8*}q*=>C>8uX+JZBtJj^_U(L8LQa1YE T%Q{h@PZ>O2{an^LB{Ts5c#wMk literal 0 HcmV?d00001 From 386999803011b2924221c57731639ddc3edebb5b Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 2 Apr 2020 08:39:51 +0100 Subject: [PATCH 059/104] Add ChangeLog --- apps/cliock/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/cliock/ChangeLog diff --git a/apps/cliock/ChangeLog b/apps/cliock/ChangeLog new file mode 100644 index 000000000..081a638f6 --- /dev/null +++ b/apps/cliock/ChangeLog @@ -0,0 +1 @@ +0.07: Submitted to App Loader From f14772f3a9ecf3deee42859810ec891e329dec87 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 2 Apr 2020 08:44:40 +0100 Subject: [PATCH 060/104] `Remove All Apps` now doesn't perform a reset before erase - fixes inability to update firmware if settings are wrong --- CHANGELOG.md | 6 ++++++ js/comms.js | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..5c055c12e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +App Loader ChangeLog +==================== + +Changed for individual apps are listed in `apps/appname/ChangeLog` + +* `Remove All Apps` now doesn't perform a reset before erase - fixes inability to update firmware if settings are wrong diff --git a/js/comms.js b/js/comms.js index 05b94ffde..e2cbf0cdd 100644 --- a/js/comms.js +++ b/js/comms.js @@ -73,13 +73,13 @@ removeApp : app => { // expects an app structure })); }, removeAllApps : () => { - return Comms.reset("wipe").then(() => new Promise((resolve,reject) => { + return new Promise((resolve,reject) => { // Use write with newline here so we wait for it to finish - Puck.write('\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK")\n', (result,err) => { + Puck.write('\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK");reset()\n', (result,err) => { if (!result || result.trim()!="OK") return reject(err || ""); resolve(); }, true /* wait for newline */); - })); + }); }, setTime : () => { return new Promise((resolve,reject) => { From ec1e6bda82dbd3110899054cc316f1bc7533459e Mon Sep 17 00:00:00 2001 From: DerGuteWolf Date: Thu, 2 Apr 2020 10:22:55 +0200 Subject: [PATCH 061/104] Take into account discussion from #167 Using now weekday abbrev, space, short dateformat with full-year removed. This should work for most locales (I hardcoded also replacing a trailing slash esp for en_IL and fr_FR) --- apps/marioclock/marioclock-app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index c0ada5e59..ecbaba38a 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -285,7 +285,10 @@ function drawTime() { function drawDate() { g.setFont("6x8"); g.setColor(LIGHTEST); - const dateStr = locale.date(new Date(), true); + let d = new Date(); + let dateStr = locale.date(d, true); + dateStr = dateStr.replace(d.getFullYear(), "").trim().replace(/\/$/i,""); + dateStr = locale.dow(d, true) + " " + dateStr; g.drawString(dateStr, (W - g.stringWidth(dateStr))/2, 0, true); } From 9d136b2e28b37f68a5961aede5c62da1a0ae8e0a Mon Sep 17 00:00:00 2001 From: DerGuteWolf Date: Thu, 2 Apr 2020 10:25:22 +0200 Subject: [PATCH 062/104] Update ChangeLog --- apps/marioclock/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/marioclock/ChangeLog b/apps/marioclock/ChangeLog index 79f103c48..4334ad92c 100644 --- a/apps/marioclock/ChangeLog +++ b/apps/marioclock/ChangeLog @@ -1,3 +1,4 @@ 0.01: Create mario app 0.02: Fix day of the week and add padding 0.03: use short date format from locale, take timeout from settings +0.04: modify date to display to be more at the original idea but still localized From 291342ea16d4a429ee9b3885e1299f0440dc2da1 Mon Sep 17 00:00:00 2001 From: DerGuteWolf Date: Thu, 2 Apr 2020 10:26:13 +0200 Subject: [PATCH 063/104] marioclock version 0.04 --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 019573266..1c1bf8c5c 100644 --- a/apps.json +++ b/apps.json @@ -892,7 +892,7 @@ { "id": "marioclock", "name": "Mario Clock", "icon": "marioclock.png", - "version":"0.03", + "version":"0.04", "description": "Animated Mario clock, jumps to change the time!", "tags": "clock,mario,retro", "type": "clock", From bdfcea2bf725f7f8344897a6693b080a40a66646 Mon Sep 17 00:00:00 2001 From: MaBecker Date: Thu, 2 Apr 2020 12:04:41 +0200 Subject: [PATCH 064/104] widget hand wash timer --- apps.json | 2 +- apps/widhwt/widget.js | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps.json b/apps.json index ce63d3b00..644258709 100644 --- a/apps.json +++ b/apps.json @@ -956,7 +956,7 @@ "name": "Hand Wash Timer", "icon": "widget.png", "version":"0.01", - "description": "Any swip will start your personal Bangle.js hand wash timer for 35 sec. Start washing after the short buzz and stop after the long buzz.", + "description": "Swipe your wrist over the watch face to start your personal Bangle.js hand wash timer for 35 sec. Start washing after the short buzz and stop after the long buzz.", "tags": "widget,tool", "type":"widget", "storage": [ diff --git a/apps/widhwt/widget.js b/apps/widhwt/widget.js index 55ffec028..a8b15ac9b 100644 --- a/apps/widhwt/widget.js +++ b/apps/widhwt/widget.js @@ -2,6 +2,7 @@ (() => { var icon = require("heatshrink").decompress(atob("jEYwIKHgwCBhwCBh4CEggPCkACBmAXDBwVZ+EB+F4gEsjl8EgMP+EChk/gEMh+ehkA+YIBxwxBnF/4HggH/wEAj0AA==")); var color = 0x4A69; + var isActive = false; function draw() { g.reset().setColor(color).drawImage(icon, this.x + 1, 0); @@ -9,14 +10,18 @@ WIDGETS["widhwt"] = { area: "tr", width: 26, draw: draw }; - Bangle.on('swipe', function() { - color = 0x41f; - Bangle.buzz(); - Bangle.drawWidgets(); - setTimeout(() => { - color = 0x4A69; - Bangle.buzz(1E3, 1); + Bangle.on('twist', function() { + if (!isActive) { + isActive = true; + color = 0x41f; + Bangle.buzz(); Bangle.drawWidgets(); - }, 35E3); + setTimeout(() => { + color = 0x4A69; + Bangle.buzz(1E3, 1); + Bangle.drawWidgets(); + setTimeout(() => { isActive = false; }, 1E10); + }, 35E3); + } }); -})(); +})(); \ No newline at end of file From c42be52076e69eea35318e33787f9a421ee39ffa Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Wed, 1 Apr 2020 21:14:34 +0100 Subject: [PATCH 065/104] Create AstroCalc app. View info on the Sun and Moon from your wrist. --- apps.json | 21 ++ apps/astrocalc/ChangeLog | 1 + apps/astrocalc/astrocalc-app.js | 348 +++++++++++++++++++++++ apps/astrocalc/astrocalc-icon.js | 1 + apps/astrocalc/astrocalc.png | Bin 0 -> 952 bytes apps/astrocalc/first-quarter-icon.json | 6 + apps/astrocalc/full-icon.json | 7 + apps/astrocalc/last-quarter-icon.json | 7 + apps/astrocalc/new-icon.json | 6 + apps/astrocalc/suncalc.js | 328 +++++++++++++++++++++ apps/astrocalc/waning-crescent-icon.json | 7 + apps/astrocalc/waning-gibbous-icon.json | 6 + apps/astrocalc/waxing-crescent-icon.json | 6 + apps/astrocalc/waxing-gibbous-icon.json | 7 + 14 files changed, 751 insertions(+) create mode 100644 apps/astrocalc/ChangeLog create mode 100644 apps/astrocalc/astrocalc-app.js create mode 100644 apps/astrocalc/astrocalc-icon.js create mode 100644 apps/astrocalc/astrocalc.png create mode 100644 apps/astrocalc/first-quarter-icon.json create mode 100644 apps/astrocalc/full-icon.json create mode 100644 apps/astrocalc/last-quarter-icon.json create mode 100644 apps/astrocalc/new-icon.json create mode 100644 apps/astrocalc/suncalc.js create mode 100644 apps/astrocalc/waning-crescent-icon.json create mode 100644 apps/astrocalc/waning-gibbous-icon.json create mode 100644 apps/astrocalc/waxing-crescent-icon.json create mode 100644 apps/astrocalc/waxing-gibbous-icon.json diff --git a/apps.json b/apps.json index a84a8010c..ea334a0b4 100644 --- a/apps.json +++ b/apps.json @@ -951,5 +951,26 @@ {"name":"chrono.app.js","url":"chrono.js"}, {"name":"chrono.img","url":"chrono-icon.js","evaluate":true} ] + }, + { "id": "astrocalc", + "name": "Astrocalc", + "icon": "astrocalc.png", + "version":"0.01", + "description": "Calculates interesting information on the sun and moon cycles for the current day based on your location.", + "tags": "app,sun,moon,cycles,tool,outdoors", + "allow_emulator":true, + "storage": [ + {"name":"astrocalc.app.js","url":"astrocalc-app.js"}, + {"name":"suncalc.js","url":"suncalc.js"}, + {"name":"astrocalc.img","url":"astrocalc-icon.js","evaluate":true}, + {"name":"first-quarter-icon.json","url":"first-quarter-icon.json"}, + {"name":"last-quarter-icon.json","url":"last-quarter-icon.json"}, + {"name":"waning-crescent-icon.json","url":"waning-crescent-icon.json"}, + {"name":"waning-gibbous-icon.json","url":"waning-gibbous-icon.json"}, + {"name":"full-icon.json","url":"full-icon.json"}, + {"name":"new-icon.json","url":"new-icon.json"}, + {"name":"waxing-gibbous-icon.json","url":"waxing-gibbous-icon.json"}, + {"name":"waxing-crescent-icon.json","url":"waxing-crescent-icon.json"} + ] } ] diff --git a/apps/astrocalc/ChangeLog b/apps/astrocalc/ChangeLog new file mode 100644 index 000000000..0c8adeb61 --- /dev/null +++ b/apps/astrocalc/ChangeLog @@ -0,0 +1 @@ +0.01: Create astrocalc app diff --git a/apps/astrocalc/astrocalc-app.js b/apps/astrocalc/astrocalc-app.js new file mode 100644 index 000000000..655544723 --- /dev/null +++ b/apps/astrocalc/astrocalc-app.js @@ -0,0 +1,348 @@ +/** + * Inspired by: https://www.timeanddate.com + */ + +const SunCalc = require("suncalc.js"); + +function drawMoon(phase, x, y) { + const moonImgFiles = [ + "new-icon.json", + "waxing-crescent-icon.json", + "first-quarter-icon.json", + "waxing-gibbous-icon.json", + "full-icon.json", + "waning-gibbous-icon.json", + "last-quarter-icon.json", + "waning-crescent-icon.json" + ]; + + imgObj = require("Storage").readJSON(moonImgFiles[phase]); + imgObj.buffer = require("heatshrink").decompress(atob(imgObj.image)); + g.drawImage(imgObj, x /*- (imgObj.width / 2)*/, y /*- (imgObj.height)*/); +} + +// linear interpolation between two values a and b +// u controls amount of a/b and is in range [0.0,1.0] +function lerp(a,b,u) { + return (1-u) * a + u * b; +} + +function titlizeKey(key) { + return (key[0].toUpperCase() + key.slice(1)).match(/[A-Z][a-z]+/g).join(" "); +} + +function dateToTimeString(date) { + const hrs = ("0" + date.getHours()).substr(-2); + const mins = ("0" + date.getMinutes()).substr(-2); + const secs = ("0" + date.getMinutes()).substr(-2); + + return `${hrs}:${mins}:${secs}`; +} + +function drawTitle(key) { + const fontHeight = 16; + const x = 0; + const x2 = g.getWidth() - 1; + const y = fontHeight + 26; + const y2 = g.getHeight() - 1; + const title = titlizeKey(key); + + g.setFont("6x8", 2); + g.setFontAlign(0,-1); + g.drawString(title,(x+x2)/2,y-fontHeight-2); + g.drawLine(x,y-2,x2,y-2); +} + +/** + * @params {Number} angle Angle of point around a radius + * @params {Number} radius Radius of the point to be drawn, default 2 + * @params {Object} color Color of the point + * @params {Number} color.r Red 0-1 + * @params {Number} color.g Green 0-1 + * @params {Number} color.b Blue 0-1 + */ +function drawPoint(angle, radius, color) { + const pRad = Math.PI / 180; + const faceWidth = 80; // watch face radius + const centerPx = g.getWidth() / 2; + + const a = angle * pRad; + const x = centerPx + Math.sin(a) * faceWidth; + const y = centerPx - Math.cos(a) * faceWidth; + + if (!radius) radius = 2; + + g.setColor(color.r, color.g, color.b); + g.fillCircle(x, y + 20, radius); +} + +function drawPoints() { + const startColor = {r: 140, g: 255, b: 255}; // light blue + const endColor = {r: 0, g: 0, b: 140}; // dark turquoise + + const steps = 60; + const step_u = 1.0 / (steps / 2); + let u = 0.0; + + for (let i = 0; i < steps; i++) { + const colR = lerp(startColor.r, endColor.r, u) / 255; + const colG = lerp(startColor.g, endColor.g, u) / 255; + const colB = lerp(startColor.b, endColor.b, u) / 255; + const col = {r: colR, g: colG, b: colB}; + + if (i >= 0 && i <= 30) { + u += step_u; + } else { + u -= step_u; + } + + drawPoint((360 * i) / steps, 2, col); + } +} + +function drawData(title, obj, startX, startY) { + g.clear(); + drawTitle(title); + + let xPos, yPos; + + if (typeof(startX) === "undefined" || startX === null) { + // Center text + g.setFontAlign(0,-1); + xPos = (0 + g.getWidth() - 2) / 2; + } else { + xPos = startX; + } + + if (typeof(startY) === "undefined") { + yPos = 5; + } else { + yPos = startY; + } + + g.setFont("6x8", 1); + + Object.keys(obj).forEach((key) => { + g.drawString(`${key}: ${obj[key]}`, xPos, yPos += 20); + }); + + g.flip(); +} + +function drawMoonPositionPage(gps, title) { + const pos = SunCalc.getMoonPosition(new Date(), gps.lat, gps.lon); + + const pageData = { + Azimuth: pos.azimuth.toFixed(2), + Altitude: pos.altitude.toFixed(2), + Distance: `${pos.distance.toFixed(0)} km`, + "Parallactic Ang": pos.parallacticAngle.toFixed(2), + }; + const azimuthDegrees = parseInt(pos.azimuth * 180 / Math.PI); + + drawData(title, pageData, null, 80); + drawPoints(); + drawPoint(azimuthDegrees, 8, {r: 1, g: 1, b: 1}); + + let m = setWatch(() => { + let m = moonIndexPageMenu(gps); + }, BTN3, {repeat: false, edge: "falling"}); +} + +function drawMoonIlluminationPage(gps, title) { + const phaseNames = [ + "New Moon", "Waxing Crescent", "First Quarter", "Waxing Gibbous", + "Full Moon", "Waning Gibbous", "Last Quater", "Waning Crescent", + ]; + + const phase = SunCalc.getMoonIllumination(new Date()); + const pageData = { + Phase: phaseNames[phase.phase], + }; + + drawData(title, pageData, null, 35); + drawMoon(phase.phase, g.getWidth() / 2, g.getHeight() / 2); + + let m = setWatch(() => { + let m = moonIndexPageMenu(gps); + }, BTN3, {repease: false, edge: "falling"}); +} + + +function drawMoonTimesPage(gps, title) { + const times = SunCalc.getMoonTimes(new Date(), gps.lat, gps.lon); + + const pageData = { + Rise: dateToTimeString(times.rise), + Set: dateToTimeString(times.set), + }; + + drawData(title, pageData, null, 105); + drawPoints(); + + // Draw the moon rise position + const risePos = SunCalc.getMoonPosition(times.rise, gps.lat, gps.lon); + const riseAzimuthDegrees = parseInt(risePos.azimuth * 180 / Math.PI); + drawPoint(riseAzimuthDegrees, 8, {r: 1, g: 1, b: 1}); + + // Draw the moon set position + const setPos = SunCalc.getMoonPosition(times.set, gps.lat, gps.lon); + const setAzimuthDegrees = parseInt(setPos.azimuth * 180 / Math.PI); + drawPoint(setAzimuthDegrees, 8, {r: 1, g: 1, b: 1}); + + let m = setWatch(() => { + let m = moonIndexPageMenu(gps); + }, BTN3, {repease: false, edge: "falling"}); +} + +function drawSunShowPage(gps, key, date) { + const pos = SunCalc.getPosition(date, gps.lat, gps.lon); + + const hrs = ("0" + date.getHours()).substr(-2); + const mins = ("0" + date.getMinutes()).substr(-2); + const secs = ("0" + date.getMinutes()).substr(-2); + const time = `${hrs}:${mins}:${secs}`; + + const azimuth = Number(pos.azimuth.toFixed(2)); + const azimuthDegrees = parseInt(pos.azimuth * 180 / Math.PI); + const altitude = Number(pos.altitude.toFixed(2)); + + const pageData = { + Time: time, + Altitude: altitude, + Azimumth: azimuth, + Degrees: azimuthDegrees + }; + + drawData(key, pageData, null, 85); + + drawPoints(); + + // Draw the suns position + drawPoint(azimuthDegrees, 8, {r: 1, g: 1, b: 0}); + + m = setWatch(() => { + m = sunIndexPageMenu(gps); + }, BTN3, {repeat: false, edge: "falling"}); + + return null; +} + +function sunIndexPageMenu(gps) { + const sunTimes = SunCalc.getTimes(new Date(), gps.lat, gps.lon); + + const sunMenu = { + "": { + "title": "-- Sun --", + }, + "Current Pos": () => { + m = E.showMenu(); + drawSunShowPage(gps, "Current Pos", new Date()); + }, + }; + + Object.keys(sunTimes).sort().reduce((menu, key) => { + const title = titlizeKey(key); + menu[title] = () => { + m = E.showMenu(); + drawSunShowPage(gps, key, sunTimes[key]); + }; + return menu; + }, sunMenu); + + sunMenu["< Back"] = () => m = indexPageMenu(gps); + + return E.showMenu(sunMenu); +} + + +function moonIndexPageMenu(gps) { + const moonMenu = { + "": { + "title": "-- Moon --", + }, + "Times": () => { + m = E.showMenu(); + drawMoonTimesPage(gps, "Times"); + }, + "Position": () => { + m = E.showMenu(); + drawMoonPositionPage(gps, "Position"); + }, + "Illumination": () => { + m = E.showMenu(); + drawMoonIlluminationPage(gps, "Illumination"); + }, + "< Back": () => m = indexPageMenu(gps), + }; + + return E.showMenu(moonMenu); +} + +function indexPageMenu(gps) { + const menu = { + "": { + "title": "Select", + }, + "Sun": () => { + m = sunIndexPageMenu(gps); + }, + "Moon": () => { + m = moonIndexPageMenu(gps); + }, + "< Exit": () => { load(); } + }; + + return E.showMenu(menu); +} + +/** + * GPS wait page, shows GPS locating animation until it gets a lock, then moves to the Sun page + */ +function drawGPSWaitPage() { + const img = require("heatshrink").decompress(atob("mEwxH+AH4A/AH4AW43GF1wwsFwYwqFwowoFw4wmFxIwdE5YAPF/4vM5nN6YAE5vMF8YtHGIgvhFpQxKF7AuOGA4vXFyAwGF63MFyIABF6xeWMC4UDLwvNGpAJG5gwSdhIIDRBLyWCIgcJHAgJJDoouQF4vMQoICBBJoeGFx6GGACIfHL6YvaX6gvZeCIdFc4gAFXogvGFxgwFDwovQCAguOGAnMMBxeG5guTGAggGGAwNKFySREcA3N5vM5gDBdpQvXEY4AKXqovGGCKbFF7AwPZQwvZGJgtGF7vGdQItG5gSIF7gASF/44WEzgwRF0wwHF1AwFF1QwDF1gvwAH4A/AFAA==")) + + g.clear(); + g.drawImage(img, 100, 50); + g.setFont("6x8", 1); + g.drawString("Astrocalc v0.01", 80, 105); + g.drawString("Locating GPS", 85, 140); + g.drawString("Please wait...", 80, 155); + g.flip(); + + const DEBUG = false; + if (DEBUG) { + const gps = { + "lat": 56.45783133333, + "lon": -3.02188583333, + "alt": 75.3, + "speed": 0.070376, + "course": NaN, + "time":new Date(), + "satellites": 4, + "fix": 1 + }; + + m = indexPageMenu(gps); + + return; + } + + Bangle.on('GPS', (gps) => { + if (gps.fix === 0) return; + + Bangle.setGPSPower(0); + Bangle.buzz(); + Bangle.setLCDPower(true); + + m = indexPageMenu(gps); + }); +} + +function init() { + Bangle.setGPSPower(1); + drawGPSWaitPage(); +} + +let m; +init(); \ No newline at end of file diff --git a/apps/astrocalc/astrocalc-icon.js b/apps/astrocalc/astrocalc-icon.js new file mode 100644 index 000000000..aa04c2805 --- /dev/null +++ b/apps/astrocalc/astrocalc-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4AW43GF1wwsFwYwqFwowoFw4wmFxIwdE5YAPF/4vM5nN6YAE5vMF8YtHGIgvhFpQxKF7AuOGA4vXFyAwGF63MFyIABF6xeWMC4UDLwvNGpAJG5gwSdhIIDRBLyWCIgcJHAgJJDoouQF4vMQoICBBJoeGFx6GGACIfHL6YvaX6gvZeCIdFc4gAFXogvGFxgwFDwovQCAguOGAnMMBxeG5guTGAggGGAwNKFySREcA3N5vM5gDBdpQvXEY4AKXqovGGCKbFF7AwPZQwvZGJgtGF7vGdQItG5gSIF7gASF/44WEzgwRF0wwHF1AwFF1QwDF1gvwAH4A/AFAA==")) \ No newline at end of file diff --git a/apps/astrocalc/astrocalc.png b/apps/astrocalc/astrocalc.png new file mode 100644 index 0000000000000000000000000000000000000000..c26a651ec60072f49fa8969f7c7d8e1479e391f0 GIT binary patch literal 952 zcmV;p14sOcP)zXZD_Mrh6h6{gWm$`>@vk&pxfS3vIN~Mrd$m z$vXvJ{cj$Da7x}e{e>pN3d5)~OCF0CuHqSMisz<%85f`+Ux#rKMg=q>Ux!f<#sp}R zufv!KZ2?XJ$Am*&SW|l3IznR*k3k|Pp37CJR6}uNPC&$hj15^E29gkqHr7{9U}GDK zC0H#%&CGzB5sxRDaS{W8q|6hc}=YXTw`Opd^4`eOZh67c9YEU&}I zrItn`xPXWSkH=x)T3{253_^D&yjut?A`;m7yljFiQ4EM+0>e~R=F_ex0crbu z$+V6L-$g7953+V+qmvrE{S2GC;yu*|Pwqf8dhvGIekg9bMc@~9C`UjU+YBTd-xpT| zsh$K}=@QS2zq|%@+6^YX{hEw~bOe;-<1z0Ed%X|#58+`>Op&=IQRaqDyI2RrJD_qb z6CoW5Pr&3GRrYqn(+AQjV|eoccK@hqJyEQ83R#qu#zV>9T<|;3B-}g#tSM$dv1kq} zfq7{|<-;OxJ>#XjSh@zRDQ27kfNSv_9gC>ay$%3Ye#6&QJ(9Pwa5LpCuO7?hzmh!o zY@)UeYsXloB4Qe$%>JW`Us#jjOwk;u|CJ#*xGU;?ug}{k8Ob+{*6POqlZDnxV zZbBY3PGXOUVhQ#XyToW3?&ri;b|V@Qbz_Rqd%p~8TNffPnrWgTC(hU+o>$?hD%Ql# zX~>YgDiWE_n7Yrqg$4oP=ESQdSXx&{q@6Js%jnztzSj8lFM#0rz}%9^aa+a4HhfwR z+&#E}nj?n&izM#R#qxSf*%-8%6W1J(oNw)m-Ni4dKaagK%>M{HZO+5Yt;Fhi%w6sln8qD; zsJ&_(QhKHgLQ8}}^1_^9_=+%0UYHC4QV}7L4;4;<>3@Inz1IHY<8r~7CEsu<) converted to rad: + return 0.0002967 / Math.tan(h + 0.00312536 / (h + 0.08901179)); +} + +// general sun calculations + +function solarMeanAnomaly(d) { return rad * (357.5291 + 0.98560028 * d); } + +function eclipticLongitude(M) { + + var C = rad * (1.9148 * sin(M) + 0.02 * sin(2 * M) + 0.0003 * sin(3 * M)), // equation of center + P = rad * 102.9372; // perihelion of the Earth + + return M + C + P + PI; +} + +function sunCoords(d) { + + var M = solarMeanAnomaly(d), + L = eclipticLongitude(M); + + return { + dec: declination(L, 0), + ra: rightAscension(L, 0) + }; +} + + +var SunCalc = {}; + + +// calculates sun position for a given date and latitude/longitude + +SunCalc.getPosition = function (date, lat, lng) { + + var lw = rad * -lng, + phi = rad * lat, + d = toDays(date), + + c = sunCoords(d), + H = siderealTime(d, lw) - c.ra; + + return { + azimuth: azimuth(H, phi, c.dec), + altitude: altitude(H, phi, c.dec) + }; +}; + + +// sun times configuration (angle, morning name, evening name) + +var times = SunCalc.times = [ + [-0.833, 'sunrise', 'sunset' ], + [ -0.3, 'sunriseEnd', 'sunsetStart' ], + [ -6, 'dawn', 'dusk' ], + [ -12, 'nauticalDawn', 'nauticalDusk'], + [ -18, 'nightEnd', 'night' ], + [ 6, 'goldenHourEnd', 'goldenHour' ] +]; + +// adds a custom time to the times config + +SunCalc.addTime = function (angle, riseName, setName) { + times.push([angle, riseName, setName]); +}; + + +// calculations for sun times + +var J0 = 0.0009; + +function julianCycle(d, lw) { return Math.round(d - J0 - lw / (2 * PI)); } + +function approxTransit(Ht, lw, n) { return J0 + (Ht + lw) / (2 * PI) + n; } +function solarTransitJ(ds, M, L) { return J2000 + ds + 0.0053 * sin(M) - 0.0069 * sin(2 * L); } + +function hourAngle(h, phi, d) { return acos((sin(h) - sin(phi) * sin(d)) / (cos(phi) * cos(d))); } +function observerAngle(height) { return -2.076 * Math.sqrt(height) / 60; } + +// returns set time for the given sun altitude +function getSetJ(h, lw, phi, dec, n, M, L) { + + var w = hourAngle(h, phi, dec), + a = approxTransit(w, lw, n); + return solarTransitJ(a, M, L); +} + + +// calculates sun times for a given date, latitude/longitude, and, optionally, +// the observer height (in meters) relative to the horizon + +SunCalc.getTimes = function (date, lat, lng, height) { + + height = height || 0; + + var lw = rad * -lng, + phi = rad * lat, + + dh = observerAngle(height), + + d = toDays(date), + n = julianCycle(d, lw), + ds = approxTransit(0, lw, n), + + M = solarMeanAnomaly(ds), + L = eclipticLongitude(M), + dec = declination(L, 0), + + Jnoon = solarTransitJ(ds, M, L), + + i, len, time, h0, Jset, Jrise; + + + var result = { + solarNoon: new Date(fromJulian(Jnoon)), + nadir: new Date(fromJulian(Jnoon - 0.5)) + }; + + for (i = 0, len = times.length; i < len; i += 1) { + time = times[i]; + h0 = (time[0] + dh) * rad; + + Jset = getSetJ(h0, lw, phi, dec, n, M, L); + Jrise = Jnoon - (Jset - Jnoon); + + result[time[1]] = new Date(fromJulian(Jrise) - (dayMs / 2)); + result[time[2]] = new Date(fromJulian(Jset) + (dayMs / 2)); + } + + return result; +}; + + +// moon calculations, based on http://aa.quae.nl/en/reken/hemelpositie.html formulas + +function moonCoords(d) { // geocentric ecliptic coordinates of the moon + + var L = rad * (218.316 + 13.176396 * d), // ecliptic longitude + M = rad * (134.963 + 13.064993 * d), // mean anomaly + F = rad * (93.272 + 13.229350 * d), // mean distance + + l = L + rad * 6.289 * sin(M), // longitude + b = rad * 5.128 * sin(F), // latitude + dt = 385001 - 20905 * cos(M); // distance to the moon in km + + return { + ra: rightAscension(l, b), + dec: declination(l, b), + dist: dt + }; +} + +SunCalc.getMoonPosition = function (date, lat, lng) { + + var lw = rad * -lng, + phi = rad * lat, + d = toDays(date), + + c = moonCoords(d), + H = siderealTime(d, lw) - c.ra, + h = altitude(H, phi, c.dec), + // formula 14.1 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + pa = atan(sin(H), tan(phi) * cos(c.dec) - sin(c.dec) * cos(H)); + + h = h + astroRefraction(h); // altitude correction for refraction + + return { + azimuth: azimuth(H, phi, c.dec), + altitude: h, + distance: c.dist, + parallacticAngle: pa + }; +}; + + +// calculations for illumination parameters of the moon, +// based on http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mphase.pro formulas and +// Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + +// Function updated from gist: https://gist.github.com/endel/dfe6bb2fbe679781948c + +SunCalc.getMoonIllumination = function (date) { + let month = date.getMonth(); + let year = date.getFullYear(); + let day = date.getDate(); + + let c = 0; + let e = 0; + let jd = 0; + let b = 0; + + if (month < 3) { + year--; + month += 12; + } + + ++month; + c = 365.25 * year; + e = 30.6 * month; + jd = c + e + day - 694039.09; // jd is total days elapsed + jd /= 29.5305882; // divide by the moon cycle + b = parseInt(jd); // int(jd) -> b, take integer part of jd + jd -= b; // subtract integer part to leave fractional part of original jd + b = Math.round(jd * 8); // scale fraction from 0-8 and round + + if (b >= 8) b = 0; // 0 and 8 are the same so turn 8 into 0 + + return {phase: b}; +}; + + +function hoursLater(date, h) { + return new Date(date.valueOf() + h * dayMs / 24); +} + +// calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article + +SunCalc.getMoonTimes = function (date, lat, lng, inUTC) { + var t = date; + if (inUTC) t.setUTCHours(0, 0, 0, 0); + else t.setHours(0, 0, 0, 0); + + var hc = 0.133 * rad, + h0 = SunCalc.getMoonPosition(t, lat, lng).altitude - hc, + h1, h2, rise, set, a, b, xe, ye, d, roots, x1, x2, dx; + + // go in 2-hour chunks, each time seeing if a 3-point quadratic curve crosses zero (which means rise or set) + for (var i = 1; i <= 24; i += 2) { + h1 = SunCalc.getMoonPosition(hoursLater(t, i), lat, lng).altitude - hc; + h2 = SunCalc.getMoonPosition(hoursLater(t, i + 1), lat, lng).altitude - hc; + + a = (h0 + h2) / 2 - h1; + b = (h2 - h0) / 2; + xe = -b / (2 * a); + ye = (a * xe + b) * xe + h1; + d = b * b - 4 * a * h1; + roots = 0; + + if (d >= 0) { + dx = Math.sqrt(d) / (Math.abs(a) * 2); + x1 = xe - dx; + x2 = xe + dx; + if (Math.abs(x1) <= 1) roots++; + if (Math.abs(x2) <= 1) roots++; + if (x1 < -1) x1 = x2; + } + + if (roots === 1) { + if (h0 < 0) rise = i + x1; + else set = i + x1; + + } else if (roots === 2) { + rise = i + (ye < 0 ? x2 : x1); + set = i + (ye < 0 ? x1 : x2); + } + + if (rise && set) break; + + h0 = h2; + } + + var result = {}; + + if (rise) result.rise = hoursLater(t, rise); + if (set) result.set = hoursLater(t, set); + + if (!rise && !set) result[ye > 0 ? 'alwaysUp' : 'alwaysDown'] = true; + + return result; +}; + + +// export as Node module / AMD module / browser variable +if (typeof exports === 'object' && typeof module !== 'undefined') module.exports = SunCalc; +else if (typeof define === 'function' && define.amd) define(SunCalc); +else global.SunCalc = SunCalc; + +}()); diff --git a/apps/astrocalc/waning-crescent-icon.json b/apps/astrocalc/waning-crescent-icon.json new file mode 100644 index 000000000..802a79fda --- /dev/null +++ b/apps/astrocalc/waning-crescent-icon.json @@ -0,0 +1,7 @@ + +{ + "width": 92, + "height": 92, + "bpp": 1, + "image": "AH4AI8AKJvgKJj+ABREH/AWJ/4KJn44Jg/+BREB//AEJP8EJP/J5P/J5MfCxMD//wCxF/MxI4BCxP/MxI4BPpA4BCxM/PpI4BPpJPBCxEPCxX/CxJPBShDBBShJPBCxBmBC0BmBCxB9BYRIWBYRAWLBQIWISgIW/C34WTW6wWNfhE/fhMDC0MfCxMBCxR+B/iVK4BnJCxJ+BCxBQBCxJnB8BQJ/wWIKAIWIHIQKIKALDIHIQKIHIKVIHISVIHIIWJOYJ+IYgJ+JEQJnJgZ+JIoJnJEQJQJgJQJRYJQJgEOBRIA/AAIA=" +} \ No newline at end of file diff --git a/apps/astrocalc/waning-gibbous-icon.json b/apps/astrocalc/waning-gibbous-icon.json new file mode 100644 index 000000000..5b7c52c41 --- /dev/null +++ b/apps/astrocalc/waning-gibbous-icon.json @@ -0,0 +1,6 @@ +{ + "width": 92, + "height": 92, + "bpp": 1, + "image": "AGMB/+ABRP+CxH///wBQ9/BYIiHj4KB/gKGg4KB//gG44ACCw0/BQQ5GEIY5GEIn4EJP/4AhJKAwKDKAxlCAAKKFgYWEKAqHCM444ECwwKEM4o4EM4o4FCwpxEM4o4FPwpPFCwkPCxQKFPwhPFSojBECyJmGCwhmFCxasEMwqsEPowWbBQwWDSgwW/C34WOZ1s/CxMDBQv+CxXgBQUBCxUfCyp+GCwaVG/gKDM43APxIWEM4wWEM4v4BQZQGwBQJCwg5GBQhQFVYY5HBQg5FPog5FSgg5GMwhzFPojEGMwgiFMwoiFBQoiEMwoiEJ4xoEJ4qLEHAx0EBQ46CRAoLEEJAAqA=" +} \ No newline at end of file diff --git a/apps/astrocalc/waxing-crescent-icon.json b/apps/astrocalc/waxing-crescent-icon.json new file mode 100644 index 000000000..55d950730 --- /dev/null +++ b/apps/astrocalc/waxing-crescent-icon.json @@ -0,0 +1,6 @@ +{ + "width": 92, + "height": 92, + "bpp": 1, + "image": "AH4ALuAKJgfgBZMfwAKIgP+CxMP+ALJv/ABREHERU//BQJ/4iJj4iJgP/IpMf/5oJ//8M5P/RZP/HJMHHJV/HJIWBHJM/OZJ+BHJIWBKBAWB/4WKKBCVBKBKVBYhAWCKBAWBM5AWZM5DDBPxIWYPxAWBSpIW/C34WLZz78BCxD8C4AWJ/gWV/AWKwAWSgZ9Kn6UJCwJ9JCwJ9Ig5mJgF/MxIWBJ5AWCBRDCBHBDCBJ5IWBHBCUBHBKUBBRAWBHBM/OJKUBYJBmBEJMHEJJmBBRMfEJMBMpMAnwKJg4KJAHw=" +} \ No newline at end of file diff --git a/apps/astrocalc/waxing-gibbous-icon.json b/apps/astrocalc/waxing-gibbous-icon.json new file mode 100644 index 000000000..652710aca --- /dev/null +++ b/apps/astrocalc/waxing-gibbous-icon.json @@ -0,0 +1,7 @@ +{ + "width": 92, + "height": 92, + "bpp": 1, + "transparent": 0, + "image": "AGUf/AKIg//BZP/BZMfBYPgBQ0DBQP/wALGv4KB/wKGh4WCFw4KC//AHBAiHgIWDEQ0/ERJPDEQ5PCAAPwRAwADNAoKE/hmIRY4KEHIpmDHIxmEHIwWFHIhmEOYx9EHIoWGKAgWF/59JKAqUEKAoWGYggWRM4gWGM4arFCwoKFM4gWGPwgWdPwYWGSogW/C34WQZ1vABQUHBQv8Cwd/CyH4CxWACyoKDgaUJgE/MxIWGPoYWGMwkBMxMAj5PJCwwKDVgw4EVgpPECww4EPwo4ESowKEM4o4FPwhxEM4zBDM4whFKAghGM4ghFKAghGKAZlFHIiHFHIosGRQYKIEQIKIAFIA=" +} \ No newline at end of file From eb2450a177b0f9a2f23dd291538cb130cb897063 Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Thu, 2 Apr 2020 12:12:27 +0100 Subject: [PATCH 066/104] Fix moon icon positioning --- apps/astrocalc/astrocalc-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/astrocalc/astrocalc-app.js b/apps/astrocalc/astrocalc-app.js index 655544723..c1a29219d 100644 --- a/apps/astrocalc/astrocalc-app.js +++ b/apps/astrocalc/astrocalc-app.js @@ -18,7 +18,7 @@ function drawMoon(phase, x, y) { imgObj = require("Storage").readJSON(moonImgFiles[phase]); imgObj.buffer = require("heatshrink").decompress(atob(imgObj.image)); - g.drawImage(imgObj, x /*- (imgObj.width / 2)*/, y /*- (imgObj.height)*/); + g.drawImage(imgObj, x - (imgObj.width / 2), y); } // linear interpolation between two values a and b From fe0f189455e2eebf55ded7a890a2be598e1e51dd Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Thu, 2 Apr 2020 12:15:10 +0100 Subject: [PATCH 067/104] Re-add tests to take screen shots of app for PR --- apps/astrocalc/astrocalc-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/astrocalc/astrocalc-app.js b/apps/astrocalc/astrocalc-app.js index c1a29219d..6819a6917 100644 --- a/apps/astrocalc/astrocalc-app.js +++ b/apps/astrocalc/astrocalc-app.js @@ -310,7 +310,7 @@ function drawGPSWaitPage() { g.drawString("Please wait...", 80, 155); g.flip(); - const DEBUG = false; + const DEBUG = true; if (DEBUG) { const gps = { "lat": 56.45783133333, From 538abc003ab8225de53ce22d330175616f60d5e5 Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Thu, 2 Apr 2020 12:23:17 +0100 Subject: [PATCH 068/104] Revert test mode --- apps/astrocalc/astrocalc-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/astrocalc/astrocalc-app.js b/apps/astrocalc/astrocalc-app.js index 6819a6917..c1a29219d 100644 --- a/apps/astrocalc/astrocalc-app.js +++ b/apps/astrocalc/astrocalc-app.js @@ -310,7 +310,7 @@ function drawGPSWaitPage() { g.drawString("Please wait...", 80, 155); g.flip(); - const DEBUG = true; + const DEBUG = false; if (DEBUG) { const gps = { "lat": 56.45783133333, From ae5f8e8f086ce7d64552742c3f2daaf3d4c0a1fd Mon Sep 17 00:00:00 2001 From: MaBecker Date: Thu, 2 Apr 2020 13:41:28 +0200 Subject: [PATCH 069/104] widget hand wash timer --- apps/widhwt/widget.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/widhwt/widget.js b/apps/widhwt/widget.js index a8b15ac9b..3fff48800 100644 --- a/apps/widhwt/widget.js +++ b/apps/widhwt/widget.js @@ -2,7 +2,6 @@ (() => { var icon = require("heatshrink").decompress(atob("jEYwIKHgwCBhwCBh4CEggPCkACBmAXDBwVZ+EB+F4gEsjl8EgMP+EChk/gEMh+ehkA+YIBxwxBnF/4HggH/wEAj0AA==")); var color = 0x4A69; - var isActive = false; function draw() { g.reset().setColor(color).drawImage(icon, this.x + 1, 0); @@ -10,18 +9,15 @@ WIDGETS["widhwt"] = { area: "tr", width: 26, draw: draw }; - Bangle.on('twist', function() { - if (!isActive) { - isActive = true; - color = 0x41f; - Bangle.buzz(); + Bangle.on('swipe', function() { + color = 0x41f; + Bangle.buzz(); + Bangle.drawWidgets(); + setTimeout(() => { + color = 0x4A69; + Bangle.buzz(1E3, 1); Bangle.drawWidgets(); - setTimeout(() => { - color = 0x4A69; - Bangle.buzz(1E3, 1); - Bangle.drawWidgets(); - setTimeout(() => { isActive = false; }, 1E10); - }, 35E3); - } + }, 35E3); + }); })(); \ No newline at end of file From bcece63915b9c45c4f16bcb7e6c97eb7c38ce8c9 Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Thu, 2 Apr 2020 13:45:27 +0100 Subject: [PATCH 070/104] Load images in an efficient manner --- apps.json | 16 ++++++++-------- apps/astrocalc/astrocalc-app.js | 22 +++++++++++----------- apps/astrocalc/first-quarter-icon.js | 1 + apps/astrocalc/first-quarter-icon.json | 6 ------ apps/astrocalc/full-icon.js | 1 + apps/astrocalc/full-icon.json | 7 ------- apps/astrocalc/last-quarter-icon.js | 1 + apps/astrocalc/last-quarter-icon.json | 7 ------- apps/astrocalc/new-icon.js | 1 + apps/astrocalc/new-icon.json | 6 ------ apps/astrocalc/waning-crescent-icon.js | 1 + apps/astrocalc/waning-crescent-icon.json | 7 ------- apps/astrocalc/waning-gibbous-icon.js | 1 + apps/astrocalc/waning-gibbous-icon.json | 6 ------ apps/astrocalc/waxing-crescent-icon.js | 1 + apps/astrocalc/waxing-crescent-icon.json | 6 ------ apps/astrocalc/waxing-gibbous-icon.js | 1 + apps/astrocalc/waxing-gibbous-icon.json | 7 ------- 18 files changed, 27 insertions(+), 71 deletions(-) create mode 100644 apps/astrocalc/first-quarter-icon.js delete mode 100644 apps/astrocalc/first-quarter-icon.json create mode 100644 apps/astrocalc/full-icon.js delete mode 100644 apps/astrocalc/full-icon.json create mode 100644 apps/astrocalc/last-quarter-icon.js delete mode 100644 apps/astrocalc/last-quarter-icon.json create mode 100644 apps/astrocalc/new-icon.js delete mode 100644 apps/astrocalc/new-icon.json create mode 100644 apps/astrocalc/waning-crescent-icon.js delete mode 100644 apps/astrocalc/waning-crescent-icon.json create mode 100644 apps/astrocalc/waning-gibbous-icon.js delete mode 100644 apps/astrocalc/waning-gibbous-icon.json create mode 100644 apps/astrocalc/waxing-crescent-icon.js delete mode 100644 apps/astrocalc/waxing-crescent-icon.json create mode 100644 apps/astrocalc/waxing-gibbous-icon.js delete mode 100644 apps/astrocalc/waxing-gibbous-icon.json diff --git a/apps.json b/apps.json index ea334a0b4..90d50ccaa 100644 --- a/apps.json +++ b/apps.json @@ -963,14 +963,14 @@ {"name":"astrocalc.app.js","url":"astrocalc-app.js"}, {"name":"suncalc.js","url":"suncalc.js"}, {"name":"astrocalc.img","url":"astrocalc-icon.js","evaluate":true}, - {"name":"first-quarter-icon.json","url":"first-quarter-icon.json"}, - {"name":"last-quarter-icon.json","url":"last-quarter-icon.json"}, - {"name":"waning-crescent-icon.json","url":"waning-crescent-icon.json"}, - {"name":"waning-gibbous-icon.json","url":"waning-gibbous-icon.json"}, - {"name":"full-icon.json","url":"full-icon.json"}, - {"name":"new-icon.json","url":"new-icon.json"}, - {"name":"waxing-gibbous-icon.json","url":"waxing-gibbous-icon.json"}, - {"name":"waxing-crescent-icon.json","url":"waxing-crescent-icon.json"} + {"name":"first-quarter.img","url":"first-quarter-icon.js","evaluate":true}, + {"name":"last-quarter.img","url":"last-quarter-icon.js","evaluate":true}, + {"name":"waning-crescent.img","url":"waning-crescent-icon.js","evaluate":true}, + {"name":"waning-gibbous.img","url":"waning-gibbous-icon.js","evaluate":true}, + {"name":"full.img","url":"full-icon.js","evaluate":true}, + {"name":"new.img","url":"new-icon.js","evaluate":true}, + {"name":"waxing-gibbous.img","url":"waxing-gibbous-icon.js","evaluate":true}, + {"name":"waxing-crescent.img","url":"waxing-crescent-icon.js","evaluate":true} ] } ] diff --git a/apps/astrocalc/astrocalc-app.js b/apps/astrocalc/astrocalc-app.js index c1a29219d..318147b13 100644 --- a/apps/astrocalc/astrocalc-app.js +++ b/apps/astrocalc/astrocalc-app.js @@ -6,19 +6,19 @@ const SunCalc = require("suncalc.js"); function drawMoon(phase, x, y) { const moonImgFiles = [ - "new-icon.json", - "waxing-crescent-icon.json", - "first-quarter-icon.json", - "waxing-gibbous-icon.json", - "full-icon.json", - "waning-gibbous-icon.json", - "last-quarter-icon.json", - "waning-crescent-icon.json" + "new", + "waxing-crescent", + "first-quarter", + "waxing-gibbous", + "full", + "waning-gibbous", + "last-quarter", + "waning-crescent", ]; - imgObj = require("Storage").readJSON(moonImgFiles[phase]); - imgObj.buffer = require("heatshrink").decompress(atob(imgObj.image)); - g.drawImage(imgObj, x - (imgObj.width / 2), y); + img = require("Storage").read(`${moonImgFiles[phase]}.img`); + // image width & height = 92px + g.drawImage(img, x - parseInt(92 / 2), y); } // linear interpolation between two values a and b diff --git a/apps/astrocalc/first-quarter-icon.js b/apps/astrocalc/first-quarter-icon.js new file mode 100644 index 000000000..e726c5d37 --- /dev/null +++ b/apps/astrocalc/first-quarter-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AGUD/ALJn4LJgf/+AWJ//gCxP/wAWJ/wWKHRAWB//ACxIiICwQiHCwQiICwQiHCwZ0HCwRoHCwf8CxSLGCwY5HCwY5GCwY5HCwY5GCwhzGCwY5GCwhQGCwf/CxRQGCwhQFCwjEGCx5nGCwhnFCyBnFCwh+GCzZ+FCwiVGC34W/CxzOt4AWJ/gWV/AWKwAWVBQoWESgoWEMwwWEPooWEMwwWEMwoWEJ4wWEBQoWEHAwWDJ4wWEHAwWDHAwWEBQwWDHAwWDOIwWEYIoWEEI4WCEI4WDEI4WCEI4WCMo4WCQ44WDBRAWBG44WCBRIAo")); \ No newline at end of file diff --git a/apps/astrocalc/first-quarter-icon.json b/apps/astrocalc/first-quarter-icon.json deleted file mode 100644 index b0018a433..000000000 --- a/apps/astrocalc/first-quarter-icon.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "width": 92, - "height": 92, - "bpp": 1, - "image": "AGUD/ALJn4LJgf/+AWJ//gCxP/wAWJ/wWKHRAWB//ACxIiICwQiHCwQiICwQiHCwZ0HCwRoHCwf8CxSLGCwY5HCwY5GCwY5HCwY5GCwhzGCwY5GCwhQGCwf/CxRQGCwhQFCwjEGCx5nGCwhnFCyBnFCwh+GCzZ+FCwiVGC34W/CxzOt4AWJ/gWV/AWKwAWVBQoWESgoWEMwwWEPooWEMwwWEMwoWEJ4wWEBQoWEHAwWDJ4wWEHAwWDHAwWEBQwWDHAwWDOIwWEYIoWEEI4WCEI4WDEI4WCEI4WCMo4WCQ44WDBRAWBG44WCBRIAo" -} \ No newline at end of file diff --git a/apps/astrocalc/full-icon.js b/apps/astrocalc/full-icon.js new file mode 100644 index 000000000..11aaadbbb --- /dev/null +++ b/apps/astrocalc/full-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AH4AfgP//AKJBZIKB//wBQ0/BYXABQsPBQX/BQsDBQf8BYt/BYfgBQkfBQf/wAhIEQwhEEQpDEIopwCAAZ0EMoZoGg4KF/yHGAAaLDLQpcEHAw5EHAw5DHAw5EOIpzEOIxzEBQ5QCJ45QCJ45QDJ45QCYIrEFCxRmHM4ZmHM4QWWPpB+CBRB+BC34W/CxLOtgYKH/gWBn4LH4AWMj4LHwEAgIKH/AWBPxAKBPxB9BM5BmCM5BmBKBBPCKBBPBKBBPCKBAKCHI44CHI44DHI44COY5xCOY5xDYg7BBAARcFLQYiGEIoiFEIhFFIYhoFMoiLGBQx0DOAgLFBRAA/AC4A==")); \ No newline at end of file diff --git a/apps/astrocalc/full-icon.json b/apps/astrocalc/full-icon.json deleted file mode 100644 index 2dc5c59aa..000000000 --- a/apps/astrocalc/full-icon.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "width": 92, - "height": 92, - "bpp": 1, - "transparent": 0, - "image": "AH4AfgP//AKJBZIKB//wBQ0/BYXABQsPBQX/BQsDBQf8BYt/BYfgBQkfBQf/wAhIEQwhEEQpDEIopwCAAZ0EMoZoGg4KF/yHGAAaLDLQpcEHAw5EHAw5DHAw5EOIpzEOIxzEBQ5QCJ45QCJ45QDJ45QCYIrEFCxRmHM4ZmHM4QWWPpB+CBRB+BC34W/CxLOtgYKH/gWBn4LH4AWMj4LHwEAgIKH/AWBPxAKBPxB9BM5BmCM5BmBKBBPCKBBPBKBBPCKBAKCHI44CHI44DHI44COY5xCOY5xDYg7BBAARcFLQYiGEIoiFEIhFFIYhoFMoiLGBQx0DOAgLFBRAA/AC4A==" -} \ No newline at end of file diff --git a/apps/astrocalc/last-quarter-icon.js b/apps/astrocalc/last-quarter-icon.js new file mode 100644 index 000000000..1de62e58a --- /dev/null +++ b/apps/astrocalc/last-quarter-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AGMB/gKJ//ABZH/CxN/CxMfCxMH/4WIG4IWJn4WJEIQWHEIQWIEIQWHEIQWIBQQWHMoIWIgYWKQ4IWIHAYWHBQQWHHAYWGHAYWHOIQWHHAYWHJ4YWGh4WKBQYWGJ4YWGYIYWSMwgWGMwYWSMwYWGPogWdBQYWGSggW/C34WQZ1s/CxMDCysBCxUfCyp+ECwqVECwxnECwx+DCwxnECwxnDCwxQECwxQDCww5ECwxQDCw45DCww5DCw45DCww5DCw5zDCw7ECCw4iDCw4iCCxAiCCw4iCCxBoCCxCLBCxB0CCxA6BCxILBCxIApA=")); \ No newline at end of file diff --git a/apps/astrocalc/last-quarter-icon.json b/apps/astrocalc/last-quarter-icon.json deleted file mode 100644 index 31e855eac..000000000 --- a/apps/astrocalc/last-quarter-icon.json +++ /dev/null @@ -1,7 +0,0 @@ - -{ - "width": 92, - "height": 92, - "bpp": 1, - "image": "AGMB/gKJ//ABZH/CxN/CxMfCxMH/4WIG4IWJn4WJEIQWHEIQWIEIQWHEIQWIBQQWHMoIWIgYWKQ4IWIHAYWHBQQWHHAYWGHAYWHOIQWHHAYWHJ4YWGh4WKBQYWGJ4YWGYIYWSMwgWGMwYWSMwYWGPogWdBQYWGSggW/C34WQZ1s/CxMDCysBCxUfCyp+ECwqVECwxnECwx+DCwxnECwxnDCwxQECwxQDCww5ECwxQDCw45DCww5DCw45DCww5DCw5zDCw7ECCw4iDCw4iCCxAiCCw4iCCxBoCCxCLBCxB0CCxA6BCxILBCxIApA=" -} \ No newline at end of file diff --git a/apps/astrocalc/new-icon.js b/apps/astrocalc/new-icon.js new file mode 100644 index 000000000..91f7034e7 --- /dev/null +++ b/apps/astrocalc/new-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AAcP///BRQLHg4KC/wKFgIKC//4BYt/BYfgBQkfBQf/wAsHFw4HCBwXwBQc/AwYLB4AhEIARIBEQn//gECgYiEIYJ2FIoQQBE4YzBDgd/NoguBNAUPKoo/BB4YhEEQIdCAYYiECQMHUwwHDEIweBLgMPWIwiBAQSlENwQTBDIQAFFQMDHAw5BOYN/HAwfB8ANCAAofCHA45B+EPHA4UBKQQAGMgMfUYQAFv+DJ45QCn5PHKAPDJ45QB/hmICwPnT4yhC/1/Mw5nBCxZmIM4P/PpB+BC34WEVZCsB/7CIYYIWWOX4WbfiwWL/gKHgf+n/ABY8/4YWJ/k/VhF/4LDIg/4j5nI/+APxEP+EPM48BCgN/KA5CBg5QHMwINCJ4/AgY5Hh4fBj45GHAKeBAQSfFMgIZCHAoqCv45GA4QOBEQsfDwQDDEIgSC/4iFv6dCg4iFj60Dn4iEEIKRCL4K5E/5uDh4QDDgKFEv4uDj4/EE4IRCDYIzEAwIvBAQKnFEQIADMIhFBAAayFNAIACMoZtDBYa9GFwbrHBQR2EBYoKEA=")); \ No newline at end of file diff --git a/apps/astrocalc/new-icon.json b/apps/astrocalc/new-icon.json deleted file mode 100644 index 368c7b376..000000000 --- a/apps/astrocalc/new-icon.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "width": 92, - "height": 92, - "bpp": 1, - "image": "AAcP///BRQLHg4KC/wKFgIKC//4BYt/BYfgBQkfBQf/wAsHFw4HCBwXwBQc/AwYLB4AhEIARIBEQn//gECgYiEIYJ2FIoQQBE4YzBDgd/NoguBNAUPKoo/BB4YhEEQIdCAYYiECQMHUwwHDEIweBLgMPWIwiBAQSlENwQTBDIQAFFQMDHAw5BOYN/HAwfB8ANCAAofCHA45B+EPHA4UBKQQAGMgMfUYQAFv+DJ45QCn5PHKAPDJ45QB/hmICwPnT4yhC/1/Mw5nBCxZmIM4P/PpB+BC34WEVZCsB/7CIYYIWWOX4WbfiwWL/gKHgf+n/ABY8/4YWJ/k/VhF/4LDIg/4j5nI/+APxEP+EPM48BCgN/KA5CBg5QHMwINCJ4/AgY5Hh4fBj45GHAKeBAQSfFMgIZCHAoqCv45GA4QOBEQsfDwQDDEIgSC/4iFv6dCg4iFj60Dn4iEEIKRCL4K5E/5uDh4QDDgKFEv4uDj4/EE4IRCDYIzEAwIvBAQKnFEQIADMIhFBAAayFNAIACMoZtDBYa9GFwbrHBQR2EBYoKEA=" -} \ No newline at end of file diff --git a/apps/astrocalc/waning-crescent-icon.js b/apps/astrocalc/waning-crescent-icon.js new file mode 100644 index 000000000..e142dc47b --- /dev/null +++ b/apps/astrocalc/waning-crescent-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AH4AI8AKJvgKJj+ABREH/AWJ/4KJn44Jg/+BREB//AEJP8EJP/J5P/J5MfCxMD//wCxF/MxI4BCxP/MxI4BPpA4BCxM/PpI4BPpJPBCxEPCxX/CxJPBShDBBShJPBCxBmBC0BmBCxB9BYRIWBYRAWLBQIWISgIW/C34WTW6wWNfhE/fhMDC0MfCxMBCxR+B/iVK4BnJCxJ+BCxBQBCxJnB8BQJ/wWIKAIWIHIQKIKALDIHIQKIHIKVIHISVIHIIWJOYJ+IYgJ+JEQJnJgZ+JIoJnJEQJQJgJQJRYJQJgEOBRIA/AAIA=")); \ No newline at end of file diff --git a/apps/astrocalc/waning-crescent-icon.json b/apps/astrocalc/waning-crescent-icon.json deleted file mode 100644 index 802a79fda..000000000 --- a/apps/astrocalc/waning-crescent-icon.json +++ /dev/null @@ -1,7 +0,0 @@ - -{ - "width": 92, - "height": 92, - "bpp": 1, - "image": "AH4AI8AKJvgKJj+ABREH/AWJ/4KJn44Jg/+BREB//AEJP8EJP/J5P/J5MfCxMD//wCxF/MxI4BCxP/MxI4BPpA4BCxM/PpI4BPpJPBCxEPCxX/CxJPBShDBBShJPBCxBmBC0BmBCxB9BYRIWBYRAWLBQIWISgIW/C34WTW6wWNfhE/fhMDC0MfCxMBCxR+B/iVK4BnJCxJ+BCxBQBCxJnB8BQJ/wWIKAIWIHIQKIKALDIHIQKIHIKVIHISVIHIIWJOYJ+IYgJ+JEQJnJgZ+JIoJnJEQJQJgJQJRYJQJgEOBRIA/AAIA=" -} \ No newline at end of file diff --git a/apps/astrocalc/waning-gibbous-icon.js b/apps/astrocalc/waning-gibbous-icon.js new file mode 100644 index 000000000..0939d0454 --- /dev/null +++ b/apps/astrocalc/waning-gibbous-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AGMB/+ABRP+CxH///wBQ9/BYIiHj4KB/gKGg4KB//gG44ACCw0/BQQ5GEIY5GEIn4EJP/4AhJKAwKDKAxlCAAKKFgYWEKAqHCM444ECwwKEM4o4EM4o4FCwpxEM4o4FPwpPFCwkPCxQKFPwhPFSojBECyJmGCwhmFCxasEMwqsEPowWbBQwWDSgwW/C34WOZ1s/CxMDBQv+CxXgBQUBCxUfCyp+GCwaVG/gKDM43APxIWEM4wWEM4v4BQZQGwBQJCwg5GBQhQFVYY5HBQg5FPog5FSgg5GMwhzFPojEGMwgiFMwoiFBQoiEMwoiEJ4xoEJ4qLEHAx0EBQ46CRAoLEEJAAqA=")); \ No newline at end of file diff --git a/apps/astrocalc/waning-gibbous-icon.json b/apps/astrocalc/waning-gibbous-icon.json deleted file mode 100644 index 5b7c52c41..000000000 --- a/apps/astrocalc/waning-gibbous-icon.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "width": 92, - "height": 92, - "bpp": 1, - "image": "AGMB/+ABRP+CxH///wBQ9/BYIiHj4KB/gKGg4KB//gG44ACCw0/BQQ5GEIY5GEIn4EJP/4AhJKAwKDKAxlCAAKKFgYWEKAqHCM444ECwwKEM4o4EM4o4FCwpxEM4o4FPwpPFCwkPCxQKFPwhPFSojBECyJmGCwhmFCxasEMwqsEPowWbBQwWDSgwW/C34WOZ1s/CxMDBQv+CxXgBQUBCxUfCyp+GCwaVG/gKDM43APxIWEM4wWEM4v4BQZQGwBQJCwg5GBQhQFVYY5HBQg5FPog5FSgg5GMwhzFPojEGMwgiFMwoiFBQoiEMwoiEJ4xoEJ4qLEHAx0EBQ46CRAoLEEJAAqA=" -} \ No newline at end of file diff --git a/apps/astrocalc/waxing-crescent-icon.js b/apps/astrocalc/waxing-crescent-icon.js new file mode 100644 index 000000000..0756408c6 --- /dev/null +++ b/apps/astrocalc/waxing-crescent-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AH4ALuAKJgfgBZMfwAKIgP+CxMP+ALJv/ABREHERU//BQJ/4iJj4iJgP/IpMf/5oJ//8M5P/RZP/HJMHHJV/HJIWBHJM/OZJ+BHJIWBKBAWB/4WKKBCVBKBKVBYhAWCKBAWBM5AWZM5DDBPxIWYPxAWBSpIW/C34WLZz78BCxD8C4AWJ/gWV/AWKwAWSgZ9Kn6UJCwJ9JCwJ9Ig5mJgF/MxIWBJ5AWCBRDCBHBDCBJ5IWBHBCUBHBKUBBRAWBHBM/OJKUBYJBmBEJMHEJJmBBRMfEJMBMpMAnwKJg4KJAHw=")); \ No newline at end of file diff --git a/apps/astrocalc/waxing-crescent-icon.json b/apps/astrocalc/waxing-crescent-icon.json deleted file mode 100644 index 55d950730..000000000 --- a/apps/astrocalc/waxing-crescent-icon.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "width": 92, - "height": 92, - "bpp": 1, - "image": "AH4ALuAKJgfgBZMfwAKIgP+CxMP+ALJv/ABREHERU//BQJ/4iJj4iJgP/IpMf/5oJ//8M5P/RZP/HJMHHJV/HJIWBHJM/OZJ+BHJIWBKBAWB/4WKKBCVBKBKVBYhAWCKBAWBM5AWZM5DDBPxIWYPxAWBSpIW/C34WLZz78BCxD8C4AWJ/gWV/AWKwAWSgZ9Kn6UJCwJ9JCwJ9Ig5mJgF/MxIWBJ5AWCBRDCBHBDCBJ5IWBHBCUBHBKUBBRAWBHBM/OJKUBYJBmBEJMHEJJmBBRMfEJMBMpMAnwKJg4KJAHw=" -} \ No newline at end of file diff --git a/apps/astrocalc/waxing-gibbous-icon.js b/apps/astrocalc/waxing-gibbous-icon.js new file mode 100644 index 000000000..2f6a665e2 --- /dev/null +++ b/apps/astrocalc/waxing-gibbous-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("AGUf/AKIg//BZP/BZMfBYPgBQ0DBQP/wALGv4KB/wKGh4WCFw4KC//AHBAiHgIWDEQ0/ERJPDEQ5PCAAPwRAwADNAoKE/hmIRY4KEHIpmDHIxmEHIwWFHIhmEOYx9EHIoWGKAgWF/59JKAqUEKAoWGYggWRM4gWGM4arFCwoKFM4gWGPwgWdPwYWGSogW/C34WQZ1vABQUHBQv8Cwd/CyH4CxWACyoKDgaUJgE/MxIWGPoYWGMwkBMxMAj5PJCwwKDVgw4EVgpPECww4EPwo4ESowKEM4o4FPwhxEM4zBDM4whFKAghGM4ghFKAghGKAZlFHIiHFHIosGRQYKIEQIKIAFIA=")); \ No newline at end of file diff --git a/apps/astrocalc/waxing-gibbous-icon.json b/apps/astrocalc/waxing-gibbous-icon.json deleted file mode 100644 index 652710aca..000000000 --- a/apps/astrocalc/waxing-gibbous-icon.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "width": 92, - "height": 92, - "bpp": 1, - "transparent": 0, - "image": "AGUf/AKIg//BZP/BZMfBYPgBQ0DBQP/wALGv4KB/wKGh4WCFw4KC//AHBAiHgIWDEQ0/ERJPDEQ5PCAAPwRAwADNAoKE/hmIRY4KEHIpmDHIxmEHIwWFHIhmEOYx9EHIoWGKAgWF/59JKAqUEKAoWGYggWRM4gWGM4arFCwoKFM4gWGPwgWdPwYWGSogW/C34WQZ1vABQUHBQv8Cwd/CyH4CxWACyoKDgaUJgE/MxIWGPoYWGMwkBMxMAj5PJCwwKDVgw4EVgpPECww4EPwo4ESowKEM4o4FPwhxEM4zBDM4whFKAghGM4ghFKAghGKAZlFHIiHFHIosGRQYKIEQIKIAFIA=" -} \ No newline at end of file From 9727f68447f500ffdc9613ce0955b03690fa86dc Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Thu, 2 Apr 2020 14:00:28 +0100 Subject: [PATCH 071/104] Update image to be compressed as image string --- apps/astrocalc/first-quarter-icon.js | 2 +- apps/astrocalc/full-icon.js | 2 +- apps/astrocalc/last-quarter-icon.js | 2 +- apps/astrocalc/new-icon.js | 2 +- apps/astrocalc/waning-crescent-icon.js | 2 +- apps/astrocalc/waning-gibbous-icon.js | 2 +- apps/astrocalc/waxing-crescent-icon.js | 2 +- apps/astrocalc/waxing-gibbous-icon.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/astrocalc/first-quarter-icon.js b/apps/astrocalc/first-quarter-icon.js index e726c5d37..d88ec79b5 100644 --- a/apps/astrocalc/first-quarter-icon.js +++ b/apps/astrocalc/first-quarter-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AGUD/ALJn4LJgf/+AWJ//gCxP/wAWJ/wWKHRAWB//ACxIiICwQiHCwQiICwQiHCwZ0HCwRoHCwf8CxSLGCwY5HCwY5GCwY5HCwY5GCwhzGCwY5GCwhQGCwf/CxRQGCwhQFCwjEGCx5nGCwhnFCyBnFCwh+GCzZ+FCwiVGC34W/CxzOt4AWJ/gWV/AWKwAWVBQoWESgoWEMwwWEPooWEMwwWEMwoWEJ4wWEBQoWEHAwWDJ4wWEHAwWDHAwWEBQwWDHAwWDOIwWEYIoWEEI4WCEI4WDEI4WCEI4WCMo4WCQ44WDBRAWBG44WCBRIAo")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgI1ygf4BZM/BZMD//wCxP/8AWJ/+ACxP+CxQ6ICwP/4AWJERAWCEQ4WCERAWCEQ4WDOg4WCNA4WD/gWKRYwWDHI4WDHIwWDHI4WDHIwWEOYwWDHIwWEKAwWD/4WKKAwWEKAoWEYgwWPM4wWEM4oWQM4oWEPwwWbPwoWESowW/C34WOZ1vACxP8Cyv4CxWACyoKFCwiUFCwhmGCwh9FCwhmGCwhmFCwhPGCwgKFCwg4GCwZPGCwg4GCwY4GCwgKGCwY4GCwZxGCwjBFCwghHCwQhHCwYhHCwQhHCwRlHCwSHHCwYKICwI3HCwQKJAFAA==")) \ No newline at end of file diff --git a/apps/astrocalc/full-icon.js b/apps/astrocalc/full-icon.js index 11aaadbbb..8bc04f7fc 100644 --- a/apps/astrocalc/full-icon.js +++ b/apps/astrocalc/full-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AH4AfgP//AKJBZIKB//wBQ0/BYXABQsPBQX/BQsDBQf8BYt/BYfgBQkfBQf/wAhIEQwhEEQpDEIopwCAAZ0EMoZoGg4KF/yHGAAaLDLQpcEHAw5EHAw5DHAw5EOIpzEOIxzEBQ5QCJ45QCJ45QDJ45QCYIrEFCxRmHM4ZmHM4QWWPpB+CBRB+BC34W/CxLOtgYKH/gWBn4LH4AWMj4LHwEAgIKH/AWBPxAKBPxB9BM5BmCM5BmBKBBPCKBBPBKBBPCKBAKCHI44CHI44DHI44COY5xCOY5xDYg7BBAARcFLQYiGEIoiFEIhFFIYhoFMoiLGBQx0DOAgLFBRAA/AC4A==")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgJC/AD8B//4BRILJBQP/+AKGn4LC4AKFh4KC/4KFgYKD/gLFv4LD8AKEj4KD/+AEJAiGEIgiFIYhFFOAQADOghlDNA0HBQv+Q4wADRYZaFLgg4GHIg4GHIY4GHIhxFOYhxGOYgKHKARPHKARPHKAZPHKATBFYgoWKMw5nDMw5nCCyx9IPwQKIPwIW/C34WJZ1sDBQ/8CwM/BY/ACxkfBY+AgEBBQ/4CwJ+IBQJ+IPoJnIMwRnIMwJQIJ4RQIJ4JQIJ4RQIBQQ5HHAQ5HHAY5HHARzHOIRzHOIbEHYIIACLgpaDEQwhFEQohEIopDENAplERYwKGOgZwEBYoKIAH4AXA==")) \ No newline at end of file diff --git a/apps/astrocalc/last-quarter-icon.js b/apps/astrocalc/last-quarter-icon.js index 1de62e58a..b6517f66b 100644 --- a/apps/astrocalc/last-quarter-icon.js +++ b/apps/astrocalc/last-quarter-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AGMB/gKJ//ABZH/CxN/CxMfCxMH/4WIG4IWJn4WJEIQWHEIQWIEIQWHEIQWIBQQWHMoIWIgYWKQ4IWIHAYWHBQQWHHAYWGHAYWHOIQWHHAYWHJ4YWGh4WKBQYWGJ4YWGYIYWSMwgWGMwYWSMwYWGPogWdBQYWGSggW/C34WQZ1s/CxMDCysBCxUfCyp+ECwqVECwxnECwx+DCwxnECwxnDCwxQECwxQDCww5ECwxQDCw45DCww5DCw45DCww5DCw5zDCw7ECCw4iDCw4iCCxAiCCw4iCCxBoCCxCLBCxB0CCxA6BCxILBCxIApA=")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgI0xgP8BRP/4ALI/4WJv4WJj4WJg//CxA3BCxM/CxIhCCw4hCCxAhCCw4hCCxAKCCw5lBCxEDCxSHBCxA4DCw4KCCw44DCww4DCw5xCCw44DCw5PDCw0PCxQKDCwxPDCwzBDCyRmECwxmDCyRmDCwx9ECzoKDCwyUEC34W/CyDOtn4WJgYWVgIWKj4WVPwgWFSogWGM4gWGPwYWGM4gWGM4YWGKAgWGKAYWGHIgWGKAYWHHIYWGHIYWHHIYWGHIYWHOYYWHYgQWHEQYWHEQQWIEQQWHEQQWINAQWIRYIWIOgQWIHQIWJBYIWJAFI=")) \ No newline at end of file diff --git a/apps/astrocalc/new-icon.js b/apps/astrocalc/new-icon.js index 91f7034e7..5d610fbe1 100644 --- a/apps/astrocalc/new-icon.js +++ b/apps/astrocalc/new-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AAcP///BRQLHg4KC/wKFgIKC//4BYt/BYfgBQkfBQf/wAsHFw4HCBwXwBQc/AwYLB4AhEIARIBEQn//gECgYiEIYJ2FIoQQBE4YzBDgd/NoguBNAUPKoo/BB4YhEEQIdCAYYiECQMHUwwHDEIweBLgMPWIwiBAQSlENwQTBDIQAFFQMDHAw5BOYN/HAwfB8ANCAAofCHA45B+EPHA4UBKQQAGMgMfUYQAFv+DJ45QCn5PHKAPDJ45QB/hmICwPnT4yhC/1/Mw5nBCxZmIM4P/PpB+BC34WEVZCsB/7CIYYIWWOX4WbfiwWL/gKHgf+n/ABY8/4YWJ/k/VhF/4LDIg/4j5nI/+APxEP+EPM48BCgN/KA5CBg5QHMwINCJ4/AgY5Hh4fBj45GHAKeBAQSfFMgIZCHAoqCv45GA4QOBEQsfDwQDDEIgSC/4iFv6dCg4iFj60Dn4iEEIKRCL4K5E/5uDh4QDDgKFEv4uDj4/EE4IRCDYIzEAwIvBAQKnFEQIADMIhFBAAayFNAIACMoZtDBYa9GFwbrHBQR2EBYoKEA=")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgIGDh///4RHBQQLHg4KC/wKFgIKC//4BYt/BYfgBQkfBQf/wAsHFw4HCBwXwBQc/AwYLB4AhEIARIBEQn//gECgYiEIYJ2FIoQQBE4YzBDgd/NoguBNAUPKoo/BB4YhEEQIdCAYYiECQMHUwwHDEIweBLgMPWIwiBAQSlENwQTBDIQAFFQMDHAw5BOYN/HAwfB8ANCAAofCHA45B+EPHA4UBKQQAGMgMfUYQAFv+DJ45QCn5PHKAPDJ45QB/hmICwPnT4yhC/1/Mw5nBCxZmIM4P/PpB+BC34WEVZCsB/7CIYYIWWOX4WbfiwWL/gKHgf+n/ABY8/4YWJ/k/VhF/4LDIg/4j5nI/+APxEP+EPM48BCgN/KA5CBg5QHMwINCJ4/AgY5Hh4fBj45GHAKeBAQSfFMgIZCHAoqCv45GA4QOBEQsfDwQDDEIgSC/4iFv6dCg4iFj60Dn4iEEIKRCL4K5E/5uDh4QDDgKFEv4uDj4/EE4IRCDYIzEAwIvBAQKnFEQIADMIhFBAAayFNAIACMoZtDBYa9GFwbrHBQR2EBYoKEA==")) \ No newline at end of file diff --git a/apps/astrocalc/waning-crescent-icon.js b/apps/astrocalc/waning-crescent-icon.js index e142dc47b..8ff83ab1f 100644 --- a/apps/astrocalc/waning-crescent-icon.js +++ b/apps/astrocalc/waning-crescent-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AH4AI8AKJvgKJj+ABREH/AWJ/4KJn44Jg/+BREB//AEJP8EJP/J5P/J5MfCxMD//wCxF/MxI4BCxP/MxI4BPpA4BCxM/PpI4BPpJPBCxEPCxX/CxJPBShDBBShJPBCxBmBC0BmBCxB9BYRIWBYRAWLBQIWISgIW/C34WTW6wWNfhE/fhMDC0MfCxMBCxR+B/iVK4BnJCxJ+BCxBQBCxJnB8BQJ/wWIKAIWIHIQKIKALDIHIQKIHIKVIHISVIHIIWJOYJ+IYgJ+JEQJnJgZ+JIoJnJEQJQJgJQJRYJQJgEOBRIA/AAIA=")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgJC/ABHgBRN8BRMfwAKIg/4CxP/BRM/HBMH/wKIgP/4AhJ/ghJ/5PJ/5PJj4WJgf/+AWIv5mJHAIWJ/5mJHAJ9IHAIWJn59JHAJ9JJ4IWIh4WK/4WJJ4KUIYIKUJJ4IWIMwIWgMwIWIPoLCJCwLCICxYKBCxCUBC34W/Cya3WCxr8In78JgYWhj4WJgIWKPwP8SpXAM5IWJPwIWIKAIWJM4PgKBP+CxBQBCxA5CBRBQBYZA5CBRA5BSpA5CSpA5BCxJzBPxDEBPxIiBM5MDPxJFBM5IiBKBMBKBKLBKBMAhwKJAH4ABA=")) \ No newline at end of file diff --git a/apps/astrocalc/waning-gibbous-icon.js b/apps/astrocalc/waning-gibbous-icon.js index 0939d0454..2373475f4 100644 --- a/apps/astrocalc/waning-gibbous-icon.js +++ b/apps/astrocalc/waning-gibbous-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AGMB/+ABRP+CxH///wBQ9/BYIiHj4KB/gKGg4KB//gG44ACCw0/BQQ5GEIY5GEIn4EJP/4AhJKAwKDKAxlCAAKKFgYWEKAqHCM444ECwwKEM4o4EM4o4FCwpxEM4o4FPwpPFCwkPCxQKFPwhPFSojBECyJmGCwhmFCxasEMwqsEPowWbBQwWDSgwW/C34WOZ1s/CxMDBQv+CxXgBQUBCxUfCyp+GCwaVG/gKDM43APxIWEM4wWEM4v4BQZQGwBQJCwg5GBQhQFVYY5HBQg5FPog5FSgg5GMwhzFPojEGMwgiFMwoiFBQoiEMwoiEJ4xoEJ4qLEHAx0EBQ46CRAoLEEJAAqA=")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgI0xgP/wAKJ/wWI///+AKHv4LBEQ8fBQP8BQ0HBQP/8A3HAAQWGn4KCHIwhDHIwhE/AhJ//AEJJQGBQZQGMoQABRQsDCwhQFQ4RnHHAgWGBQhnFHAhnFHAoWFOIhnFHAp+FJ4oWEh4WKBQp+EJ4qVEYIgWRMwwWEMwoWLVghmFVgh9GCzYKGCwaUGC34W/CxzOtn4WJgYKF/wWK8AKCgIWKj4WVPwwWDSo38BQZnG4B+JCwhnGCwhnF/AKDKA2AKBIWEHIwKEKAqrDHI4KEHIp9EHIqUEHIxmEOYp9EYgxmEEQpmFEQoKFEQhmFEQhPGNAhPFRYg4GOggKHHQSIFBYghIAFQ=")) \ No newline at end of file diff --git a/apps/astrocalc/waxing-crescent-icon.js b/apps/astrocalc/waxing-crescent-icon.js index 0756408c6..d89525c88 100644 --- a/apps/astrocalc/waxing-crescent-icon.js +++ b/apps/astrocalc/waxing-crescent-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AH4ALuAKJgfgBZMfwAKIgP+CxMP+ALJv/ABREHERU//BQJ/4iJj4iJgP/IpMf/5oJ//8M5P/RZP/HJMHHJV/HJIWBHJM/OZJ+BHJIWBKBAWB/4WKKBCVBKBKVBYhAWCKBAWBM5AWZM5DDBPxIWYPxAWBSpIW/C34WLZz78BCxD8C4AWJ/gWV/AWKwAWSgZ9Kn6UJCwJ9JCwJ9Ig5mJgF/MxIWBJ5AWCBRDCBHBDCBJ5IWBHBCUBHBKUBBRAWBHBM/OJKUBYJBmBEJMHEJJmBBRMfEJMBMpMAnwKJg4KJAHw=")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgJC/ABdwBRMD8ALJj+ABREB/wWJh/wBZN/4AKIg4iKn/4KBP/ERMfERMB/5FJj//NBP//hnJ/6LJ/45Jg45Kv45JCwI5Jn5zJPwI5JCwJQICwP/CxRQISoJQJSoLEICwRQICwJnICzJnIYYJ+JCzB+ICwKVJC34W/CxbOffgIWIfgXACxP8Cyv4CxWACyUDPpU/ShIWBPpIWBPpEHMxMAv5mJCwJPICwQKIYQI4IYQJPJCwI4ISgI4JSgIKICwI4Jn5xJSgLBIMwIhJg4hJMwIKJj4hJgJlJgE+BRMHBRIA+A")) \ No newline at end of file diff --git a/apps/astrocalc/waxing-gibbous-icon.js b/apps/astrocalc/waxing-gibbous-icon.js index 2f6a665e2..90ccd6f37 100644 --- a/apps/astrocalc/waxing-gibbous-icon.js +++ b/apps/astrocalc/waxing-gibbous-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("AGUf/AKIg//BZP/BZMfBYPgBQ0DBQP/wALGv4KB/wKGh4WCFw4KC//AHBAiHgIWDEQ0/ERJPDEQ5PCAAPwRAwADNAoKE/hmIRY4KEHIpmDHIxmEHIwWFHIhmEOYx9EHIoWGKAgWF/59JKAqUEKAoWGYggWRM4gWGM4arFCwoKFM4gWGPwgWdPwYWGSogW/C34WQZ1vABQUHBQv8Cwd/CyH4CxWACyoKDgaUJgE/MxIWGPoYWGMwkBMxMAj5PJCwwKDVgw4EVgpPECww4EPwo4ESowKEM4o4FPwhxEM4zBDM4whFKAghGM4ghFKAghGKAZlFHIiHFHIosGRQYKIEQIKIAFIA=")); \ No newline at end of file +require("heatshrink").decompress(atob("rlcgI1yj/4BREH/4LJ/4LJj4LB8AKGgYKB/+ABY1/BQP+BQ0PCwQuHBQX/4A4IEQ8BCwYiGn4iJJ4YiHJ4QAB+CIGAAZoFBQn8MxCLHBQg5FMwY5GMwg5GCwo5EMwhzGPog5FCwxQECwv/PpJQFSghQFCwzEECyJnECwxnDVYoWFBQpnECwx+ECzp+DCwyVEC34W/CyDOt4AKCg4KF/gWDv4WQ/AWKwAWVBQcDShMAn5mJCwx9DCwxmEgJmJgEfJ5IWGBQasGHAisFJ4gWGHAh+FHAiVGBQhnFHAp+EOIhnGYIZnGEIpQEEIxnEEIpQEEIxQDMoo5EQ4o5FFgyKDBRAiBBRAApA=")) \ No newline at end of file From 3cb109f487d048ae3913608e462b9ebcf71a7689 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 2 Apr 2020 14:16:54 +0100 Subject: [PATCH 072/104] 0.05: Inline locale details - faster, less memory overhead Add correct scaling for speed/distance/temperature --- apps.json | 2 +- apps/locale/ChangeLog | 2 + apps/locale/locale.html | 126 +++++++++++++++++++++++++++++----------- apps/locale/locales.js | 26 +++++++-- 4 files changed, 117 insertions(+), 39 deletions(-) diff --git a/apps.json b/apps.json index 019573266..f4aee1a8b 100644 --- a/apps.json +++ b/apps.json @@ -65,7 +65,7 @@ { "id": "locale", "name": "Languages", "icon": "locale.png", - "version":"0.04", + "version":"0.05", "description": "Translations for different countries", "tags": "tool,system,locale,translate", "type": "locale", diff --git a/apps/locale/ChangeLog b/apps/locale/ChangeLog index fb461edcc..d46bbaea0 100644 --- a/apps/locale/ChangeLog +++ b/apps/locale/ChangeLog @@ -2,3 +2,5 @@ 0.02: Fix locale.currencySym 0.03: Fix global 'locale' variable 0.04: Add function meridian +0.05: Inline locale details - faster, less memory overhead + Add correct scaling for speed/distance/temperature diff --git a/apps/locale/locale.html b/apps/locale/locale.html index de3500934..5d7882e00 100644 --- a/apps/locale/locale.html +++ b/apps/locale/locale.html @@ -15,6 +15,45 @@ + diff --git a/js/comms.js b/js/comms.js index e2cbf0cdd..91ae54b68 100644 --- a/js/comms.js +++ b/js/comms.js @@ -9,14 +9,19 @@ reset : (opt) => new Promise((resolve,reject) => { }); }), uploadApp : (app,skipReset) => { + Progress.show({title:`Uploading ${app.name}`,sticky:true}); return AppInfo.getFiles(app, httpGet).then(fileContents => { return new Promise((resolve,reject) => { console.log("uploadApp",fileContents.map(f=>f.name).join(", ")); + var maxBytes = fileContents.reduce((b,f)=>b+f.content.length, 0)||1; + var currentBytes = 0; + // Upload each file one at a time function doUploadFiles() { // No files left - print 'reboot' message if (fileContents.length==0) { Puck.write(`\x10E.showMessage('Hold BTN3\\nto reload')\n`,(result) => { + Progress.hide({sticky:true}); if (result===null) return reject(""); resolve(app); }); @@ -24,17 +29,27 @@ uploadApp : (app,skipReset) => { } var f = fileContents.shift(); console.log(`Upload ${f.name} => ${JSON.stringify(f.content)}`); + Progress.show({ + min:currentBytes / maxBytes, + max:(currentBytes+f.content.length) / maxBytes}); + currentBytes += f.content.length; // Chould check CRC here if needed instead of returning 'OK'... // E.CRC32(require("Storage").read(${JSON.stringify(app.name)})) Puck.write(`\x10${f.cmd};Bluetooth.println("OK")\n`,(result) => { - if (!result || result.trim()!="OK") return reject("Unexpected response "+(result||"")); + if (!result || result.trim()!="OK") { + Progress.hide({sticky:true}); + return reject("Unexpected response "+(result||"")); + } doUploadFiles(); }, true); // wait for a newline } // Start the upload function doUpload() { Puck.write(`\x10E.showMessage('Uploading\\n${app.id}...')\n`,(result) => { - if (result===null) return reject(""); + if (result===null) { + Progress.hide({sticky:true}); + return reject(""); + } doUploadFiles(); }); } @@ -48,10 +63,15 @@ uploadApp : (app,skipReset) => { }); }, getInstalledApps : () => { + Progress.show({title:`Getting app list...`,sticky:true}); return new Promise((resolve,reject) => { Puck.write("\x03",(result) => { - if (result===null) return reject(""); + if (result===null) { + Progress.hide({sticky:true}); + return reject(""); + } Puck.eval('require("Storage").list(/\.info$/).map(f=>{var j=require("Storage").readJSON(f,1)||{};j.id=f.slice(0,-5);return j})', (appList,err) => { + Progress.hide({sticky:true}); if (appList===null) return reject(err || ""); console.log("getInstalledApps", appList); resolve(appList); @@ -60,6 +80,7 @@ getInstalledApps : () => { }); }, removeApp : app => { // expects an app structure + Progress.show({title:`Removing ${app.name}`,sticky:true}); var storage = [{name:app.id+".info"}].concat(app.storage); var cmds = storage.map(file=>{ return `\x10require("Storage").erase(${toJS(file.name)});\n`; @@ -67,15 +88,21 @@ removeApp : app => { // expects an app structure console.log("removeApp", cmds); return Comms.reset().then(new Promise((resolve,reject) => { Puck.write(`\x03\x10E.showMessage('Erasing\\n${app.id}...')${cmds}\x10E.showMessage('Hold BTN3\\nto reload')\n`,(result) => { + Progress.hide({sticky:true}); if (result===null) return reject(""); resolve(); }); - })); + })).catch(function(reason) { + Progress.hide({sticky:true}); + return Promise.reject(reason); + }); }, removeAllApps : () => { + Progress.show({title:"Removing all apps",progess:"animate",sticky:true}); return new Promise((resolve,reject) => { // Use write with newline here so we wait for it to finish Puck.write('\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK");reset()\n', (result,err) => { + Progress.hide({sticky:true}); if (!result || result.trim()!="OK") return reject(err || ""); resolve(); }, true /* wait for newline */); @@ -171,10 +198,10 @@ readStorageFile : (filename) => { // StorageFiles are different to normal storag fileContent = fileContent.substr(newLineIdx+1); } } else { - showProgress(undefined,100*fileContent.length / (fileSize||1000000)); + Progress.show({percent:100*fileContent.length / (fileSize||1000000)}); } if (finished) { - hideProgress(); + Progress.hide(); connection.received = ""; connection.cb = undefined; resolve(fileContent); @@ -188,7 +215,7 @@ readStorageFile : (filename) => { // StorageFiles are different to normal storag while (l!==undefined) { Bluetooth.print(l); l = f.readLine(); } Bluetooth.print("\xFF"); })()\n`,() => { - showProgress(`Reading ${JSON.stringify(filename)}`,0); + Progress.show({title:`Reading ${JSON.stringify(filename)}`,percent:0}); console.log(`StorageFile read started...`); }); }); diff --git a/js/index.js b/js/index.js index b21fc907d..60b66436a 100644 --- a/js/index.js +++ b/js/index.js @@ -14,119 +14,7 @@ httpGet("apps.json").then(apps=>{ refreshFilter(); }); -// Status // =========================================== Top Navigation -function showToast(message, type) { - // toast-primary, toast-success, toast-warning or toast-error - var style = "toast-primary"; - if (type=="success") style = "toast-success"; - else if (type=="error") style = "toast-error"; - else if (type!==undefined) console.log("showToast: unknown toast "+type); - var toastcontainer = document.getElementById("toastcontainer"); - var msgDiv = htmlElement(`
`); - msgDiv.innerHTML = message; - toastcontainer.append(msgDiv); - setTimeout(function() { - msgDiv.remove(); - }, 5000); -} -var progressToast; // the DOM element -var progressSticky; // showProgress(,,"sticky") don't remove until hideProgress("sticky") -var progressInterval; // the interval used if showProgress(..., "animate") -var progressPercent; // the current progress percentage -function showProgress(text, percent, sticky) { - if (sticky=="sticky") - progressSticky = true; - if (!progressToast) { - if (progressInterval) { - clearInterval(progressInterval); - progressInterval = undefined; - } - if (percent == "animate") { - progressInterval = setInterval(function() { - progressPercent += 2; - if (progressPercent>100) progressPercent=0; - showProgress(undefined, progressPercent); - }, 100); - percent = 0; - } - progressPercent = percent; - - var toastcontainer = document.getElementById("toastcontainer"); - progressToast = htmlElement(`
- ${text ? `
${text}
`:``} -
-
-
-
`); - toastcontainer.append(progressToast); - } else { - var pt=document.getElementById("progressToast"); - pt.setAttribute("aria-valuenow",percent); - pt.style.width = percent+"%"; - } -} -function hideProgress(sticky) { - if (progressSticky && sticky!="sticky") - return; - progressSticky = false; - if (progressInterval) { - clearInterval(progressInterval); - progressInterval = undefined; - } - if (progressToast) progressToast.remove(); - progressToast = undefined; -} - -Puck.writeProgress = function(charsSent, charsTotal) { - if (charsSent===undefined) { - hideProgress(); - return; - } - var percent = Math.round(charsSent*100/charsTotal); - showProgress(undefined, percent); -} -function showPrompt(title, text, buttons) { - if (!buttons) buttons={yes:1,no:1}; - return new Promise((resolve,reject) => { - var modal = htmlElement(``); - document.body.append(modal); - modal.querySelector("a[href='#close']").addEventListener("click",event => { - event.preventDefault(); - reject("User cancelled"); - modal.remove(); - }); - htmlToArray(modal.getElementsByTagName("button")).forEach(button => { - button.addEventListener("click",event => { - event.preventDefault(); - var isYes = event.target.getAttribute("isyes")=="1"; - if (isYes) resolve(); - else reject("User cancelled"); - modal.remove(); - }); - }); - }); -} function showChangeLog(appid) { var app = appNameToApp(appid); function show(contents) { @@ -170,12 +58,11 @@ function handleCustomApp(appTemplate) { Object.keys(appFiles).forEach(k => app[k] = appFiles[k]); console.log("Received custom app", app); modal.remove(); - showProgress(`Uploading ${app.name}`,undefined,"sticky"); Comms.uploadApp(app).then(()=>{ - hideProgress("sticky"); + Progress.hide({sticky:true}); resolve(); }).catch(e => { - hideProgress("sticky"); + Progress.hide({sticky:true}); reject(e); }); }, false); @@ -334,9 +221,8 @@ function refreshLibrary() { // upload icon.classList.remove("icon-upload"); icon.classList.add("loading"); - showProgress(`Uploading ${app.name}`,undefined,"sticky"); Comms.uploadApp(app).then((appJSON) => { - hideProgress("sticky"); + Progress.hide({sticky:true}); if (appJSON) appsInstalled.push(appJSON); showToast(app.name+" Uploaded!", "success"); icon.classList.remove("loading"); @@ -344,7 +230,7 @@ function refreshLibrary() { refreshMyApps(); refreshLibrary(); }).catch(err => { - hideProgress("sticky"); + Progress.hide({sticky:true}); showToast("Upload failed, "+err, "error"); icon.classList.remove("loading"); icon.classList.add("icon-upload"); @@ -403,19 +289,16 @@ function customApp(app) { function updateApp(app) { if (app.custom) return customApp(app); - showProgress(`Upgrading ${app.name}`,undefined,"sticky"); return Comms.removeApp(app).then(()=>{ showToast(app.name+" removed successfully. Updating...",); appsInstalled = appsInstalled.filter(a=>a.id!=app.id); return Comms.uploadApp(app); }).then((appJSON) => { - hideProgress("sticky"); if (appJSON) appsInstalled.push(appJSON); showToast(app.name+" Updated!", "success"); refreshMyApps(); refreshLibrary(); }, err=>{ - hideProgress("sticky"); showToast(app.name+" update failed, "+err,"error"); refreshMyApps(); refreshLibrary(); @@ -488,18 +371,15 @@ return `
function getInstalledApps() { showLoadingIndicator("myappscontainer"); - showProgress(`Getting app list...`,undefined,"sticky"); // Get apps and files return Comms.getInstalledApps() .then(appJSON => { - hideProgress("sticky"); appsInstalled = appJSON; refreshMyApps(); refreshLibrary(); }) .then(() => handleConnectionChange(true)) .catch(err=>{ - hideProgress("sticky"); return Promise.reject(); }); } @@ -555,15 +435,14 @@ document.getElementById("settime").addEventListener("click",event=>{ }); document.getElementById("removeall").addEventListener("click",event=>{ showPrompt("Remove All","Really remove all apps?").then(() => { - showProgress("Removing all apps","animate", "sticky"); return Comms.removeAllApps(); }).then(()=>{ - hideProgress("sticky"); + Progress.hide({sticky:true}); appsInstalled = []; showToast("All apps removed","success"); return getInstalledApps(); }).catch(err=>{ - hideProgress("sticky"); + Progress.hide({sticky:true}); showToast("App removal failed, "+err,"error"); }); }); @@ -578,24 +457,23 @@ document.getElementById("installdefault").addEventListener("click",event=>{ appCount = defaultApps.length; return showPrompt("Install Defaults","Remove everything and install default apps?"); }).then(() => { - showProgress("Removing all apps","animate", "sticky"); return Comms.removeAllApps(); }).then(()=>{ - hideProgress("sticky"); + Progress.hide({sticky:true}); appsInstalled = []; showToast(`Existing apps removed. Installing ${appCount} apps...`); return new Promise((resolve,reject) => { function upload() { var app = defaultApps.shift(); if (app===undefined) return resolve(); - showProgress(`${app.name} (${appCount-defaultApps.length}/${appCount})`,undefined,"sticky"); + Progress.show({title:`${app.name} (${appCount-defaultApps.length}/${appCount})`,sticky:true}); Comms.uploadApp(app,"skip_reset").then((appJSON) => { - hideProgress("sticky"); + Progress.hide({sticky:true}); if (appJSON) appsInstalled.push(appJSON); showToast(`(${appCount-defaultApps.length}/${appCount}) ${app.name} Uploaded`); upload(); }).catch(function() { - hideProgress("sticky"); + Progress.hide({sticky:true}); reject() }); } @@ -607,7 +485,7 @@ document.getElementById("installdefault").addEventListener("click",event=>{ showToast("Default apps successfully installed!","success"); return getInstalledApps(); }).catch(err=>{ - hideProgress("sticky"); + Progress.hide({sticky:true}); showToast("App Install failed, "+err,"error"); }); }); diff --git a/js/ui.js b/js/ui.js new file mode 100644 index 000000000..c88091872 --- /dev/null +++ b/js/ui.js @@ -0,0 +1,140 @@ +// General UI tools (progress bar, toast, prompt) + +/// Handle progress bars +var Progress = { + domElement : null, // the DOM element + sticky : false, // Progress.show({..., sticky:true}) don't remove until Progress.hide({sticky:true}) + interval : undefined, // the interval used if Progress.show({progress:"animate"}) + percent : undefined, // the current progress percentage + min : 0, // scaling for percentage + max : 1, // scaling for percentage + + /* Show a Progress message + Progress.show({ + sticky : bool // keep showing text even when Progress.hide is called (unless Progress.hide({sticky:true})) + percent : number | "animate" + min : // minimum scale for percentage (default 0) + max : // maximum scale for percentage (default 1) + }) */ + show : function(options) { + options = options||{}; + var text = options.title; + if (options.sticky) Progress.sticky = true; + if (options.min!==undefined) Progress.min = options.min; + if (options.max!==undefined) Progress.max = options.max; + var percent = options.percent; + if (percent!==undefined) + percent = Progress.min*100 + (Progress.max-Progress.min)*percent; + if (!Progress.domElement) { + if (Progress.interval) { + clearInterval(Progress.interval); + Progress.interval = undefined; + } + if (percent == "animate") { + Progress.interval = setInterval(function() { + Progress.percent += 2; + if (Progress.percent>100) Progress.percent=0; + Progress.show({percent:Progress.percent}); + }, 100); + percent = 0; + } + + var toastcontainer = document.getElementById("toastcontainer"); + Progress.domElement = htmlElement(`
+ ${text ? `
${text}
`:``} +
+
+
+
`); + toastcontainer.append(Progress.domElement); + } else { + var pt=document.getElementById("Progress.domElement"); + pt.setAttribute("aria-valuenow",percent); + pt.style.width = percent+"%"; + } + }, + // Progress.hide({sticky:true}) undoes Progress.show({title:"title", sticky:true}) + hide : function(options) { + options = options||{}; + if (Progress.sticky && !options.sticky) + return; + Progress.sticky = false; + Progress.min = 0; + Progress.max = 1; + if (Progress.interval) { + clearInterval(Progress.interval); + Progress.interval = undefined; + } + if (Progress.domElement) Progress.domElement.remove(); + Progress.domElement = undefined; + } +}; + +/// Add progress handler so we get nice uploads +Puck.writeProgress = function(charsSent, charsTotal) { + if (charsSent===undefined) { + Progress.hide(); + return; + } + var percent = Math.round(charsSent*100/charsTotal); + Progress.show({percent: percent}); +} + +/// Show a 'toast' message for status +function showToast(message, type) { + // toast-primary, toast-success, toast-warning or toast-error + var style = "toast-primary"; + if (type=="success") style = "toast-success"; + else if (type=="error") style = "toast-error"; + else if (type!==undefined) console.log("showToast: unknown toast "+type); + var toastcontainer = document.getElementById("toastcontainer"); + var msgDiv = htmlElement(`
`); + msgDiv.innerHTML = message; + toastcontainer.append(msgDiv); + setTimeout(function() { + msgDiv.remove(); + }, 5000); +} + +/// Show a yes/no prompt +function showPrompt(title, text, buttons) { + if (!buttons) buttons={yes:1,no:1}; + return new Promise((resolve,reject) => { + var modal = htmlElement(``); + document.body.append(modal); + modal.querySelector("a[href='#close']").addEventListener("click",event => { + event.preventDefault(); + reject("User cancelled"); + modal.remove(); + }); + htmlToArray(modal.getElementsByTagName("button")).forEach(button => { + button.addEventListener("click",event => { + event.preventDefault(); + var isYes = event.target.getAttribute("isyes")=="1"; + if (isYes) resolve(); + else reject("User cancelled"); + modal.remove(); + }); + }); + }); +} From f66aab5823c6b1974c38ebf729c223017740773b Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 3 Apr 2020 15:15:06 +0100 Subject: [PATCH 102/104] Add page to export files from Stopwatch, save files in better format and with better filename --- apps.json | 3 +- apps/heart/interface.html | 12 +---- apps/swatch/ChangeLog | 1 + apps/swatch/interface.html | 90 ++++++++++++++++++++++++++++++++++++++ apps/swatch/stopwatch.js | 32 +++++++------- lib/interface.js | 18 +++++++- 6 files changed, 128 insertions(+), 28 deletions(-) create mode 100644 apps/swatch/interface.html diff --git a/apps.json b/apps.json index d502b37c4..18d20b9da 100644 --- a/apps.json +++ b/apps.json @@ -392,7 +392,8 @@ { "id": "swatch", "name": "Stopwatch", "icon": "stopwatch.png", - "version":"0.03", + "version":"0.04", + "interface": "interface.html", "description": "Simple stopwatch with Lap Time logging to a JSON file", "tags": "health", "allow_emulator":true, diff --git a/apps/heart/interface.html b/apps/heart/interface.html index 177e2cdfb..4a21d2e27 100644 --- a/apps/heart/interface.html +++ b/apps/heart/interface.html @@ -11,17 +11,7 @@ var domRecords = document.getElementById("records"); function saveRecord(record,name) { var csv = `${record.map(rec=>[rec.time, rec.bpm, rec.confidence].join(",")).join("\n")}`; - var a = document.createElement("a"), - file = new Blob([csv], {type: "Comma-separated value file"}); - var url = URL.createObjectURL(file); - a.href = url; - a.download = name+".csv"; - document.body.appendChild(a); - a.click(); - setTimeout(function() { - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); + Util.saveCSV(name, csv); } diff --git a/apps/swatch/ChangeLog b/apps/swatch/ChangeLog index 86a782585..2900c9aa1 100644 --- a/apps/swatch/ChangeLog +++ b/apps/swatch/ChangeLog @@ -3,3 +3,4 @@ Lap log now scrolls into 2nd column after 18th entry, able to display 36 entries before going off screen 0.03: Added ability to save Lap log as a date named JSON file into memory Fixed bug from 0.01 where BN1 (reset) could clear the lap log when timer is running +0.04: Changed save file filename, add interface.html to allow laps to be loaded diff --git a/apps/swatch/interface.html b/apps/swatch/interface.html new file mode 100644 index 000000000..928c5fe39 --- /dev/null +++ b/apps/swatch/interface.html @@ -0,0 +1,90 @@ + + + + + +
+ + + + + diff --git a/apps/swatch/stopwatch.js b/apps/swatch/stopwatch.js index d4136d8ed..2ebd8198b 100644 --- a/apps/swatch/stopwatch.js +++ b/apps/swatch/stopwatch.js @@ -4,7 +4,6 @@ var started = false; var timeY = 60; var hsXPos = 0; var lapTimes = []; -var saveTimes = []; var displayInterval; function timeToText(t) { @@ -25,7 +24,7 @@ function updateLabels() { for (var i in lapTimes) { if (i<18) {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 30 + i*8);} - else + else {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-18)*8);} } drawsecs(); @@ -51,10 +50,8 @@ function drawms() { g.clearRect(hsXPos,timeY,220,timeY+20); g.drawString("."+("0"+hs).substr(-2),hsXPos,timeY+10); } -function saveconvert() { - for (var v in lapTimes){ - saveTimes[v]=v+1+"-"+timeToText(lapTimes[(lapTimes.length-1)-v]); - } +function getLapTimesArray() { + return lapTimes.map(timeToText).reverse(); } setWatch(function() { // Start/stop @@ -80,16 +77,21 @@ setWatch(function() { // Start/stop }, BTN2, {repeat:true}); setWatch(function() { // Lap Bangle.beep(); - if (started) tCurrent = Date.now(); - lapTimes.unshift(tCurrent-tStart); - tStart = tCurrent; - if (!started) - { - var timenow= Date(); - saveconvert(); - require("Storage").writeJSON("StpWch-"+timenow.toString(), saveTimes); + if (started) { + tCurrent = Date.now(); + lapTimes.unshift(tCurrent-tStart); + } + tStart = tCurrent; + if (!started) { // save + var timenow= Date(); + var filename = "swatch-"+(new Date()).toISOString().substr(0,16).replace("T","_")+".json"; + // this maxes out the 28 char maximum + require("Storage").writeJSON(filename, getLapTimesArray()); + E.showMessage("Laps Saved","Stopwatch"); + setTimeout(updateLabels, 1000); + } else { + updateLabels(); } - updateLabels(); }, BTN1, {repeat:true}); setWatch(function() { // Reset if (!started) { diff --git a/lib/interface.js b/lib/interface.js index 414c9d7fb..7e8be4fd9 100644 --- a/lib/interface.js +++ b/lib/interface.js @@ -39,7 +39,10 @@ var Util = { window.postMessage({type:"readstoragefile",data:filename,id:__id}); }, eraseStorageFile : function(filename,callback) { - Puck.write(`\x10require("Storage").open(${JSON.stringify(filename)}","r").erase()\n`,callback); + Puck.write(`\x10require("Storage").open(${JSON.stringify(filename)},"r").erase()\n`,callback); + }, + eraseStorage : function(filename,callback) { + Puck.write(`\x10require("Storage").erase(${JSON.stringify(filename)})\n`,callback); }, showModal : function(title) { if (!Util.domModal) { @@ -66,6 +69,19 @@ var Util = { hideModal : function() { if (!Util.domModal) return; Util.domModal.classList.remove("active"); + }, + saveCSV : function(filename, csvData) { + var a = document.createElement("a"), + file = new Blob([csvData], {type: "Comma-separated value file"}); + var url = URL.createObjectURL(file); + a.href = url; + a.download = filename+".csv"; + document.body.appendChild(a); + a.click(); + setTimeout(function() { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); } }; window.addEventListener("message", function(event) { From fbce9aaa7cd1bddaefa71ee8a9b15fb54912d7f1 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 3 Apr 2020 15:24:09 +0100 Subject: [PATCH 103/104] stopwatch - Added widgets --- apps.json | 2 +- apps/swatch/ChangeLog | 1 + apps/swatch/stopwatch.js | 14 +++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps.json b/apps.json index 18d20b9da..dcb27d1d1 100644 --- a/apps.json +++ b/apps.json @@ -392,7 +392,7 @@ { "id": "swatch", "name": "Stopwatch", "icon": "stopwatch.png", - "version":"0.04", + "version":"0.05", "interface": "interface.html", "description": "Simple stopwatch with Lap Time logging to a JSON file", "tags": "health", diff --git a/apps/swatch/ChangeLog b/apps/swatch/ChangeLog index 2900c9aa1..3246eeced 100644 --- a/apps/swatch/ChangeLog +++ b/apps/swatch/ChangeLog @@ -4,3 +4,4 @@ 0.03: Added ability to save Lap log as a date named JSON file into memory Fixed bug from 0.01 where BN1 (reset) could clear the lap log when timer is running 0.04: Changed save file filename, add interface.html to allow laps to be loaded +0.05: Added widgets diff --git a/apps/swatch/stopwatch.js b/apps/swatch/stopwatch.js index 2ebd8198b..6f8ad9e34 100644 --- a/apps/swatch/stopwatch.js +++ b/apps/swatch/stopwatch.js @@ -13,24 +13,26 @@ function timeToText(t) { return mins+":"+("0"+secs).substr(-2)+"."+("0"+hs).substr(-2); } function updateLabels() { - g.clear(); + g.reset(1); + g.clearRect(0,23,g.getWidth()-1,g.getHeight()-24); g.setFont("6x8",2); g.setFontAlign(0,0,3); g.drawString(started?"STOP":"GO",230,120); - if (!started) g.drawString("RESET",230,190); + if (!started) g.drawString("RESET",230,180); g.drawString(started?"LAP":"SAVE",230,50); g.setFont("6x8",1); g.setFontAlign(-1,-1); for (var i in lapTimes) { - if (i<18) + if (i<16) {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 30 + i*8);} - else - {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-18)*8);} + else if (i<32) + {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-16)*8);} } drawsecs(); } function drawsecs() { var t = tCurrent-tStart; + g.reset(1); g.setFont("Vector",48); g.setFontAlign(0,0); var secs = Math.floor(t/1000)%60; @@ -103,3 +105,5 @@ setWatch(function() { // Reset }, BTN3, {repeat:true}); updateLabels(); +Bangle.loadWidgets(); +Bangle.drawWidgets(); From 9d5751405871766fed7cb5c5ee3ac31ae4031c1d Mon Sep 17 00:00:00 2001 From: MaBecker Date: Fri, 3 Apr 2020 20:34:38 +0200 Subject: [PATCH 104/104] add cs_CZ with support from Standa --- apps/locale/locales.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/locale/locales.js b/apps/locale/locales.js index 7f6fbaef9..43e073cd1 100644 --- a/apps/locale/locales.js +++ b/apps/locale/locales.js @@ -1,4 +1,4 @@ - +/* jshint esversion: 6 */ const distanceUnits = { // how many meters per X? "m" : 1, "yd" : 0.9144, @@ -387,4 +387,21 @@ var locales = { abday: "Dom,Seg,Ter,Qua,Qui,Sex,Sab", day: "Domingo,Segunda-feira,Terça-feira,Quarta-feira,Quinta-feira,Sexta-feira,Sábado", trans: { yes: "sim", Yes: "Sim", no: "não", No: "Não", ok: "certo", on: "ligado", off: "desligado" }}, + "cs_CZ": { + lang: "cs_CZ", + decimal_point: ",", + thousands_sep: " ", + currency_symbol: "Kč", + int_curr_symbol: " CZK", + speed: 'kmh', + distance: { "0": "m", "1": "km" }, + temperature: '°C', + ampm: {0:"dop",1:"odp"}, + timePattern: { 0: "%HH:%MM:%SS ", 1: "%HH:%MM" }, + datePattern: { 0: "%d. %b %Y", 1: "%d.%m.%Y" }, // "30. led 2020" // "30.01.2020"(short) + abmonth: "led,úno,bře,dub,kvě,čvn,čvc,srp,zář,říj,lis,pro", + month: "leden,únor,březen,duben,květen,červen,červenec,srpen,září,říjen,listopad,prosinec", + abday: "ne,po,út,st,čt,pá,so", + day: "neděle,pondělí,úterý,středa,čtvrtek,pátek,sobota", + trans: { yes: "tak", Yes: "Tak", no: "nie", No: "Nie", ok: "ok", on: "na", off: "poza" }} };