|
33 | 33 | if (!mode) return; |
34 | 34 | if (mode=="updown") { |
35 | 35 | Bangle.btnWatches = [ |
36 | | - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}), |
37 | | - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}), |
38 | | - setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"falling"}) |
| 36 | + setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}), |
| 37 | + setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}), |
| 38 | + setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"rising"}) |
39 | 39 | ]; |
40 | 40 | } else if (mode=="leftright") { |
41 | 41 | Bangle.btnWatches = [ |
42 | | - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}), |
43 | | - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}), |
44 | | - setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"falling"}) |
| 42 | + setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}), |
| 43 | + setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}), |
| 44 | + setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"rising"}) |
45 | 45 | ]; |
46 | 46 | Bangle.swipeHandler = d => {cb(d);}; |
47 | 47 | Bangle.on("swipe", Bangle.swipeHandler); |
|
50 | 50 | } else if (mode=="clock") { |
51 | 51 | Bangle.CLOCK=1; |
52 | 52 | Bangle.btnWatches = [ |
53 | | - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) |
| 53 | + setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"}) |
54 | 54 | ]; |
55 | 55 | } else if (mode=="clockupdown") { |
56 | 56 | Bangle.CLOCK=1; |
57 | 57 | Bangle.btnWatches = [ |
58 | | - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}), |
59 | | - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}), |
60 | | - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) |
| 58 | + setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}), |
| 59 | + setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}), |
| 60 | + setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"}) |
61 | 61 | ]; |
62 | 62 | } else if (mode=="custom") { |
63 | | - if (options.clock) Bangle.CLOCK=1; |
64 | | - if (options.touch) { |
65 | | - Bangle.touchHandler = options.touch; |
66 | | - Bangle.on("touch", Bangle.touchHandler); |
67 | | - } |
68 | | - if (options.swipe) { |
69 | | - Bangle.swipeHandler = options.swipe; |
70 | | - Bangle.on("swipe", Bangle.swipeHandler); |
71 | | - } |
72 | | - if (options.btn || options.btnRelease) { |
73 | | - Bangle.btnWatches = [ |
74 | | - setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}), |
75 | | - setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"falling"}), |
76 | | - setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"falling"}) |
77 | | - ]; |
78 | | - } else if (options.clock) { |
| 63 | + if (options.clock) { |
79 | 64 | Bangle.btnWatches = [ |
80 | | - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) |
| 65 | + setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"}) |
81 | 66 | ]; |
82 | 67 | } |
83 | 68 | } else |
84 | 69 | throw new Error("Unknown UI mode "+E.toJS(mode)); |
| 70 | + if (options.clock) Bangle.CLOCK=1; |
| 71 | + if (options.touch) { |
| 72 | + Bangle.touchHandler = options.touch; |
| 73 | + Bangle.on("touch", Bangle.touchHandler); |
| 74 | + } |
| 75 | + if (options.swipe) { |
| 76 | + Bangle.swipeHandler = options.swipe; |
| 77 | + Bangle.on("swipe", Bangle.swipeHandler); |
| 78 | + } |
| 79 | + if ((options.btn || options.btnRelease) && !Bangle.btnWatches) Bangle.btnWatches = []; |
| 80 | + if (options.btn) Bangle.btnWatches.push( |
| 81 | + setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"rising"}), |
| 82 | + setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"rising"}), |
| 83 | + setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"rising"}) |
| 84 | + ); |
| 85 | + if (options.btnRelease) Bangle.btnWatches.push( |
| 86 | + setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}), |
| 87 | + setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"falling"}), |
| 88 | + setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"falling"}) |
| 89 | + ); |
85 | 90 | if (options.remove) // handler for removing the UI (intervals/etc) |
86 | 91 | Bangle.uiRemove = options.remove; |
87 | 92 | if (options.redraw) // handler for redrawing the UI |
|
96 | 101 | btnWatch = setWatch(function() { |
97 | 102 | btnWatch = undefined; |
98 | 103 | options.back(); |
99 | | - }, BTN3, {edge:"falling"}); |
| 104 | + }, BTN3, {edge:"rising"}); |
100 | 105 | WIDGETS = Object.assign({back:{ |
101 | 106 | area:"tl", width:24, |
102 | 107 | draw:e=>g.reset().setColor("#f00").drawImage(atob("GBiBAAAYAAH/gAf/4A//8B//+D///D///H/P/n+H/n8P/n4f/vwAP/wAP34f/n8P/n+H/n/P/j///D///B//+A//8Af/4AH/gAAYAA=="),e.x,e.y), |
|
0 commit comments