From 81632cda7efca73e7fef1be515cc6b0e550fec12 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 6 Nov 2022 12:42:11 +0100 Subject: [PATCH 01/36] iconlaunch - Cleanup and reset timeout as needed --- apps/iconlaunch/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/iconlaunch/app.js b/apps/iconlaunch/app.js index 479956019..e7cf34840 100644 --- a/apps/iconlaunch/app.js +++ b/apps/iconlaunch/app.js @@ -133,6 +133,7 @@ g.flip(); const itemsN = Math.ceil(launchCache.apps.length / appsN); let onDrag = function(e) { + updateTimeout(); g.setColor(g.theme.fg); g.setBgColor(g.theme.bg); let dy = e.dy; @@ -182,6 +183,7 @@ drag: onDrag, touch: (_, e) => { if (e.y < R.y - 4) return; + updateTimeout(); let i = YtoIdx(e.y); selectItem(i, e); }, @@ -202,16 +204,23 @@ delete idxToY; delete YtoIdx; delete settings; + if (timeout) clearTimeout(timeout); setTimeout(eval, 0, s.read(".bootcde")); }; if (settings.oneClickExit) mode.btn = returnToClock; + + let timeout; + const updateTimeout = function(){ if (settings.timeOut!="Off"){ let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt - setTimeout(returnToClock,time*1000); + if (timeout) clearTimeout(timeout); + timeout = setTimeout(returnToClock,time*1000); + } } + updateTimeout(); Bangle.setUI(mode); } From d3286bab65bb59fb8cdecf63217a6fd238b66029 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 6 Nov 2022 14:20:55 +0100 Subject: [PATCH 02/36] iconlaunch - Bump version --- apps/iconlaunch/ChangeLog | 2 ++ apps/iconlaunch/metadata.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/iconlaunch/ChangeLog b/apps/iconlaunch/ChangeLog index c71da1467..b0fcaf856 100644 --- a/apps/iconlaunch/ChangeLog +++ b/apps/iconlaunch/ChangeLog @@ -12,3 +12,5 @@ used Object.assing for the settings fix cache not deleted when "showClocks" options is changed added timeOut to return to the clock +0.11: Cleanup timeout when changing to clock + Reset timeout on swipe and drag diff --git a/apps/iconlaunch/metadata.json b/apps/iconlaunch/metadata.json index 13e7aee08..8154d830a 100644 --- a/apps/iconlaunch/metadata.json +++ b/apps/iconlaunch/metadata.json @@ -2,7 +2,7 @@ "id": "iconlaunch", "name": "Icon Launcher", "shortName" : "Icon launcher", - "version": "0.10", + "version": "0.11", "icon": "app.png", "description": "A launcher inspired by smartphones, with an icon-only scrollable menu.", "tags": "tool,system,launcher", From cc6b296b095e3630b423aaa113ff69165f5e7440 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Sun, 6 Nov 2022 22:51:08 +0100 Subject: [PATCH 03/36] iconlaunch - Remove console log output --- apps/iconlaunch/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/iconlaunch/app.js b/apps/iconlaunch/app.js index e7cf34840..a7b89996a 100644 --- a/apps/iconlaunch/app.js +++ b/apps/iconlaunch/app.js @@ -9,7 +9,6 @@ timeOut:"Off" }, s.readJSON("iconlaunch.json", true) || {}); - console.log(settings); if (!settings.fullscreen) { Bangle.loadWidgets(); Bangle.drawWidgets(); From ac60c9cc11ab7cffa36569c312c9aac9cee15de9 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 18:37:49 +0100 Subject: [PATCH 04/36] Move interactions inside setUI --- apps/torch/app.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index 418463144..f2e9cdfe5 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -13,12 +13,14 @@ Bangle.setLCDTimeout(0); g.reset(); g.setColor(settings.bg); g.fillRect(0,0,g.getWidth(),g.getHeight()); -// Any button turns off -setWatch(()=>load(), BTN1); -if (global.BTN2) setWatch(()=>load(), BTN2); -if (global.BTN3) setWatch(()=>load(), BTN3); -// Pressing upper left corner turns off (where red back button would be) Bangle.setUI({ mode : 'custom', - back : load + back : load, // B2: Clicking the hardware button or pressing upper left corner turns off (where red back button would be) + btn : (n)=>{ // B1: Any button turns off + if (process.env.HWVERSION==1) { + setWatch(()=>load(), BTN1); + setWatch(()=>load(), BTN2); + setWatch(()=>load(), BTN3); + } + }, }); From 4b2215f3fc183f1605075ff0999c733290149af7 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 18:38:24 +0100 Subject: [PATCH 05/36] Update metadata.json --- apps/torch/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/metadata.json b/apps/torch/metadata.json index 580ae4e8a..88329eb44 100644 --- a/apps/torch/metadata.json +++ b/apps/torch/metadata.json @@ -2,7 +2,7 @@ "id": "torch", "name": "Torch", "shortName": "Torch", - "version": "0.06", + "version": "0.07", "description": "Turns screen white to help you see in the dark. Select from the launcher or press BTN1,BTN3,BTN1,BTN3 quickly to start when in any app that shows widgets on Bangle.js 1. You can also set the color through the app's setting menu.", "icon": "app.png", "tags": "tool,torch", From fceca1a5cc8c68e985d091a0cb214d433699210e Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 18:40:01 +0100 Subject: [PATCH 06/36] Update ChangeLog --- apps/torch/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/torch/ChangeLog b/apps/torch/ChangeLog index 22b1c179a..0ece0538f 100644 --- a/apps/torch/ChangeLog +++ b/apps/torch/ChangeLog @@ -4,3 +4,4 @@ 0.04: Add Support For Bangle.js 2 0.05: Default full Brightness 0.06: Press upper left corner to exit on Bangle.js 2 +0.07: Code tweaks From 28421a5e87156587253a23fede061c2b67c7f1c7 Mon Sep 17 00:00:00 2001 From: kirktrekkie Date: Mon, 7 Nov 2022 20:04:41 +0100 Subject: [PATCH 07/36] Added barwatch --- apps/barwatch/ChangeLog | 1 + apps/barwatch/README.md | 5 +++ apps/barwatch/app-icon.js | 1 + apps/barwatch/app.js | 80 ++++++++++++++++++++++++++++++++++++ apps/barwatch/app.png | Bin 0 -> 973 bytes apps/barwatch/barwatch.png | Bin 0 -> 1343 bytes apps/barwatch/metadata.json | 18 ++++++++ 7 files changed, 105 insertions(+) create mode 100644 apps/barwatch/ChangeLog create mode 100644 apps/barwatch/README.md create mode 100644 apps/barwatch/app-icon.js create mode 100644 apps/barwatch/app.js create mode 100644 apps/barwatch/app.png create mode 100644 apps/barwatch/barwatch.png create mode 100644 apps/barwatch/metadata.json diff --git a/apps/barwatch/ChangeLog b/apps/barwatch/ChangeLog new file mode 100644 index 000000000..7f837e50e --- /dev/null +++ b/apps/barwatch/ChangeLog @@ -0,0 +1 @@ +0.01: First version diff --git a/apps/barwatch/README.md b/apps/barwatch/README.md new file mode 100644 index 000000000..c37caa6e4 --- /dev/null +++ b/apps/barwatch/README.md @@ -0,0 +1,5 @@ +# BarWatch - an experimental watch + +For too long the watches have shown the time with digits or hands. No more! +With this stylish watch the time is represented by bars. Up to 24 as the day goes by. +Practical? Not really, but a different look! \ No newline at end of file diff --git a/apps/barwatch/app-icon.js b/apps/barwatch/app-icon.js new file mode 100644 index 000000000..f976346fb --- /dev/null +++ b/apps/barwatch/app-icon.js @@ -0,0 +1 @@ +E.toArrayBuffer(atob("l0uwkE/4A/AH4A/AB0gicQmUB+EPgEigExh8gj8A+ECAgMQn4WCgcACyotWC34W/C34W/CycACw0wgYWFBYIWCAAc/+YGHCAgNFACkxl8hGYwAMLYUvCykQC34WycoIW/C34W0gAWTmUjkUzkbmSAFY=")) \ No newline at end of file diff --git a/apps/barwatch/app.js b/apps/barwatch/app.js new file mode 100644 index 000000000..ff43bad44 --- /dev/null +++ b/apps/barwatch/app.js @@ -0,0 +1,80 @@ +// timeout used to update every minute +var drawTimeout; + +// schedule a draw for the next minute +function queueDraw() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, 60000 - (Date.now() % 60000)); +} + + +function draw() { + g.reset(); + g.setBgColor(0, 1, 1); + + // work out how to display the current time + var d = new Date(); + var h = d.getHours(), m = d.getMinutes(); + //h = 13; + //m = 59; + + var battery = E.getBattery() / 100; + g.setColor(1-battery,0+battery,0); + //console.log(battery); + g.setColor(1,1,1); + + var bx_offset = 10, by_offset = 35; + var b_width = 8, b_height = 60; + var b_space = 5; + + // hour bars + for(var i=0; i 11){ + by_offset = 105; + } + var iter = i % 12; + //console.log(iter); + g.fillRect(bx_offset+(b_width*(iter+1))+(b_space*iter), + by_offset, + bx_offset+(b_width*iter)+(b_space*iter), + by_offset+b_height); + } + + // minute bar + if(h > 11){ + by_offset = 105; + } + var m_bar = h % 12; + if(m != 0){ + g.fillRect(bx_offset+(b_width*(m_bar+1))+(b_space*m_bar), + by_offset+b_height-m, + bx_offset+(b_width*m_bar)+(b_space*m_bar), + by_offset+b_height); + } + + // queue draw in one minute + queueDraw(); +} + +Bangle.loadWidgets(); + +// Clear the screen once, at startup +g.clear(); +// draw immediately at first +draw(); +// Stop updates when LCD is off, restart when on +Bangle.on('lcdPower',on=>{ + if (on) { + draw(); // draw immediately, queue redraw + } else { // stop draw timer + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + } +}); + + +Bangle.drawWidgets(); +Bangle.setUI("clock"); \ No newline at end of file diff --git a/apps/barwatch/app.png b/apps/barwatch/app.png new file mode 100644 index 0000000000000000000000000000000000000000..134de9424bba19e3208a14cc1f755df74aeb3172 GIT binary patch literal 973 zcmV;;12X)HP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmbN~PnbOGLGA9w%&17b-;K~!i%?U_AG zGeHo?CyDQ%D84~_K|!>Th&Fx(3keA6liF`!Av{=#f`x^pAHl-L4`3no7FJ>t-xJg% z#w6-`|38`K@R20N!{zdDKR9+~Z)R??+3e13LdHQ_kZ`qaIfBH!CP>_Cg2cVXCjR;P zDWy_LDwPU#wD0fll(E!9{`mNyUMv=+TrN{a3qRQ4f~@xt1GeDn>x=SlF<=Kj*Z_A7 zw6OhayKy?m*47s8n7O$*bAEnq=I7_B9~~W;ot+)ZsZ@%#kjKZz&HeqoiAJN;VY9ot zOL=N)%3NGrn5Cs9>Q`4+W`BR5aw3s1&LB|k@9#HHPfs?+_V%_pJUpblu&`iWUS7=N z;v)5vlM_B$u_Lad`~3XO(JvGV)G-=5N;(Q4pU<;>dwXMxQBoh+>o*7@kq9pU`}X#B z%6Jxdcz9sz+S()>4%=tzOi*m%8mz0Ui%zOT?&#>CtbG770&7ChJ3BimqYpZK z0qk%A^oK$rE2F=sr-wTF^;sHQ<7=zb{c&OxaH(7i_x*adjZiB_-NgM$khs?biF-|u zxYq=Udrd=$>lR%Pw_T$?wWt-tCaxtViX+IXW7}2P9q8wF3>)|=kbm2<-F@(Zu7wnE z$I$yKyRnIDwda(QtbeoFEOk_CudlC^Gnouq;FP1R7PSvmpVr=}_TUE_fY=%zaWzpS ziKxg0CD(a}+HYHbD?8yln3?d`2N^|K5O4aw!@rS$gp z^4|6JH7mEl!9ji_kB^V63Y{98KKRhHv$HIDZ*FdAhszxUc1RMj;d^&?$Cwin6OvA+ z`N1Y9CvEi!TK^>L`1n|o$)s#gLr;Q(IC~;@KuS))*p~U@2khs^_ z#C0D3Y~A>2uG_@*{24_%mOotr^&bJCXXt()^2dRK^TsheJS;0KE3&-2EPZ`_GBYzH v@pxPY1_rnht*)+0EEc0KYFn5^BR*R?HIDeOs`DYw@LY|;5&pN@2GirHp!;=}VK zh&yl0{U_|5S3K+9%d=vKUKv!CDi}0!zHw}Odv@j9UbqL|1b!+qwNX7e_i|(G`bekG z3Wu9}VvX+Yq(0@!mBAvlLimQf^UBhtn+%!4`&@%H8JU(Z zxe^L=-O~t@sX)rhD^`_p*hzJ;`rQwZWwHhqH0rt6tL88?%DcbfEf-Sw;CE}?R|`fa z`@SpE?|_j$cT4Q+LME0vnU&^uJR1&JXYRiCn1$nyMNs~Z$qbF2=lsJk Date: Mon, 7 Nov 2022 20:12:05 +0100 Subject: [PATCH 08/36] barwatch fixes --- apps/barwatch/app.js | 19 ++++++++---------- apps/barwatch/metadata.json | 2 +- .../barwatch/{barwatch.png => screenshot.png} | Bin 3 files changed, 9 insertions(+), 12 deletions(-) rename apps/barwatch/{barwatch.png => screenshot.png} (100%) diff --git a/apps/barwatch/app.js b/apps/barwatch/app.js index ff43bad44..d6b759706 100644 --- a/apps/barwatch/app.js +++ b/apps/barwatch/app.js @@ -13,24 +13,22 @@ function queueDraw() { function draw() { g.reset(); - g.setBgColor(0, 1, 1); + + if(g.theme.dark){ + g.setColor(1,1,1); + }else{ + g.setColor(0,0,0); + } // work out how to display the current time var d = new Date(); var h = d.getHours(), m = d.getMinutes(); - //h = 13; - //m = 59; - - var battery = E.getBattery() / 100; - g.setColor(1-battery,0+battery,0); - //console.log(battery); - g.setColor(1,1,1); + // hour bars var bx_offset = 10, by_offset = 35; var b_width = 8, b_height = 60; var b_space = 5; - // hour bars for(var i=0; i 11){ by_offset = 105; @@ -75,6 +73,5 @@ Bangle.on('lcdPower',on=>{ } }); - +Bangle.setUI("clock"); Bangle.drawWidgets(); -Bangle.setUI("clock"); \ No newline at end of file diff --git a/apps/barwatch/metadata.json b/apps/barwatch/metadata.json index f0e3b87ab..adcd44107 100644 --- a/apps/barwatch/metadata.json +++ b/apps/barwatch/metadata.json @@ -5,7 +5,7 @@ "version":"0.01", "description": "A watch that displays the time using bars. One bar for each hour.", "readme": "README.md", - "icon": "barwatch.png", + "icon": "screenshot.png", "tags": "clock", "type": "clock", "allow_emulator":true, diff --git a/apps/barwatch/barwatch.png b/apps/barwatch/screenshot.png similarity index 100% rename from apps/barwatch/barwatch.png rename to apps/barwatch/screenshot.png From 4d01bb44f2e169d3143a04b8e2a19c90130e1747 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 20:13:21 +0100 Subject: [PATCH 09/36] edge: 'rising' added --- apps/torch/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index f2e9cdfe5..7f2680b46 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -18,9 +18,9 @@ Bangle.setUI({ back : load, // B2: Clicking the hardware button or pressing upper left corner turns off (where red back button would be) btn : (n)=>{ // B1: Any button turns off if (process.env.HWVERSION==1) { - setWatch(()=>load(), BTN1); - setWatch(()=>load(), BTN2); - setWatch(()=>load(), BTN3); + setWatch(()=>load(), BTN1, {edge: 'rising'}); + setWatch(()=>load(), BTN2, {edge: 'rising'}); + setWatch(()=>load(), BTN3, {edge: 'rising'}); } }, }); From 6442be55699a706a86bff73d2b3bdf81d2f450d9 Mon Sep 17 00:00:00 2001 From: kirktrekkie Date: Mon, 7 Nov 2022 20:17:32 +0100 Subject: [PATCH 10/36] Fixing app-icon.js --- apps/barwatch/app-icon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/barwatch/app-icon.js b/apps/barwatch/app-icon.js index f976346fb..82416ee28 100644 --- a/apps/barwatch/app-icon.js +++ b/apps/barwatch/app-icon.js @@ -1 +1 @@ -E.toArrayBuffer(atob("l0uwkE/4A/AH4A/AB0gicQmUB+EPgEigExh8gj8A+ECAgMQn4WCgcACyotWC34W/C34W/CycACw0wgYWFBYIWCAAc/+YGHCAgNFACkxl8hGYwAMLYUvCykQC34WycoIW/C34W0gAWTmUjkUzkbmSAFY=")) \ No newline at end of file +require("heatshrink").decompress(atob("l0uwkE/4A/AH4A/AB0gicQmUB+EPgEigExh8gj8A+ECAgMQn4WCgcACyotWC34W/C34W/CycACw0wgYWFBYIWCAAc/+YGHCAgNFACkxl8hGYwAMLYUvCykQC34WycoIW/C34W0gAWTmUjkUzkbmSAFY=")) \ No newline at end of file From 650cb3e0554a58ddd6183bd0acf4347dd383d3b7 Mon Sep 17 00:00:00 2001 From: kirktrekkie Date: Mon, 7 Nov 2022 20:29:41 +0100 Subject: [PATCH 11/36] Moving loadWidgets --- apps/barwatch/app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/barwatch/app.js b/apps/barwatch/app.js index d6b759706..e0ed15ce6 100644 --- a/apps/barwatch/app.js +++ b/apps/barwatch/app.js @@ -57,8 +57,6 @@ function draw() { queueDraw(); } -Bangle.loadWidgets(); - // Clear the screen once, at startup g.clear(); // draw immediately at first @@ -74,4 +72,5 @@ Bangle.on('lcdPower',on=>{ }); Bangle.setUI("clock"); +Bangle.loadWidgets(); Bangle.drawWidgets(); From 7a2acd8c48273064789082bd579b0500ab359b46 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 20:36:54 +0100 Subject: [PATCH 12/36] Code hopefully correct for B1 --- apps/torch/app.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index 7f2680b46..6e3354ee3 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -17,10 +17,8 @@ Bangle.setUI({ mode : 'custom', back : load, // B2: Clicking the hardware button or pressing upper left corner turns off (where red back button would be) btn : (n)=>{ // B1: Any button turns off - if (process.env.HWVERSION==1) { - setWatch(()=>load(), BTN1, {edge: 'rising'}); - setWatch(()=>load(), BTN2, {edge: 'rising'}); - setWatch(()=>load(), BTN3, {edge: 'rising'}); + if (process.env.HWVERSION==1 && (n==1 || n==2 || n==3)) { + load(); } }, }); From 9740753f0bcc6445af955a299a1ade4f3db7f87d Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:15:01 +0100 Subject: [PATCH 13/36] remove superfluous comma --- apps/torch/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index 6e3354ee3..4f44faf69 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -20,5 +20,5 @@ Bangle.setUI({ if (process.env.HWVERSION==1 && (n==1 || n==2 || n==3)) { load(); } - }, + } }); From af81e45aed4a2d512b70b6c3f82a4e84c4262700 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Mon, 7 Nov 2022 22:44:02 +0100 Subject: [PATCH 14/36] move ineractive code into setUI, replace 'click to exit' with back function in setUI (always on). --- apps/dtlaunch/ChangeLog | 3 +++ apps/dtlaunch/app-b2.js | 29 ++++++++--------------------- apps/dtlaunch/metadata.json | 2 +- apps/dtlaunch/settings-b2.js | 10 +--------- 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/apps/dtlaunch/ChangeLog b/apps/dtlaunch/ChangeLog index 1054aa387..ea9ca729f 100644 --- a/apps/dtlaunch/ChangeLog +++ b/apps/dtlaunch/ChangeLog @@ -16,3 +16,6 @@ 0.16: Use default Bangle formatter for booleans 0.17: Bangle 2: Fast loading on exit to clock face. Added option for exit to clock face by timeout. +0.18: Move interactions inside setUI. Replace "one click exit" with +back-functionality through setUI, adding the red back button as well. Hardware +button to exit is no longer an option. diff --git a/apps/dtlaunch/app-b2.js b/apps/dtlaunch/app-b2.js index 48d9b2f38..df5bfc48f 100644 --- a/apps/dtlaunch/app-b2.js +++ b/apps/dtlaunch/app-b2.js @@ -8,15 +8,10 @@ let settings = Object.assign({ showClocks: true, showLaunchers: true, direct: false, - oneClickExit: false, swipeExit: false, timeOut: "Off" }, require('Storage').readJSON("dtlaunch.json", true) || {}); -if (settings.oneClickExit) { - var buttonWatch = setWatch(_=> returnToClock(), BTN1, {edge: 'falling'}); -} - let s = require("Storage"); var apps = s.list(/\.info$/).map(app=>{ let a=s.readJSON(app,1); @@ -91,7 +86,7 @@ let drawPage = function(p){ Bangle.loadWidgets(); //g.clear(); -Bangle.drawWidgets(); +//Bangle.drawWidgets(); drawPage(0); let swipeListenerDt = function(dirLeftRight, dirUpDown){ @@ -106,7 +101,6 @@ let swipeListenerDt = function(dirLeftRight, dirUpDown){ drawPage(page); } }; -Bangle.on("swipe",swipeListenerDt); let isTouched = function(p,n){ if (n<0 || n>3) return false; @@ -138,25 +132,18 @@ let touchListenerDt = function(_,p){ selected=-1; } }; -Bangle.on("touch",touchListenerDt); const returnToClock = function() { Bangle.setUI(); - if (buttonWatch) { - clearWatch(buttonWatch); - delete buttonWatch; - } - if (timeoutToClock) { - clearTimeout(timeoutToClock); - delete timeoutToClock; - } - Bangle.removeListener("swipe", swipeListenerDt); - Bangle.removeListener("touch", touchListenerDt); - var apps = []; - delete apps; - delete returnToClock; setTimeout(eval, 0, s.read(".bootcde")); }; + +Bangle.setUI({ + mode : 'custom', + back : returnToClock, + swipe : swipeListenerDt, + touch : touchListenerDt +}); // taken from Icon Launcher with minor alterations var timeoutToClock; diff --git a/apps/dtlaunch/metadata.json b/apps/dtlaunch/metadata.json index b71f4ca9b..2892b758e 100644 --- a/apps/dtlaunch/metadata.json +++ b/apps/dtlaunch/metadata.json @@ -1,7 +1,7 @@ { "id": "dtlaunch", "name": "Desktop Launcher", - "version": "0.17", + "version": "0.18", "description": "Desktop style App Launcher with six (four for Bangle 2) apps per page - fast access if you have lots of apps installed.", "screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}], "icon": "icon.png", diff --git a/apps/dtlaunch/settings-b2.js b/apps/dtlaunch/settings-b2.js index 80ad0414a..24959df8c 100644 --- a/apps/dtlaunch/settings-b2.js +++ b/apps/dtlaunch/settings-b2.js @@ -5,7 +5,6 @@ showClocks: true, showLaunchers: true, direct: false, - oneClickExit:false, swipeExit: false, timeOut: "Off" }, require('Storage').readJSON(FILE, true) || {}); @@ -47,13 +46,6 @@ writeSettings(); } }, - /*LANG*/'One click exit': { - value: settings.oneClickExit, - onchange: v => { - settings.oneClickExit = v; - writeSettings(); - } - }, /*LANG*/'Time Out': { // Adapted from Icon Launcher value: timeOutChoices.indexOf(settings.timeOut), min: 0, @@ -63,6 +55,6 @@ settings.timeOut = timeOutChoices[v]; writeSettings(); } - }, + } }); }); From ed58888091c4fca4a379bada581df66b01d601a4 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Tue, 8 Nov 2022 23:32:59 +0100 Subject: [PATCH 15/36] Use appRect. Keep all in ram for performance ... ... only adds 1% to ram widget while getting to be buttery smooth --- apps/dragboard/lib.js | 62 +++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/apps/dragboard/lib.js b/apps/dragboard/lib.js index b9b19f982..edeb759bf 100644 --- a/apps/dragboard/lib.js +++ b/apps/dragboard/lib.js @@ -3,10 +3,14 @@ //Bangle.setLCDPower(1); exports.input = function(options) { + "ram"; + //Bangle.loadWidgets(); + //Bangle.drawWidgets(); options = options||{}; var text = options.text; if ("string"!=typeof text) text=""; + var R = Bangle.appRect; var BGCOLOR = g.theme.bg; var HLCOLOR = g.theme.fg; var ABCCOLOR = g.toColor(1,0,0);//'#FF0000'; @@ -17,11 +21,11 @@ exports.input = function(options) { var SMALLFONTWIDTH = parseInt(SMALLFONT.charAt(0)*parseInt(SMALLFONT.charAt(-1))); var ABC = 'abcdefghijklmnopqrstuvwxyz'.toUpperCase(); - var ABCPADDING = (g.getWidth()-6*ABC.length)/2; + var ABCPADDING = ((R.x+R.w)-6*ABC.length)/2; var NUM = ' 1234567890!?,.- '; var NUMHIDDEN = ' 1234567890!?,.- '; - var NUMPADDING = (g.getWidth()-6*NUM.length)/2; + var NUMPADDING = ((R.x+R.w)-6*NUM.length)/2; var rectHeight = 40; @@ -32,20 +36,20 @@ exports.input = function(options) { g.clear(); g.setFont(SMALLFONT); g.setColor(ABCCOLOR); - g.drawString(ABC, ABCPADDING, g.getHeight()/2); - g.fillRect(0, g.getHeight()-26, g.getWidth(), g.getHeight()); + g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); + g.fillRect(0, (R.y+R.h)-26, (R.x+R.w), (R.y+R.h)); } function drawNumRow() { g.setFont(SMALLFONT); g.setColor(NUMCOLOR); - g.drawString(NUM, NUMPADDING, g.getHeight()/4); + g.drawString(NUM, NUMPADDING, (R.y+R.h)/4); - g.fillRect(NUMPADDING, g.getHeight()-rectHeight*4/3, g.getWidth()-NUMPADDING, g.getHeight()-rectHeight*2/3); + g.fillRect(NUMPADDING, (R.y+R.h)-rectHeight*4/3, (R.x+R.w)-NUMPADDING, (R.y+R.h)-rectHeight*2/3); } function updateTopString() { - "ram" + g.setColor(BGCOLOR); g.fillRect(0,4+20,176,13+20); g.setColor(0.2,0,0); @@ -57,10 +61,6 @@ exports.input = function(options) { g.drawString(text.length<=27? text.substr(-27, 27) : '<- '+text.substr(-24,24), 5, 5+20); } - drawAbcRow(); - drawNumRow(); - updateTopString(); - var abcHL; var abcHLPrev = -10; var numHL; @@ -70,36 +70,40 @@ exports.input = function(options) { var largeCharOffset = 6; function resetChars(char, HLPrev, typePadding, heightDivisor, rowColor) { - "ram" + // Small character in list g.setColor(rowColor); g.setFont(SMALLFONT); - g.drawString(char, typePadding + HLPrev*6, g.getHeight()/heightDivisor); + g.drawString(char, typePadding + HLPrev*6, (R.y+R.h)/heightDivisor); // Large character g.setColor(BGCOLOR); - g.fillRect(0,g.getHeight()/3,176,g.getHeight()/3+24); - //g.drawString(charSet.charAt(HLPrev), typePadding + HLPrev*6 -largeCharOffset, g.getHeight()/3);; //Old implementation where I find the shape and place of letter to remove instead of just a rectangle. + g.fillRect(0,(R.y+R.h)/3,176,(R.y+R.h)/3+24); + //g.drawString(charSet.charAt(HLPrev), typePadding + HLPrev*6 -largeCharOffset, (R.y+R.h)/3);; //Old implementation where I find the shape and place of letter to remove instead of just a rectangle. // mark in the list } function showChars(char, HL, typePadding, heightDivisor) { - "ram" + // mark in the list g.setColor(HLCOLOR); g.setFont(SMALLFONT); - if (char != 'del' && char != 'space') g.drawString(char, typePadding + HL*6, g.getHeight()/heightDivisor); + if (char != 'del' && char != 'space') g.drawString(char, typePadding + HL*6, (R.y+R.h)/heightDivisor); // show new large character g.setFont(BIGFONT); - g.drawString(char, typePadding + HL*6 -largeCharOffset, g.getHeight()/3); + g.drawString(char, typePadding + HL*6 -largeCharOffset, (R.y+R.h)/3); g.setFont(SMALLFONT); } - + + drawAbcRow(); + drawNumRow(); + updateTopString(); + function changeCase(abcHL) { g.setColor(BGCOLOR); - g.drawString(ABC, ABCPADDING, g.getHeight()/2); + g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); if (ABC.charAt(abcHL) == ABC.charAt(abcHL).toUpperCase()) ABC = ABC.toLowerCase(); else ABC = ABC.toUpperCase(); g.setColor(ABCCOLOR); - g.drawString(ABC, ABCPADDING, g.getHeight()/2); + g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); } return new Promise((resolve,reject) => { // Interpret touch input @@ -114,7 +118,7 @@ exports.input = function(options) { // ABCDEFGHIJKLMNOPQRSTUVWXYZ // Choose character by draging along red rectangle at bottom of screen - if (event.y >= ( g.getHeight() - 12 )) { + if (event.y >= ( (R.y+R.h) - 12 )) { // Translate x-position to character if (event.x < ABCPADDING) { abcHL = 0; } else if (event.x >= 176-ABCPADDING) { abcHL = 25; } @@ -154,7 +158,7 @@ exports.input = function(options) { // 12345678901234567890 // Choose number or puctuation by draging on green rectangle - else if ((event.y < ( g.getHeight() - 12 )) && (event.y > ( g.getHeight() - 52 ))) { + else if ((event.y < ( (R.y+R.h) - 12 )) && (event.y > ( (R.y+R.h) - 52 ))) { // Translate x-position to character if (event.x < NUMPADDING) { numHL = 0; } else if (event.x > 176-NUMPADDING) { numHL = NUM.length-1; } @@ -177,16 +181,16 @@ exports.input = function(options) { // Backspace if releasing before list of numbers/punctuation if (event.x < NUMPADDING) { // show delete sign - showChars('del', 0, g.getWidth()/2 +6 -27 , 4); + showChars('del', 0, (R.x+R.w)/2 +6 -27 , 4); delSpaceLast = 1; text = text.slice(0, -1); updateTopString(); //print(text); } // Append space if releasing after list of numbers/punctuation - else if (event.x > g.getWidth()-NUMPADDING) { + else if (event.x > (R.x+R.w)-NUMPADDING) { //show space sign - showChars('space', 0, g.getWidth()/2 +6 -6*3*5/2 , 4); + showChars('space', 0, (R.x+R.w)/2 +6 -6*3*5/2 , 4); delSpaceLast = 1; text = text + ' '; updateTopString(); @@ -217,12 +221,12 @@ exports.input = function(options) { else if (event.y > 20+4) { if (event.b == 0) { g.setColor(HLCOLOR); - if (event.x < g.getWidth()/2) { + if (event.x < (R.x+R.w)/2) { resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); // show delete sign - showChars('del', 0, g.getWidth()/2 +6 -27 , 4); + showChars('del', 0, (R.x+R.w)/2 +6 -27 , 4); delSpaceLast = 1; // Backspace and draw string upper right corner @@ -236,7 +240,7 @@ exports.input = function(options) { resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); //show space sign - showChars('space', 0, g.getWidth()/2 +6 -6*3*5/2 , 4); + showChars('space', 0, (R.x+R.w)/2 +6 -6*3*5/2 , 4); delSpaceLast = 1; // Append space and draw string upper right corner From fd6c1e83edcb24ee0936b7ac4c4f58f7c5864e75 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:23:24 +0100 Subject: [PATCH 16/36] Draw widgets if present. Code more reliable. --- apps/dragboard/lib.js | 289 ++++++++++++++++++++---------------------- 1 file changed, 136 insertions(+), 153 deletions(-) diff --git a/apps/dragboard/lib.js b/apps/dragboard/lib.js index edeb759bf..7f147b3e0 100644 --- a/apps/dragboard/lib.js +++ b/apps/dragboard/lib.js @@ -1,15 +1,9 @@ -//Keep banglejs screen on for 100 sec at 0.55 power level for development purposes -//Bangle.setLCDTimeout(30); -//Bangle.setLCDPower(1); - exports.input = function(options) { "ram"; - //Bangle.loadWidgets(); - //Bangle.drawWidgets(); options = options||{}; var text = options.text; if ("string"!=typeof text) text=""; - + var R = Bangle.appRect; var BGCOLOR = g.theme.bg; var HLCOLOR = g.theme.fg; @@ -29,13 +23,16 @@ exports.input = function(options) { var rectHeight = 40; - var delSpaceLast; function drawAbcRow() { g.clear(); + try { // Draw widgets if they are present in the current app. + if (WIDGETS) Bangle.drawWidgets(); + } catch (_) {} g.setFont(SMALLFONT); g.setColor(ABCCOLOR); + g.setFontAlign(-1, -1, 0); g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); g.fillRect(0, (R.y+R.h)-26, (R.x+R.w), (R.y+R.h)); } @@ -43,13 +40,14 @@ exports.input = function(options) { function drawNumRow() { g.setFont(SMALLFONT); g.setColor(NUMCOLOR); + g.setFontAlign(-1, -1, 0); g.drawString(NUM, NUMPADDING, (R.y+R.h)/4); g.fillRect(NUMPADDING, (R.y+R.h)-rectHeight*4/3, (R.x+R.w)-NUMPADDING, (R.y+R.h)-rectHeight*2/3); } function updateTopString() { - + g.setColor(BGCOLOR); g.fillRect(0,4+20,176,13+20); g.setColor(0.2,0,0); @@ -58,6 +56,7 @@ exports.input = function(options) { g.setColor(0.7,0,0); g.fillRect(rectLen+5,4+20,rectLen+10,13+20); g.setColor(1,1,1); + g.setFontAlign(-1, -1, 0); g.drawString(text.length<=27? text.substr(-27, 27) : '<- '+text.substr(-24,24), 5, 5+20); } @@ -68,12 +67,13 @@ exports.input = function(options) { var type = ''; var typePrev = ''; var largeCharOffset = 6; - + function resetChars(char, HLPrev, typePadding, heightDivisor, rowColor) { - + // Small character in list g.setColor(rowColor); g.setFont(SMALLFONT); + g.setFontAlign(-1, -1, 0); g.drawString(char, typePadding + HLPrev*6, (R.y+R.h)/heightDivisor); // Large character g.setColor(BGCOLOR); @@ -82,10 +82,11 @@ exports.input = function(options) { // mark in the list } function showChars(char, HL, typePadding, heightDivisor) { - + // mark in the list g.setColor(HLCOLOR); g.setFont(SMALLFONT); + g.setFontAlign(-1, -1, 0); if (char != 'del' && char != 'space') g.drawString(char, typePadding + HL*6, (R.y+R.h)/heightDivisor); // show new large character g.setFont(BIGFONT); @@ -93,12 +94,18 @@ exports.input = function(options) { g.setFont(SMALLFONT); } - drawAbcRow(); - drawNumRow(); - updateTopString(); + function initDraw() { + //var R = Bangle.appRect; // To make sure it's properly updated. Not sure if this is needed. + drawAbcRow(); + drawNumRow(); + updateTopString(); + } + initDraw(); + //setTimeout(initDraw, 0); // So Bangle.appRect reads the correct environment. It would draw off to the side sometimes otherwise. function changeCase(abcHL) { g.setColor(BGCOLOR); + g.setFontAlign(-1, -1, 0); g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); if (ABC.charAt(abcHL) == ABC.charAt(abcHL).toUpperCase()) ABC = ABC.toLowerCase(); else ABC = ABC.toUpperCase(); @@ -106,160 +113,136 @@ exports.input = function(options) { g.drawString(ABC, ABCPADDING, (R.y+R.h)/2); } return new Promise((resolve,reject) => { - // Interpret touch input + // Interpret touch input Bangle.setUI({ - mode: 'custom', - back: ()=>{ - Bangle.setUI(); - g.clearRect(Bangle.appRect); - resolve(text); - }, - drag: function(event) { + mode: 'custom', + back: ()=>{ + Bangle.setUI(); + g.clearRect(Bangle.appRect); + resolve(text); + }, + drag: function(event) { - // ABCDEFGHIJKLMNOPQRSTUVWXYZ - // Choose character by draging along red rectangle at bottom of screen - if (event.y >= ( (R.y+R.h) - 12 )) { - // Translate x-position to character - if (event.x < ABCPADDING) { abcHL = 0; } - else if (event.x >= 176-ABCPADDING) { abcHL = 25; } - else { abcHL = Math.floor((event.x-ABCPADDING)/6); } + // ABCDEFGHIJKLMNOPQRSTUVWXYZ + // Choose character by draging along red rectangle at bottom of screen + if (event.y >= ( (R.y+R.h) - 12 )) { + // Translate x-position to character + if (event.x < ABCPADDING) { abcHL = 0; } + else if (event.x >= 176-ABCPADDING) { abcHL = 25; } + else { abcHL = Math.floor((event.x-ABCPADDING)/6); } - // Datastream for development purposes - //print(event.x, event.y, event.b, ABC.charAt(abcHL), ABC.charAt(abcHLPrev)); + // Datastream for development purposes + //print(event.x, event.y, event.b, ABC.charAt(abcHL), ABC.charAt(abcHLPrev)); - // Unmark previous character and mark the current one... - // Handling switching between letters and numbers/punctuation - if (typePrev != 'abc') resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); + // Unmark previous character and mark the current one... + // Handling switching between letters and numbers/punctuation + if (typePrev != 'abc') resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); - if (abcHL != abcHLPrev) { - resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); - showChars(ABC.charAt(abcHL), abcHL, ABCPADDING, 2); + if (abcHL != abcHLPrev) { + resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); + showChars(ABC.charAt(abcHL), abcHL, ABCPADDING, 2); } - // Print string at top of screen - if (event.b == 0) { - text = text + ABC.charAt(abcHL); - updateTopString(); - - // Autoswitching letter case - if (ABC.charAt(abcHL) == ABC.charAt(abcHL).toUpperCase()) changeCase(abcHL); - } - // Update previous character to current one - abcHLPrev = abcHL; - typePrev = 'abc'; - } - - - - - - - - - - // 12345678901234567890 - // Choose number or puctuation by draging on green rectangle - else if ((event.y < ( (R.y+R.h) - 12 )) && (event.y > ( (R.y+R.h) - 52 ))) { - // Translate x-position to character - if (event.x < NUMPADDING) { numHL = 0; } - else if (event.x > 176-NUMPADDING) { numHL = NUM.length-1; } - else { numHL = Math.floor((event.x-NUMPADDING)/6); } - - // Datastream for development purposes - //print(event.x, event.y, event.b, NUM.charAt(numHL), NUM.charAt(numHLPrev)); - - // Unmark previous character and mark the current one... - // Handling switching between letters and numbers/punctuation - if (typePrev != 'num') resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); - - if (numHL != numHLPrev) { - resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); - showChars(NUM.charAt(numHL), numHL, NUMPADDING, 4); - } - // Print string at top of screen - if (event.b == 0) { - g.setColor(HLCOLOR); - // Backspace if releasing before list of numbers/punctuation - if (event.x < NUMPADDING) { - // show delete sign - showChars('del', 0, (R.x+R.w)/2 +6 -27 , 4); - delSpaceLast = 1; - text = text.slice(0, -1); - updateTopString(); - //print(text); - } - // Append space if releasing after list of numbers/punctuation - else if (event.x > (R.x+R.w)-NUMPADDING) { - //show space sign - showChars('space', 0, (R.x+R.w)/2 +6 -6*3*5/2 , 4); - delSpaceLast = 1; - text = text + ' '; - updateTopString(); - //print(text); - } - // Append selected number/punctuation - else { - text = text + NUMHIDDEN.charAt(numHL); + // Print string at top of screen + if (event.b == 0) { + text = text + ABC.charAt(abcHL); updateTopString(); // Autoswitching letter case - if ((text.charAt(text.length-1) == '.') || (text.charAt(text.length-1) == '!')) changeCase(); + if (ABC.charAt(abcHL) == ABC.charAt(abcHL).toUpperCase()) changeCase(abcHL); } + // Update previous character to current one + abcHLPrev = abcHL; + typePrev = 'abc'; } - // Update previous character to current one - numHLPrev = numHL; - typePrev = 'num'; - } - - - - - - - - - // Make a space or backspace by swiping right or left on screen above green rectangle - else if (event.y > 20+4) { - if (event.b == 0) { - g.setColor(HLCOLOR); - if (event.x < (R.x+R.w)/2) { - resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); + + // 12345678901234567890 + // Choose number or puctuation by draging on green rectangle + else if ((event.y < ( (R.y+R.h) - 12 )) && (event.y > ( (R.y+R.h) - 52 ))) { + // Translate x-position to character + if (event.x < NUMPADDING) { numHL = 0; } + else if (event.x > 176-NUMPADDING) { numHL = NUM.length-1; } + else { numHL = Math.floor((event.x-NUMPADDING)/6); } + + // Datastream for development purposes + //print(event.x, event.y, event.b, NUM.charAt(numHL), NUM.charAt(numHLPrev)); + + // Unmark previous character and mark the current one... + // Handling switching between letters and numbers/punctuation + if (typePrev != 'num') resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); + + if (numHL != numHLPrev) { resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); - - // show delete sign - showChars('del', 0, (R.x+R.w)/2 +6 -27 , 4); - delSpaceLast = 1; - - // Backspace and draw string upper right corner - text = text.slice(0, -1); - updateTopString(); - if (text.length==0) changeCase(abcHL); - //print(text, 'undid'); + showChars(NUM.charAt(numHL), numHL, NUMPADDING, 4); } - else { - resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); - resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); + // Print string at top of screen + if (event.b == 0) { + g.setColor(HLCOLOR); + // Backspace if releasing before list of numbers/punctuation + if (event.x < NUMPADDING) { + // show delete sign + showChars('del', 0, (R.x+R.w)/2 +6 -27 , 4); + delSpaceLast = 1; + text = text.slice(0, -1); + updateTopString(); + //print(text); + } + // Append space if releasing after list of numbers/punctuation + else if (event.x > (R.x+R.w)-NUMPADDING) { + //show space sign + showChars('space', 0, (R.x+R.w)/2 +6 -6*3*5/2 , 4); + delSpaceLast = 1; + text = text + ' '; + updateTopString(); + //print(text); + } + // Append selected number/punctuation + else { + text = text + NUMHIDDEN.charAt(numHL); + updateTopString(); - //show space sign - showChars('space', 0, (R.x+R.w)/2 +6 -6*3*5/2 , 4); - delSpaceLast = 1; + // Autoswitching letter case + if ((text.charAt(text.length-1) == '.') || (text.charAt(text.length-1) == '!')) changeCase(); + } + } + // Update previous character to current one + numHLPrev = numHL; + typePrev = 'num'; + } - // Append space and draw string upper right corner - text = text + NUMHIDDEN.charAt(0); - updateTopString(); - //print(text, 'made space'); + // Make a space or backspace by swiping right or left on screen above green rectangle + else if (event.y > 20+4) { + if (event.b == 0) { + g.setColor(HLCOLOR); + if (event.x < (R.x+R.w)/2) { + resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); + resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); + + // show delete sign + showChars('del', 0, (R.x+R.w)/2 +6 -27 , 4); + delSpaceLast = 1; + + // Backspace and draw string upper right corner + text = text.slice(0, -1); + updateTopString(); + if (text.length==0) changeCase(abcHL); + //print(text, 'undid'); + } + else { + resetChars(ABC.charAt(abcHLPrev), abcHLPrev, ABCPADDING, 2, ABCCOLOR); + resetChars(NUM.charAt(numHLPrev), numHLPrev, NUMPADDING, 4, NUMCOLOR); + + //show space sign + showChars('space', 0, (R.x+R.w)/2 +6 -6*3*5/2 , 4); + delSpaceLast = 1; + + // Append space and draw string upper right corner + text = text + NUMHIDDEN.charAt(0); + updateTopString(); + //print(text, 'made space'); + } } } } - } - }); -}); -/* return new Promise((resolve,reject) => { - Bangle.setUI({mode:"custom", back:()=>{ - Bangle.setUI(); - g.clearRect(Bangle.appRect); - Bangle.setUI(); - resolve(text); - }}); - }); */ - + }); + }); }; From 6e54a369013d90ba541784f748254a8c2994d3d8 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:25:03 +0100 Subject: [PATCH 17/36] Update ChangeLog --- apps/dragboard/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dragboard/ChangeLog b/apps/dragboard/ChangeLog index 48a1ffb03..265094e87 100644 --- a/apps/dragboard/ChangeLog +++ b/apps/dragboard/ChangeLog @@ -3,3 +3,4 @@ 0.03: Made the code shorter and somewhat more readable by writing some functions. Also made it work as a library where it returns the text once finished. The keyboard is now made to exit correctly when the 'back' event is called. The keyboard now uses theme colors correctly, although it still looks best with dark theme. The numbers row is now solidly green - except for highlights. 0.04: Now displays the opened text string at launch. 0.05: Now scrolls text when string gets longer than screen width. +0.06: The code is now more reliable and the input snappier. Widgets will be drawn if present. From 867a67330299dec4b21331483609c61ad591a874 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:25:21 +0100 Subject: [PATCH 18/36] Update metadata.json --- apps/dragboard/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dragboard/metadata.json b/apps/dragboard/metadata.json index f9c73ddde..64b6dbe18 100644 --- a/apps/dragboard/metadata.json +++ b/apps/dragboard/metadata.json @@ -1,6 +1,6 @@ { "id": "dragboard", "name": "Dragboard", - "version":"0.05", + "version":"0.06", "description": "A library for text input via swiping keyboard", "icon": "app.png", "type":"textinput", From 05a56ec67e2f54928d9b1f8eece7b7a2fa966ff7 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:31:15 +0100 Subject: [PATCH 19/36] remove some empty rows --- apps/dragboard/lib.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/dragboard/lib.js b/apps/dragboard/lib.js index 7f147b3e0..c43a37ab7 100644 --- a/apps/dragboard/lib.js +++ b/apps/dragboard/lib.js @@ -47,7 +47,6 @@ exports.input = function(options) { } function updateTopString() { - g.setColor(BGCOLOR); g.fillRect(0,4+20,176,13+20); g.setColor(0.2,0,0); @@ -69,7 +68,6 @@ exports.input = function(options) { var largeCharOffset = 6; function resetChars(char, HLPrev, typePadding, heightDivisor, rowColor) { - // Small character in list g.setColor(rowColor); g.setFont(SMALLFONT); @@ -82,7 +80,6 @@ exports.input = function(options) { // mark in the list } function showChars(char, HL, typePadding, heightDivisor) { - // mark in the list g.setColor(HLCOLOR); g.setFont(SMALLFONT); @@ -122,7 +119,6 @@ exports.input = function(options) { resolve(text); }, drag: function(event) { - // ABCDEFGHIJKLMNOPQRSTUVWXYZ // Choose character by draging along red rectangle at bottom of screen if (event.y >= ( (R.y+R.h) - 12 )) { From a01a572182e7180efc3e0a5c93df45620bc097ad Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 01:06:58 +0100 Subject: [PATCH 20/36] Keep in ram for higher performance --- apps/kbswipe/lib.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/kbswipe/lib.js b/apps/kbswipe/lib.js index 417ac98d9..fc9704850 100644 --- a/apps/kbswipe/lib.js +++ b/apps/kbswipe/lib.js @@ -5,6 +5,7 @@ Bangle.on('stroke',print) on the left of the IDE, then do a stroke and copy out the Uint8Array line */ exports.getStrokes = function(cb) { + "ram"; cb("a", new Uint8Array([58, 159, 58, 155, 62, 144, 69, 127, 77, 106, 86, 90, 94, 77, 101, 68, 108, 62, 114, 59, 121, 59, 133, 61, 146, 70, 158, 88, 169, 107, 176, 124, 180, 135, 183, 144, 185, 152])); cb("b", new Uint8Array([51, 47, 51, 77, 56, 123, 60, 151, 65, 163, 68, 164, 68, 144, 67, 108, 67, 76, 72, 43, 104, 51, 121, 74, 110, 87, 109, 95, 131, 117, 131, 140, 109, 152, 88, 157])); cb("c", new Uint8Array([153, 62, 150, 62, 145, 62, 136, 62, 123, 62, 106, 65, 85, 70, 65, 75, 50, 82, 42, 93, 37, 106, 36, 119, 36, 130, 40, 140, 49, 147, 61, 153, 72, 156, 85, 157, 106, 158, 116, 158])); From 502429a0d0c8e306d416848885841beda6a56eb8 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 09:59:46 +0100 Subject: [PATCH 21/36] Update metadata.json --- apps/kbswipe/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/kbswipe/metadata.json b/apps/kbswipe/metadata.json index d4026c815..59622cb96 100644 --- a/apps/kbswipe/metadata.json +++ b/apps/kbswipe/metadata.json @@ -1,6 +1,6 @@ { "id": "kbswipe", "name": "Swipe keyboard", - "version":"0.04", + "version":"0.05", "description": "A library for text input via PalmOS style swipe gestures (beta!)", "icon": "app.png", "type":"textinput", From 70f61f55dd5b273a2dfc26a60e76cbd59ddf9a3f Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:00:31 +0100 Subject: [PATCH 22/36] Update ChangeLog --- apps/kbswipe/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/kbswipe/ChangeLog b/apps/kbswipe/ChangeLog index f0dc54b69..49f532b54 100644 --- a/apps/kbswipe/ChangeLog +++ b/apps/kbswipe/ChangeLog @@ -2,3 +2,4 @@ 0.02: Now keeps user input trace intact by changing how the screen is updated. 0.03: Positioning of marker now takes the height of the widget field into account. 0.04: Fix issue if going back without typing. +0.05: Keep in ram for improved performance and input reliability. From 33a686de393341cf46d5513890269f327c1764d1 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:20:39 +0100 Subject: [PATCH 23/36] Be selective about "ram" keyword --- apps/dragboard/lib.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/dragboard/lib.js b/apps/dragboard/lib.js index c43a37ab7..2da61e1db 100644 --- a/apps/dragboard/lib.js +++ b/apps/dragboard/lib.js @@ -1,5 +1,4 @@ exports.input = function(options) { - "ram"; options = options||{}; var text = options.text; if ("string"!=typeof text) text=""; @@ -68,6 +67,7 @@ exports.input = function(options) { var largeCharOffset = 6; function resetChars(char, HLPrev, typePadding, heightDivisor, rowColor) { + "ram" // Small character in list g.setColor(rowColor); g.setFont(SMALLFONT); @@ -80,6 +80,7 @@ exports.input = function(options) { // mark in the list } function showChars(char, HL, typePadding, heightDivisor) { + "ram" // mark in the list g.setColor(HLCOLOR); g.setFont(SMALLFONT); @@ -119,6 +120,7 @@ exports.input = function(options) { resolve(text); }, drag: function(event) { + "ram" // ABCDEFGHIJKLMNOPQRSTUVWXYZ // Choose character by draging along red rectangle at bottom of screen if (event.y >= ( (R.y+R.h) - 12 )) { From 44916e364f5ed5d2625ebd66ce8beaa030bcb28f Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:24:12 +0100 Subject: [PATCH 24/36] add semicolons --- apps/dragboard/lib.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/dragboard/lib.js b/apps/dragboard/lib.js index 2da61e1db..220f075d7 100644 --- a/apps/dragboard/lib.js +++ b/apps/dragboard/lib.js @@ -67,7 +67,7 @@ exports.input = function(options) { var largeCharOffset = 6; function resetChars(char, HLPrev, typePadding, heightDivisor, rowColor) { - "ram" + "ram"; // Small character in list g.setColor(rowColor); g.setFont(SMALLFONT); @@ -80,7 +80,7 @@ exports.input = function(options) { // mark in the list } function showChars(char, HL, typePadding, heightDivisor) { - "ram" + "ram"; // mark in the list g.setColor(HLCOLOR); g.setFont(SMALLFONT); @@ -120,7 +120,7 @@ exports.input = function(options) { resolve(text); }, drag: function(event) { - "ram" + "ram"; // ABCDEFGHIJKLMNOPQRSTUVWXYZ // Choose character by draging along red rectangle at bottom of screen if (event.y >= ( (R.y+R.h) - 12 )) { From e3c0ce299869fe3cda84d8d865a1563384064630 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:25:04 +0100 Subject: [PATCH 25/36] move "ram" to drag-function --- apps/kbswipe/lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/kbswipe/lib.js b/apps/kbswipe/lib.js index fc9704850..fe5f7e977 100644 --- a/apps/kbswipe/lib.js +++ b/apps/kbswipe/lib.js @@ -5,7 +5,6 @@ Bangle.on('stroke',print) on the left of the IDE, then do a stroke and copy out the Uint8Array line */ exports.getStrokes = function(cb) { - "ram"; cb("a", new Uint8Array([58, 159, 58, 155, 62, 144, 69, 127, 77, 106, 86, 90, 94, 77, 101, 68, 108, 62, 114, 59, 121, 59, 133, 61, 146, 70, 158, 88, 169, 107, 176, 124, 180, 135, 183, 144, 185, 152])); cb("b", new Uint8Array([51, 47, 51, 77, 56, 123, 60, 151, 65, 163, 68, 164, 68, 144, 67, 108, 67, 76, 72, 43, 104, 51, 121, 74, 110, 87, 109, 95, 131, 117, 131, 140, 109, 152, 88, 157])); cb("c", new Uint8Array([153, 62, 150, 62, 145, 62, 136, 62, 123, 62, 106, 65, 85, 70, 65, 75, 50, 82, 42, 93, 37, 106, 36, 119, 36, 130, 40, 140, 49, 147, 61, 153, 72, 156, 85, 157, 106, 158, 116, 158])); @@ -140,6 +139,7 @@ exports.getStrokes( (id,s) => Bangle.strokes[id] = Unistroke.new(s) ); return new Promise((resolve,reject) => { var l;//last event Bangle.setUI({mode:"custom", drag:e=>{ + "ram"; if (l) g.reset().setColor("#f00").drawLine(l.x,l.y,e.x,e.y); l = e.b ? e : 0; },touch:() => { From 55389ae680c52730b61e2c0c0dcf40578516cf4d Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:27:40 +0100 Subject: [PATCH 26/36] Update ChangeLog --- apps/kbswipe/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/kbswipe/ChangeLog b/apps/kbswipe/ChangeLog index 49f532b54..1804c4a89 100644 --- a/apps/kbswipe/ChangeLog +++ b/apps/kbswipe/ChangeLog @@ -2,4 +2,4 @@ 0.02: Now keeps user input trace intact by changing how the screen is updated. 0.03: Positioning of marker now takes the height of the widget field into account. 0.04: Fix issue if going back without typing. -0.05: Keep in ram for improved performance and input reliability. +0.05: Keep drag-function in ram, hopefully improving performance and input reliability somewhat. From 1187af38377e4da180f642e528376df1118a8235 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:12:23 +0100 Subject: [PATCH 27/36] set light theme to force white widget bar --- apps/torch/app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/torch/app.js b/apps/torch/app.js index 4f44faf69..1bc8944ad 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -11,6 +11,7 @@ Bangle.setLCDBrightness(1); Bangle.setLCDPower(1); Bangle.setLCDTimeout(0); g.reset(); +g.setTheme({bg:"#fff",fg:"#000"}) g.setColor(settings.bg); g.fillRect(0,0,g.getWidth(),g.getHeight()); Bangle.setUI({ From 9d2be74bc463791a452af518bdb8ea39b687a097 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:14:13 +0100 Subject: [PATCH 28/36] Update ChangeLog --- apps/torch/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/torch/ChangeLog b/apps/torch/ChangeLog index 0ece0538f..d851c242a 100644 --- a/apps/torch/ChangeLog +++ b/apps/torch/ChangeLog @@ -5,3 +5,4 @@ 0.05: Default full Brightness 0.06: Press upper left corner to exit on Bangle.js 2 0.07: Code tweaks +0.08: Force white background for widgetbar From 4de39617c1d1cb111dea34637bba4ffa962daaf2 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:14:36 +0100 Subject: [PATCH 29/36] Update metadata.json --- apps/torch/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/metadata.json b/apps/torch/metadata.json index 88329eb44..aff8dee37 100644 --- a/apps/torch/metadata.json +++ b/apps/torch/metadata.json @@ -2,7 +2,7 @@ "id": "torch", "name": "Torch", "shortName": "Torch", - "version": "0.07", + "version": "0.08", "description": "Turns screen white to help you see in the dark. Select from the launcher or press BTN1,BTN3,BTN1,BTN3 quickly to start when in any app that shows widgets on Bangle.js 1. You can also set the color through the app's setting menu.", "icon": "app.png", "tags": "tool,torch", From ab24b214e068179641575f4b9269c171d78e03e7 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:19:53 +0100 Subject: [PATCH 30/36] widget bar follows settings colour --- apps/torch/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index 1bc8944ad..8d9205784 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -11,7 +11,7 @@ Bangle.setLCDBrightness(1); Bangle.setLCDPower(1); Bangle.setLCDTimeout(0); g.reset(); -g.setTheme({bg:"#fff",fg:"#000"}) +g.setTheme({settings.bg,fg:"#000"}) g.setColor(settings.bg); g.fillRect(0,0,g.getWidth(),g.getHeight()); Bangle.setUI({ From 22c27b7d1d17ece9f175273230a34ffb25bdce8d Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:21:16 +0100 Subject: [PATCH 31/36] Update ChangeLog --- apps/torch/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/ChangeLog b/apps/torch/ChangeLog index d851c242a..27d880e78 100644 --- a/apps/torch/ChangeLog +++ b/apps/torch/ChangeLog @@ -5,4 +5,4 @@ 0.05: Default full Brightness 0.06: Press upper left corner to exit on Bangle.js 2 0.07: Code tweaks -0.08: Force white background for widgetbar +0.08: Force background of widget field to the torch colour From 7888824e691bb772d1cd78ff1d880d279be1a69c Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:22:19 +0100 Subject: [PATCH 32/36] Update app.js --- apps/torch/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index 8d9205784..44a343db9 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -11,7 +11,7 @@ Bangle.setLCDBrightness(1); Bangle.setLCDPower(1); Bangle.setLCDTimeout(0); g.reset(); -g.setTheme({settings.bg,fg:"#000"}) +g.setTheme({bg:settings.bg,fg:"#000"}) g.setColor(settings.bg); g.fillRect(0,0,g.getWidth(),g.getHeight()); Bangle.setUI({ From 4758d2b71f65050ef3e9edd300a021e6d1c01b96 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:26:49 +0100 Subject: [PATCH 33/36] Update app.js --- apps/torch/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/torch/app.js b/apps/torch/app.js index 44a343db9..e3f1ab89c 100644 --- a/apps/torch/app.js +++ b/apps/torch/app.js @@ -11,7 +11,7 @@ Bangle.setLCDBrightness(1); Bangle.setLCDPower(1); Bangle.setLCDTimeout(0); g.reset(); -g.setTheme({bg:settings.bg,fg:"#000"}) +g.setTheme({bg:settings.bg,fg:"#000"}); g.setColor(settings.bg); g.fillRect(0,0,g.getWidth(),g.getHeight()); Bangle.setUI({ From 2aa0bc88eb116b31f5a3777eb16a4689a9cd5459 Mon Sep 17 00:00:00 2001 From: Marco H Date: Wed, 9 Nov 2022 20:29:14 +0100 Subject: [PATCH 34/36] Add configuration --- apps/slopeclockpp/ChangeLog | 3 +- apps/slopeclockpp/app.js | 37 ++++++++++++++----- apps/slopeclockpp/default.json | 10 ++++++ apps/slopeclockpp/metadata.json | 13 ++++--- apps/slopeclockpp/settings.js | 64 +++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 apps/slopeclockpp/default.json create mode 100644 apps/slopeclockpp/settings.js diff --git a/apps/slopeclockpp/ChangeLog b/apps/slopeclockpp/ChangeLog index 5560f00bc..aef4d7324 100644 --- a/apps/slopeclockpp/ChangeLog +++ b/apps/slopeclockpp/ChangeLog @@ -1 +1,2 @@ -0.01: New App! +0.01: Clone of original SlopeClock +0.02: Added configuration diff --git a/apps/slopeclockpp/app.js b/apps/slopeclockpp/app.js index 25fd307eb..497d4a4c9 100644 --- a/apps/slopeclockpp/app.js +++ b/apps/slopeclockpp/app.js @@ -11,6 +11,12 @@ Graphics.prototype.setFontPaytoneOne = function(scale) { { // must be inside our own scope here so that when we are unloaded everything disappears // we also define functions using 'let fn = function() {..}' for the same reason. function decls are global + +let settings = Object.assign( + require("Storage").readJSON("slopeclockpp.default.json", true) || {}, + require("Storage").readJSON("slopeclockpp.json", true) || {} +); + let drawTimeout; let g2 = Graphics.createArrayBuffer(g.getWidth(),90,1,{msb:true}); @@ -24,7 +30,16 @@ const fontBorder = 4; // offset from left/right const slopeBorder = 10, slopeBorderUpper = 4; // fudge-factor to move minutes down from slope let R,x,y; // middle of the clock face let dateStr = ""; -let bgColors = g.theme.dark ? ["#ff0","#0ff","#f0f"] : ["#f00","#0f0","#00f"]; +let bgColors = []; +if (g.theme.dark) { + if (settings.colorYellow) bgColors.push("#ff0"); + if (settings.colorCyan) bgColors.push("#0ff"); + if (settings.colorMagenta) bgColors.push("#f0f"); +} else { + if (settings.colorRed) bgColors.push("#f00"); + if (settings.colorGreen) bgColors.push("#0f0"); + if (settings.colorBlue) bgColors.push("#00f"); +} let bgColor = bgColors[(Math.random()*bgColors.length)|0]; @@ -95,19 +110,23 @@ let animate = function(isIn, callback) { // draw the date g.setColor(g.theme.bg).setFontAlign(0, 0).setFont("6x15").drawString(dateStr, R.x + R.w/2, R.y+R.h-9); + if (settings.showSteps || true) { // draw steps to bottom left const steps = getSteps(); if (steps > 0) g.setFontAlign(-1, 0).drawString(shortValue(steps), 3, R.y+R.h-30); + } - // draw weather to top right - const weather = getWeather(); - const tempString = weather ? require("locale").temp(weather.temp - 273.15) : undefined; - const code = weather ? weather.code : -1; - if (code > -1) { - g.setColor(g.theme.fg).setFontAlign(1, 0).drawString(tempString, R.w - 3, y-slope-slopeBorderUpper); - const icon = getWeatherIconByCode(code); - if (icon) g.drawImage(icon, R.w - 3 - 15, y-slope-slopeBorderUpper - 15 - 15); + if (settings.showWeather || true) { + // draw weather to top right + const weather = getWeather(); + const tempString = weather ? require("locale").temp(weather.temp - 273.15) : undefined; + const code = weather ? weather.code : -1; + if (code > -1) { + g.setColor(g.theme.fg).setFontAlign(1, 0).drawString(tempString, R.w - 3, y-slope-slopeBorderUpper); + const icon = getWeatherIconByCode(code); + if (icon) g.drawImage(icon, R.w - 3 - 15, y-slope-slopeBorderUpper - 15 - 15); + } } } if (callback) callback(); diff --git a/apps/slopeclockpp/default.json b/apps/slopeclockpp/default.json new file mode 100644 index 000000000..448d64f6a --- /dev/null +++ b/apps/slopeclockpp/default.json @@ -0,0 +1,10 @@ +{ + "showSteps": true, + "showWeather": true, + "colorRed": true, + "colorGreen": true, + "colorBlue": true, + "colorYellow": true, + "colorMagenta": true, + "colorCyan": true +} diff --git a/apps/slopeclockpp/metadata.json b/apps/slopeclockpp/metadata.json index 9e28424a8..fc6d3e415 100644 --- a/apps/slopeclockpp/metadata.json +++ b/apps/slopeclockpp/metadata.json @@ -1,7 +1,7 @@ { "id": "slopeclockpp", "name": "Slope Clock ++", - "version":"0.01", - "description": "A clock where hours and minutes are divided by a sloping line. When the minute changes, the numbers slide off the screen. This is a clone of the original Slope Clock which shows weather and steps.", + "version":"0.02", + "description": "A clock where hours and minutes are divided by a sloping line. When the minute changes, the numbers slide off the screen. This is a clone of the original Slope Clock which can show the weather and steps.", "icon": "app.png", "screenshots": [{"url":"screenshot.png"}], "type": "clock", @@ -9,6 +9,11 @@ "supports" : ["BANGLEJS2"], "storage": [ {"name":"slopeclockpp.app.js","url":"app.js"}, - {"name":"slopeclockpp.img","url":"app-icon.js","evaluate":true} - ] + {"name":"slopeclockpp.img","url":"app-icon.js","evaluate":true}, + {"name":"slopeclockpp.settings.js","url":"settings.js"}, + {"name":"slopeclockpp.default.json","url":"default.json"} + ], + "data": [ + {"name":"slopeclockpp.json"} + ] } diff --git a/apps/slopeclockpp/settings.js b/apps/slopeclockpp/settings.js new file mode 100644 index 000000000..8e26a4aa9 --- /dev/null +++ b/apps/slopeclockpp/settings.js @@ -0,0 +1,64 @@ +(function(back) { + const SETTINGS_FILE = "slopclockpp.json"; + const storage = require('Storage'); + let settings = Object.assign( + storage.readJSON("slopclockpp.default.json", true) || {}, + storage.readJSON(SETTINGS_FILE, true) || {} + ); + + function save(key, value) { + settings[key] = value; + storage.write(SETTINGS_FILE, settings); + } + + function showMainMenu() { + let menu ={ + '': { 'title': 'Slope Clock ++' }, + /*LANG*/'< Back': back, + /*LANG*/'show steps': { + value: !!settings.showSteps, + format: () => (settings.showSteps ? 'Yes' : 'No'), + onchange: x => save('showSteps', x), + }, + /*LANG*/'show weather': { + value: !!settings.showWeather, + format: () => (settings.showWeather ? 'Yes' : 'No'), + onchange: x => save('showWeather', x), + }, + /*LANG*/'red': { + value: !!settings.colorRed, + format: () => (settings.colorRed ? 'Yes' : 'No'), + onchange: x => save('colorRed', x), + }, + /*LANG*/'green': { + value: !!settings.colorGreen, + format: () => (settings.colorGreen ? 'Yes' : 'No'), + onchange: x => save('colorGreen', x), + }, + /*LANG*/'blue': { + value: !!settings.colorBlue, + format: () => (settings.colorBlue ? 'Yes' : 'No'), + onchange: x => save('colorBlue', x), + }, + /*LANG*/'magenta': { + value: !!settings.colorMagenta, + format: () => (settings.colorMagenta ? 'Yes' : 'No'), + onchange: x => save('colorMagenta', x), + }, + /*LANG*/'cyan': { + value: !!settings.colorCyan, + format: () => (settings.colorCyan ? 'Yes' : 'No'), + onchange: x => save('colorCyan', x), + }, + /*LANG*/'yellow': { + value: !!settings.colorYellow, + format: () => (settings.colorYellow ? 'Yes' : 'No'), + onchange: x => save('colorYellow', x), + } + }; + E.showMenu(menu); + } + + + showMainMenu(); +}); From 746d59520bf334b363793d253959c6bf1459a653 Mon Sep 17 00:00:00 2001 From: Marco H Date: Wed, 9 Nov 2022 20:38:15 +0100 Subject: [PATCH 35/36] Fix settings --- apps/slopeclockpp/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/slopeclockpp/settings.js b/apps/slopeclockpp/settings.js index 8e26a4aa9..a9319cd99 100644 --- a/apps/slopeclockpp/settings.js +++ b/apps/slopeclockpp/settings.js @@ -1,8 +1,8 @@ (function(back) { - const SETTINGS_FILE = "slopclockpp.json"; + const SETTINGS_FILE = "slopeclockpp.json"; const storage = require('Storage'); let settings = Object.assign( - storage.readJSON("slopclockpp.default.json", true) || {}, + storage.readJSON("slopeclockpp.default.json", true) || {}, storage.readJSON(SETTINGS_FILE, true) || {} ); From 0567e45fb8417c9b3a4c7b5731a2ec7b2e20bde7 Mon Sep 17 00:00:00 2001 From: Marco H Date: Wed, 9 Nov 2022 20:50:19 +0100 Subject: [PATCH 36/36] Fix weather and step setting reading --- apps/slopeclockpp/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/slopeclockpp/app.js b/apps/slopeclockpp/app.js index 497d4a4c9..96648dd54 100644 --- a/apps/slopeclockpp/app.js +++ b/apps/slopeclockpp/app.js @@ -110,14 +110,14 @@ let animate = function(isIn, callback) { // draw the date g.setColor(g.theme.bg).setFontAlign(0, 0).setFont("6x15").drawString(dateStr, R.x + R.w/2, R.y+R.h-9); - if (settings.showSteps || true) { + if (settings.showSteps) { // draw steps to bottom left const steps = getSteps(); if (steps > 0) g.setFontAlign(-1, 0).drawString(shortValue(steps), 3, R.y+R.h-30); } - if (settings.showWeather || true) { + if (settings.showWeather) { // draw weather to top right const weather = getWeather(); const tempString = weather ? require("locale").temp(weather.temp - 273.15) : undefined;