Skip to content

Commit

Permalink
Bangle_setUI_Q3: Make custom btn edge configurable
Browse files Browse the repository at this point in the history
`btn` can be set like before, so backwards compatible I think.
But it can now also be an object on form
{fn: ()={}, edge: "rising/falling/both"}.
@gfwilliams has suggested another solution using callbacks in
espruino/BangleApps#3452 (comment)
The solution I opted for here for now follows the same coding
style of how the `type`/`mode` parameter of setUI can be
either a string or an object.
  • Loading branch information
thyttan committed Jul 1, 2024
1 parent 6567b77 commit 8a3210c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/js/banglejs/Bangle_setUI_Q3.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@
}
if (options.btn) {
if (Bangle.btnWatches) Bangle.btnWatches.forEach(clearWatch);
var e = "falling";
if ("object"==typeof options.btn) {
e = options.btn.edge;
options.btn = options.btn.fn;
}
Bangle.btnWatches = [
setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"})
setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:e})
];
} else if (options.clock) {
Bangle.btnWatches = [
Expand Down

0 comments on commit 8a3210c

Please sign in to comment.