Skip to content

Commit f5fd600

Browse files
author
thyttan
committed
Merge branch 'msgtwistscroll' into app-loader
2 parents 2c3168f + 1b88dd2 commit f5fd600

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

apps/msgtwscr/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.01: New App!

apps/msgtwscr/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Message Twist to Scroll
2+
3+
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.
4+
5+
## Usage
6+
7+
This is a bootloader app and only needs to be installed to add the functionality to the watch.
8+
9+
## Notes
10+
11+
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.
12+
13+
## Requests
14+
15+
Mention @thyttan in an issue on the espruino/BangleApps repository.
16+
17+
## Creator
18+
19+
thyttan

apps/msgtwscr/app.png

1.43 KB
Loading

apps/msgtwscr/boot.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
// If doing regular loads, not Bangle.load, this is used:
3+
if (global.__FILE__=="messagegui.new.js") {
4+
onTwistEmitDrag();
5+
}
6+
7+
// If Fastload Utils is installed this is used:
8+
Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) {
9+
setTimeout(()=>{
10+
if (global.__FILE__=="messagegui.new.js") {
11+
onTwistEmitDrag();
12+
}
13+
},1000)
14+
// It feels like there's a more elegant solution than checking the filename
15+
// after 1000 milliseconds. But this at least seems to work w/o sometimes
16+
// activating when it shouldn't.
17+
// Maybe we could add events for when fast load and/or Bangle.uiRemove occurs?
18+
// Then that could be used similarly to boot code and/or the `kill` event.
19+
}});
20+
21+
// twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800
22+
// twistMaxY Maximum acceleration in Y to trigger a twist (low Y means watch is facing the right way up). default = -800
23+
// twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000
24+
function onTwistEmitDrag() {
25+
Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400});
26+
let twistHandler = ()=>{
27+
Bangle.setLocked(false);
28+
Bangle.setLCDPower(true);
29+
Bangle.emit("swipe",0,-1);
30+
let i = 25;
31+
const int = setInterval(() => {
32+
Bangle.emit("drag", {dy:-3})
33+
i--;
34+
if (i<1) clearInterval(int);
35+
}, 10);
36+
}
37+
Bangle.on("twist", twistHandler);
38+
// Give messagegui some extra time to add its remove function to
39+
// Bangle.uiRemove, then attach msgtwscr remove logic.
40+
setTimeout(
41+
()=>{if (Bangle.uiRemove) {
42+
let showMessageUIRemove = Bangle.uiRemove;
43+
Bangle.uiRemove = function () {
44+
Bangle.removeListener("twist", twistHandler)
45+
showMessageUIRemove();
46+
}
47+
}},
48+
500
49+
)
50+
51+
}
52+
}

apps/msgtwscr/metadata.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{ "id": "msgtwscr",
2+
"name": "Message Twist to Scroll",
3+
"version":"0.01",
4+
"description": "Temporarily activate scroll on twist function when a new message triggers the message app.",
5+
"icon": "app.png",
6+
"tags": "messages,tweak,scroll",
7+
"type": "bootloader",
8+
"supports" : ["BANGLEJS2"],
9+
"readme": "README.md",
10+
"storage": [
11+
{"name":"msgtwscr.boot.js","url":"boot.js"}
12+
]
13+
}

0 commit comments

Comments
 (0)