Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: Setui proposal preview app #3487

Merged
merged 11 commits into from
Jul 4, 2024

Conversation

thyttan
Copy link
Collaborator

@thyttan thyttan commented Jul 2, 2024

@gfwilliams

Related issues:
#3435
#3452

As proposed here: espruino/Espruino#2526 (comment)

Updated the code on the companion spotrem PR: #3485

Both the setUI change app ( setuichange) and the correspondingly updated spotrem can be installed from my app loader: https://thyttan.github.io/BangleApps/

thyttan added 7 commits July 2, 2024 22:46
To make the ui feel snappier.

First discussed around here:
espruino#3435 (comment)
In addition to `btn` adds `btnRelease` to act on `falling` edge.

Clears button handlers that maybe was set as part of one of the standard
modes before adding the custom button handlers.
apps/setuichange/boot.js Outdated Show resolved Hide resolved
@gfwilliams
Copy link
Member

Thanks! Looks good - just the minor stuff I commented on, and then we can merge it in and post on the forum and see what the response is like

@thyttan thyttan force-pushed the setui-proposal-preview branch 2 times, most recently from a490a86 to 4f116f8 Compare July 3, 2024 20:32
@thyttan thyttan force-pushed the setui-proposal-preview branch from 4f116f8 to eaa2918 Compare July 3, 2024 20:38
@thyttan
Copy link
Collaborator Author

thyttan commented Jul 3, 2024

Here's a diff agains the firmware with changes as they are now:

diff --git a/Espruino/libs/js/banglejs/Bangle_setUI_Q3.js b/BangleApps/apps/setuichange/boot.js
index 3a30c43..dd541e7 100644
--- a/Espruino/libs/js/banglejs/Bangle_setUI_Q3.js
+++ b/BangleApps/apps/setuichange/boot.js
@@ -1,4 +1,4 @@
-(function(mode, cb) {
+Bangle.setUI = (function(mode, cb) {
   var options = {};
   if ("object"==typeof mode) {
     options = mode;
@@ -52,7 +52,7 @@
     Bangle.on('drag',Bangle.dragHandler);
     Bangle.touchHandler = d => {b();cb();};
     Bangle.btnWatches = [
-      setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"falling"}),
+      setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}),
     ];
   } else if (mode=="leftright") {
     var dx = 0;
@@ -68,12 +68,12 @@
     Bangle.on('drag',Bangle.dragHandler);
     Bangle.touchHandler = d => {b();cb();};
     Bangle.btnWatches = [
-      setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"falling"}),
+      setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}),
     ];
   } else if (mode=="clock") {
     Bangle.CLOCK=1;
     Bangle.btnWatches = [
-      setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"})
+      setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"})
     ];
   } else if (mode=="clockupdown") {
     Bangle.CLOCK=1;
@@ -82,31 +82,29 @@
       b();cb((e.y > 88) ? 1 : -1);
     };
     Bangle.btnWatches = [
-      setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"})
+      setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"})
     ];
   } else if (mode=="custom") {
-    if (options.clock) Bangle.CLOCK=1;
-    if (options.touch)
-      Bangle.touchHandler = options.touch;
-    if (options.drag) {
-      Bangle.dragHandler = options.drag;
-      Bangle.on("drag", Bangle.dragHandler);
-    }
-    if (options.swipe) {
-      Bangle.swipeHandler = options.swipe;
-      Bangle.on("swipe", Bangle.swipeHandler);
-    }
-    if (options.btn) {
-      Bangle.btnWatches = [
-        setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"})
-      ];
-    } else if (options.clock) {
+    if (options.clock) {
       Bangle.btnWatches = [
-        setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"})
+        setWatch(Bangle.showLauncher, BTN1, {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;
+  if (options.drag) {
+    Bangle.dragHandler = options.drag;
+    Bangle.on("drag", Bangle.dragHandler);
+  }
+  if (options.swipe) {
+    Bangle.swipeHandler = options.swipe;
+    Bangle.on("swipe", Bangle.swipeHandler);
+  }
+  if (options.btn) Bangle.btnWatches.push(setWatch(options.btn.bind(options), BTN1, {repeat:1,edge:"rising"}))
+  if (options.btnRelease) Bangle.btnWatches.push(setWatch(options.btnRelease.bind(options), BTN1, {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
@@ -133,7 +131,7 @@
     btnWatch = setWatch(function() {
       btnWatch = undefined;
       options.back();
-    }, BTN1, {edge:"falling"});
+    }, BTN1, {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),

@gfwilliams
Copy link
Member

Thanks - this looks great! Merging now

@gfwilliams gfwilliams marked this pull request as ready for review July 4, 2024 10:55
@gfwilliams gfwilliams merged commit 0598ed6 into espruino:master Jul 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants