msgtwscr: adapt to the recent messagegui updates

master
thyttan 2025-05-27 00:50:12 +02:00
parent 79e7f634f5
commit 7608697377
1 changed files with 23 additions and 11 deletions

View File

@ -4,8 +4,7 @@
onTwistEmitDrag(); onTwistEmitDrag();
} }
// If Fastload Utils is installed this is used: let attachAfterTimeout = ()=>{
Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) {
setTimeout(()=>{ setTimeout(()=>{
if (global.__FILE__=="messagegui.new.js") { if (global.__FILE__=="messagegui.new.js") {
onTwistEmitDrag(); onTwistEmitDrag();
@ -16,6 +15,11 @@
// activating when it shouldn't. // activating when it shouldn't.
// Maybe we could add events for when fast load and/or Bangle.uiRemove occurs? // 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. // 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 // 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 // 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});
let isTwistDragging = false;
let twistHandler = ()=>{ let twistHandler = ()=>{
Bangle.setLocked(false); if (!isTwistDragging) {
Bangle.setLCDPower(true); isTwistDragging = true;
Bangle.emit("swipe",0,-1); Bangle.setLocked(false);
let i = 25; Bangle.setLCDPower(true);
const int = setInterval(() => { let i = 25;
Bangle.emit("drag", {dy:-3}) const int = setInterval(() => {
i--; Bangle.emit("drag", {dy:-3, b:i===0?0:1})
if (i<1) clearInterval(int); i--;
}, 10); if (i<0) {
clearInterval(int);
isTwistDragging = false;
}
}, 10);
}
} }
Bangle.on("twist", twistHandler); Bangle.on("twist", twistHandler);
// Give messagegui some extra time to add its remove function to // Give messagegui some extra time to add its remove function to
@ -43,6 +53,8 @@
Bangle.uiRemove = function () { Bangle.uiRemove = function () {
Bangle.removeListener("twist", twistHandler) Bangle.removeListener("twist", twistHandler)
showMessageUIRemove(); showMessageUIRemove();
// Reset twist drag logic if we go to next message.
attachAfterTimeout();
} }
}}, }},
800) 800)