Skip to content

Commit

Permalink
Bangle_setUI_F18: (WIP) complete rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
thyttan committed Nov 1, 2024
1 parent cdfb4d6 commit c5fce53
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions libs/js/banglejs/Bangle_setUI_F18.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
if (!mode) return;
if (mode=="updown") {
Bangle.btnWatches = [
setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}),
setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}),
setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"falling"})
setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}),
setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}),
setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"rising"})
];
} else if (mode=="leftright") {
Bangle.btnWatches = [
setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}),
setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}),
setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"falling"})
setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}),
setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}),
setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"rising"})
];
Bangle.swipeHandler = d => {cb(d);};
Bangle.on("swipe", Bangle.swipeHandler);
Expand All @@ -50,38 +50,43 @@
} else if (mode=="clock") {
Bangle.CLOCK=1;
Bangle.btnWatches = [
setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"})
setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"})
];
} else if (mode=="clockupdown") {
Bangle.CLOCK=1;
Bangle.btnWatches = [
setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}),
setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}),
setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"})
setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}),
setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}),
setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"})
];
} else if (mode=="custom") {
if (options.clock) Bangle.CLOCK=1;
if (options.touch) {
Bangle.touchHandler = options.touch;
Bangle.on("touch", Bangle.touchHandler);
}
if (options.swipe) {
Bangle.swipeHandler = options.swipe;
Bangle.on("swipe", Bangle.swipeHandler);
}
if (options.btn || options.btnRelease) {
Bangle.btnWatches = [
setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}),
setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"falling"}),
setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"falling"})
];
} else if (options.clock) {
if (options.clock) {
Bangle.btnWatches = [
setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"})
setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"})
];
}
} else
throw new Error("Unknown UI mode "+E.toJS(mode));
if (options.clock) Bangle.CLOCK=1;
if (options.touch) {
Bangle.touchHandler = options.touch;
Bangle.on("touch", Bangle.touchHandler);
}
if (options.swipe) {
Bangle.swipeHandler = options.swipe;
Bangle.on("swipe", Bangle.swipeHandler);
}
if ((options.btn || options.btnRelease) && !Bangle.btnWatches) Bangle.btnWatches = [];
if (options.btn) Bangle.btnWatches.push(
setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"rising"}),
setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"rising"}),
setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"rising"})
);
if (options.btnRelease) Bangle.btnWatches.push(
setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}),
setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"falling"}),
setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"falling"})
);
if (options.remove) // handler for removing the UI (intervals/etc)
Bangle.uiRemove = options.remove;
if (options.redraw) // handler for redrawing the UI
Expand All @@ -96,7 +101,7 @@
btnWatch = setWatch(function() {
btnWatch = undefined;
options.back();
}, BTN3, {edge:"falling"});
}, BTN3, {edge:"rising"});
WIDGETS = Object.assign({back:{
area:"tl", width:24,
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),
Expand Down

0 comments on commit c5fce53

Please sign in to comment.