msgtwscr: tweak to work with recent messagegui updates

master
thyttan 2025-05-26 23:55:03 +02:00
parent c51919045b
commit 1b88dd2d19
1 changed files with 22 additions and 3 deletions

View File

@ -10,7 +10,12 @@
if (global.__FILE__=="messagegui.new.js") { if (global.__FILE__=="messagegui.new.js") {
onTwistEmitDrag(); 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 // 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 // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000
function onTwistEmitDrag() { function onTwistEmitDrag() {
Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400});
Bangle.on("twist", ()=>{ let twistHandler = ()=>{
Bangle.setLocked(false); Bangle.setLocked(false);
Bangle.setLCDPower(true); Bangle.setLCDPower(true);
Bangle.emit("swipe",0,-1);
let i = 25; let i = 25;
const int = setInterval(() => { const int = setInterval(() => {
Bangle.emit("drag", {dy:-3}) Bangle.emit("drag", {dy:-3})
i--; i--;
if (i<1) clearInterval(int); if (i<1) clearInterval(int);
}, 10); }, 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
)
} }
} }