From 90b440e635ace58b3ed9de7bb822421779483f7a Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 11 Jan 2025 21:16:23 +0100 Subject: [PATCH 01/10] msgtwscr: new app! Temporarily activate scroll on twist function when a new message triggers the message app. --- apps/msgtwscr/ChangeLog | 1 + apps/msgtwscr/README.md | 19 +++++++++++++++++++ apps/msgtwscr/app.png | Bin 0 -> 1466 bytes apps/msgtwscr/boot.js | 31 +++++++++++++++++++++++++++++++ apps/msgtwscr/metadata.json | 13 +++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 apps/msgtwscr/ChangeLog create mode 100644 apps/msgtwscr/README.md create mode 100644 apps/msgtwscr/app.png create mode 100644 apps/msgtwscr/boot.js create mode 100644 apps/msgtwscr/metadata.json diff --git a/apps/msgtwscr/ChangeLog b/apps/msgtwscr/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/msgtwscr/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/msgtwscr/README.md b/apps/msgtwscr/README.md new file mode 100644 index 000000000..e97b8b2f1 --- /dev/null +++ b/apps/msgtwscr/README.md @@ -0,0 +1,19 @@ +# Message Scroll on Twist + +Temporarily activate scroll on twist function when a new message triggers the message app. This way it's possible to scroll through a message in the message scroller hands free. + +## Usage + +This is a bootloader app and only needs to be installed to add the functionality to the watch. + +## Notes + +Tried with [a development version "Message UI" app](https://github.com/espruino/BangleApps/pull/3685) centered around the message scroller. Should work with the standard version as well. + +## Requests + +Mention @thyttan in an issue on the espruino/BangleApps repository. + +## Creator + +thyttan diff --git a/apps/msgtwscr/app.png b/apps/msgtwscr/app.png new file mode 100644 index 0000000000000000000000000000000000000000..83d7e9add5396af12aa2b860375291aea1507a30 GIT binary patch literal 1466 zcmV;r1x5OaP)L8%qoKz;CEPmD*nSzLYFL?6DI{Vw)shTeX#9egKdnMBvO@of#)F*fBPC z9OsiB${20NIg5npF%qT>;%qCk-wISbVFnT=Ai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Hnj7Cymt_eULR~d9%1>M z>vI0X)LV6X25!3ghSBSzj0oa%+0f35@?La0d(mO*!MRSy4@|vPmuujV!`=Ua3R9d^ z+}$rMn@#!i_8y$GI$pH5J3e9Rv20F{-R|{if (Bangle.CLOCK && msg.new) { + setTimeout(()=>{ + if (global.__FILE__=="messagegui.new.js") { + onTwistEmitDrag(); + } + },700) // It feels like there's a more elegant solution than checking the filename after 700 milliseconds. But this at least seems to work w/o sometimes activating when it shouldn't. + }}); + + // twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800 + // twistMaxY Maximum acceleration in Y to trigger a twist (low Y means watch is facing the right way up). default = -800 + // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000 + function onTwistEmitDrag() { + Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); + Bangle.on("twist", ()=>{ + let i = 25; + const int = setInterval(() => { + Bangle.emit("drag", {dy:-3}) + i--; + if (i<1) clearInterval(int); + }, 10); + }); + + } +} diff --git a/apps/msgtwscr/metadata.json b/apps/msgtwscr/metadata.json new file mode 100644 index 000000000..0bd79e55a --- /dev/null +++ b/apps/msgtwscr/metadata.json @@ -0,0 +1,13 @@ +{ "id": "msgtwscr", + "name": "Message Scroll on Twist", + "version":"0.01", + "description": "Temporarily activate scroll on twist function when a new message triggers the message app.", + "icon": "app.png", + "tags": "messages,tweak, scroll", + "type": "bootloader", + "supports" : ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"msgtwscr.boot.js","url":"boot.js"} + ] +} From 4a60ee4f8ecef8cc3fc0028865d927902c38f1c5 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Tue, 21 Jan 2025 21:49:16 +0100 Subject: [PATCH 02/10] msgtwscr: tweak app name. --- apps/msgtwscr/README.md | 2 +- apps/msgtwscr/metadata.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/msgtwscr/README.md b/apps/msgtwscr/README.md index e97b8b2f1..2fbdda240 100644 --- a/apps/msgtwscr/README.md +++ b/apps/msgtwscr/README.md @@ -1,4 +1,4 @@ -# Message Scroll on Twist +# Message Twist to Scroll Temporarily activate scroll on twist function when a new message triggers the message app. This way it's possible to scroll through a message in the message scroller hands free. diff --git a/apps/msgtwscr/metadata.json b/apps/msgtwscr/metadata.json index 0bd79e55a..5bf1e9736 100644 --- a/apps/msgtwscr/metadata.json +++ b/apps/msgtwscr/metadata.json @@ -1,5 +1,5 @@ { "id": "msgtwscr", - "name": "Message Scroll on Twist", + "name": "Message Twist to Scroll", "version":"0.01", "description": "Temporarily activate scroll on twist function when a new message triggers the message app.", "icon": "app.png", From 3ff442700baa45fcaf210373be7b9bb5e5afcd2c Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 15 Feb 2025 03:25:46 +0100 Subject: [PATCH 03/10] msgtwscr: fix formatting of metadata tags --- apps/msgtwscr/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/msgtwscr/metadata.json b/apps/msgtwscr/metadata.json index 5bf1e9736..6f267ea01 100644 --- a/apps/msgtwscr/metadata.json +++ b/apps/msgtwscr/metadata.json @@ -3,7 +3,7 @@ "version":"0.01", "description": "Temporarily activate scroll on twist function when a new message triggers the message app.", "icon": "app.png", - "tags": "messages,tweak, scroll", + "tags": "messages,tweak,scroll", "type": "bootloader", "supports" : ["BANGLEJS2"], "readme": "README.md", From c51919045b7a18bb4434608303a59ce5e8ed307f Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Sat, 15 Feb 2025 03:42:00 +0100 Subject: [PATCH 04/10] msgtwscr: unlock the watch on twist as well Maybe implement this in a separate app instead. --- apps/msgtwscr/boot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/msgtwscr/boot.js b/apps/msgtwscr/boot.js index 821561bdc..22bc03bcc 100644 --- a/apps/msgtwscr/boot.js +++ b/apps/msgtwscr/boot.js @@ -19,6 +19,8 @@ function onTwistEmitDrag() { Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); Bangle.on("twist", ()=>{ + Bangle.setLocked(false); + Bangle.setLCDPower(true); let i = 25; const int = setInterval(() => { Bangle.emit("drag", {dy:-3}) From 1b88dd2d196320aae84358a35ee2cdecb579d981 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Mon, 26 May 2025 23:55:03 +0200 Subject: [PATCH 05/10] msgtwscr: tweak to work with recent messagegui updates --- apps/msgtwscr/boot.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/msgtwscr/boot.js b/apps/msgtwscr/boot.js index 22bc03bcc..714aa0cbc 100644 --- a/apps/msgtwscr/boot.js +++ b/apps/msgtwscr/boot.js @@ -10,7 +10,12 @@ if (global.__FILE__=="messagegui.new.js") { onTwistEmitDrag(); } - },700) // It feels like there's a more elegant solution than checking the filename after 700 milliseconds. But this at least seems to work w/o sometimes activating when it shouldn't. + },1000) + // It feels like there's a more elegant solution than checking the filename + // after 1000 milliseconds. But this at least seems to work w/o sometimes + // activating when it shouldn't. + // Maybe we could add events for when fast load and/or Bangle.uiRemove occurs? + // Then that could be used similarly to boot code and/or the `kill` event. }}); // twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800 @@ -18,16 +23,30 @@ // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000 function onTwistEmitDrag() { Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); - Bangle.on("twist", ()=>{ + let twistHandler = ()=>{ Bangle.setLocked(false); Bangle.setLCDPower(true); + Bangle.emit("swipe",0,-1); let i = 25; const int = setInterval(() => { Bangle.emit("drag", {dy:-3}) i--; if (i<1) clearInterval(int); }, 10); - }); + } + Bangle.on("twist", twistHandler); + // Give messagegui some extra time to add its remove function to + // Bangle.uiRemove, then attach msgtwscr remove logic. + setTimeout( + ()=>{if (Bangle.uiRemove) { + let showMessageUIRemove = Bangle.uiRemove; + Bangle.uiRemove = function () { + Bangle.removeListener("twist", twistHandler) + showMessageUIRemove(); + } + }}, + 500 + ) } } From 591c0efd4043387108dd67c5684777347ec930b8 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Tue, 27 May 2025 00:06:49 +0200 Subject: [PATCH 06/10] msgtwscr: rm out of date README section --- apps/msgtwscr/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/msgtwscr/README.md b/apps/msgtwscr/README.md index 2fbdda240..ea92ce76f 100644 --- a/apps/msgtwscr/README.md +++ b/apps/msgtwscr/README.md @@ -6,10 +6,6 @@ Temporarily activate scroll on twist function when a new message triggers the me This is a bootloader app and only needs to be installed to add the functionality to the watch. -## Notes - -Tried with [a development version "Message UI" app](https://github.com/espruino/BangleApps/pull/3685) centered around the message scroller. Should work with the standard version as well. - ## Requests Mention @thyttan in an issue on the espruino/BangleApps repository. From 79e7f634f533bc40e81e91746d482d1aa2fad385 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Tue, 27 May 2025 00:09:07 +0200 Subject: [PATCH 07/10] msgtwscr: rebalance timeouts --- apps/msgtwscr/boot.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/msgtwscr/boot.js b/apps/msgtwscr/boot.js index 714aa0cbc..0a7923c05 100644 --- a/apps/msgtwscr/boot.js +++ b/apps/msgtwscr/boot.js @@ -10,9 +10,9 @@ if (global.__FILE__=="messagegui.new.js") { onTwistEmitDrag(); } - },1000) + },700) // It feels like there's a more elegant solution than checking the filename - // after 1000 milliseconds. But this at least seems to work w/o sometimes + // after 700 milliseconds. But this at least seems to work w/o sometimes // activating when it shouldn't. // Maybe we could add events for when fast load and/or Bangle.uiRemove occurs? // Then that could be used similarly to boot code and/or the `kill` event. @@ -45,8 +45,6 @@ showMessageUIRemove(); } }}, - 500 - ) - + 800) } } From 7608697377101ee47f0c79dac9cb78c5073cc39d Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Tue, 27 May 2025 00:50:12 +0200 Subject: [PATCH 08/10] msgtwscr: adapt to the recent messagegui updates --- apps/msgtwscr/boot.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/apps/msgtwscr/boot.js b/apps/msgtwscr/boot.js index 0a7923c05..fa4e4edd6 100644 --- a/apps/msgtwscr/boot.js +++ b/apps/msgtwscr/boot.js @@ -4,8 +4,7 @@ onTwistEmitDrag(); } - // If Fastload Utils is installed this is used: - Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) { + let attachAfterTimeout = ()=>{ setTimeout(()=>{ if (global.__FILE__=="messagegui.new.js") { onTwistEmitDrag(); @@ -16,6 +15,11 @@ // activating when it shouldn't. // Maybe we could add events for when fast load and/or Bangle.uiRemove occurs? // Then that could be used similarly to boot code and/or the `kill` event. + } + + // If Fastload Utils is installed this is used: + Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) { + attachAfterTimeout(); }}); // twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800 @@ -23,16 +27,22 @@ // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000 function onTwistEmitDrag() { Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); + let isTwistDragging = false; let twistHandler = ()=>{ - Bangle.setLocked(false); - Bangle.setLCDPower(true); - Bangle.emit("swipe",0,-1); - let i = 25; - const int = setInterval(() => { - Bangle.emit("drag", {dy:-3}) - i--; - if (i<1) clearInterval(int); - }, 10); + if (!isTwistDragging) { + isTwistDragging = true; + Bangle.setLocked(false); + Bangle.setLCDPower(true); + let i = 25; + const int = setInterval(() => { + Bangle.emit("drag", {dy:-3, b:i===0?0:1}) + i--; + if (i<0) { + clearInterval(int); + isTwistDragging = false; + } + }, 10); + } } Bangle.on("twist", twistHandler); // Give messagegui some extra time to add its remove function to @@ -43,6 +53,8 @@ Bangle.uiRemove = function () { Bangle.removeListener("twist", twistHandler) showMessageUIRemove(); + // Reset twist drag logic if we go to next message. + attachAfterTimeout(); } }}, 800) From fb9c4173ff8f65329148a1fe544698af93e31b49 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Tue, 24 Jun 2025 11:23:09 +0200 Subject: [PATCH 09/10] msgtwscr: fix function used before declared --- apps/msgtwscr/boot.js | 47 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/apps/msgtwscr/boot.js b/apps/msgtwscr/boot.js index fa4e4edd6..2b3884d2e 100644 --- a/apps/msgtwscr/boot.js +++ b/apps/msgtwscr/boot.js @@ -1,27 +1,4 @@ { - // If doing regular loads, not Bangle.load, this is used: - if (global.__FILE__=="messagegui.new.js") { - onTwistEmitDrag(); - } - - let attachAfterTimeout = ()=>{ - setTimeout(()=>{ - if (global.__FILE__=="messagegui.new.js") { - onTwistEmitDrag(); - } - },700) - // It feels like there's a more elegant solution than checking the filename - // after 700 milliseconds. But this at least seems to work w/o sometimes - // activating when it shouldn't. - // Maybe we could add events for when fast load and/or Bangle.uiRemove occurs? - // Then that could be used similarly to boot code and/or the `kill` event. - } - - // If Fastload Utils is installed this is used: - Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) { - attachAfterTimeout(); - }}); - // twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800 // twistMaxY Maximum acceleration in Y to trigger a twist (low Y means watch is facing the right way up). default = -800 // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000 @@ -59,4 +36,28 @@ }}, 800) } + + // If doing regular loads, not Bangle.load, this is used: + if (global.__FILE__=="messagegui.new.js") { + onTwistEmitDrag(); + } + + let attachAfterTimeout = ()=>{ + setTimeout(()=>{ + if (global.__FILE__=="messagegui.new.js") { + onTwistEmitDrag(); + } + },700) + // It feels like there's a more elegant solution than checking the filename + // after 700 milliseconds. But this at least seems to work w/o sometimes + // activating when it shouldn't. + // Maybe we could add events for when fast load and/or Bangle.uiRemove occurs? + // Then that could be used similarly to boot code and/or the `kill` event. + } + + // If Fastload Utils is installed this is used: + Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) { + attachAfterTimeout(); + }}); + } From c6b1c0c1e6b1f7920ec1e07cf384fc0e045e70e4 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Tue, 24 Jun 2025 11:31:33 +0200 Subject: [PATCH 10/10] msgtwscr: don't pollute global scope --- apps/msgtwscr/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/msgtwscr/boot.js b/apps/msgtwscr/boot.js index 2b3884d2e..4b43102a9 100644 --- a/apps/msgtwscr/boot.js +++ b/apps/msgtwscr/boot.js @@ -2,7 +2,7 @@ // twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800 // twistMaxY Maximum acceleration in Y to trigger a twist (low Y means watch is facing the right way up). default = -800 // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000 - function onTwistEmitDrag() { + let onTwistEmitDrag = ()=>{ Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); let isTwistDragging = false; let twistHandler = ()=>{