|
10 | 10 | if (global.__FILE__=="messagegui.new.js") { |
11 | 11 | onTwistEmitDrag(); |
12 | 12 | } |
13 | | - },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. |
| 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. |
14 | 19 | }}); |
15 | 20 |
|
16 | 21 | // twistThreshold How much acceleration to register a twist of the watch strap? Can be negative for opposite direction. default = 800 |
17 | 22 | // twistMaxY Maximum acceleration in Y to trigger a twist (low Y means watch is facing the right way up). default = -800 |
18 | 23 | // twistTimeout How little time (in ms) must a twist take from low->high acceleration? default = 1000 |
19 | 24 | function onTwistEmitDrag() { |
20 | 25 | Bangle.setOptions({twistThreshold:2500, twistMaxY:-800, twistTimeout:400}); |
21 | | - Bangle.on("twist", ()=>{ |
| 26 | + let twistHandler = ()=>{ |
22 | 27 | Bangle.setLocked(false); |
23 | 28 | Bangle.setLCDPower(true); |
| 29 | + Bangle.emit("swipe",0,-1); |
24 | 30 | let i = 25; |
25 | 31 | const int = setInterval(() => { |
26 | 32 | Bangle.emit("drag", {dy:-3}) |
27 | 33 | i--; |
28 | 34 | if (i<1) clearInterval(int); |
29 | 35 | }, 10); |
30 | | - }); |
| 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 | + ) |
31 | 50 |
|
32 | 51 | } |
33 | 52 | } |
0 commit comments