-
Notifications
You must be signed in to change notification settings - Fork 46
Allow other Input implementations #17
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
Conversation
This enables alternative implementations that could, for instance, use ESP touchpads: ``` prv = buttons.touch_0 sel = buttons.touch_1 nxt = buttons.touch_2 class TouchInput: def __init__(self, prv, sel, nxt): self._prev = Touch(prv, 0) self._sel = Touch(sel, 1) self._next = Touch(nxt, 2) self._prev.press_func(Screen.ctrl_move, (_PPREV,)) self._sel.release_func(Screen.sel_ctrl) self._next.press_func(Screen.ctrl_move, (_NNEXT,)) def precision(self, val): Screen.redraw_co() def adj_mode(self, v=None): Screen.redraw_co() def is_adjust(self): return False disp = Display(ssd, input=TouchInput(prv, sel, nxt)) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest passing the Input
class to the constructor rather than an instance, then you wouldn't need to assign defaults to nxt
and sel
:
class Display:
def __init__(self, objssd, nxt, sel, prev=None, incr=None, decr=None, encoder=False, IPClass=None):
global display, ssd
IP = Input if IPCLass is None else IPClass
self.ipdev = IP(nxt, sel, prev, incr, decr, encoder)
This preserves the logic of requiring, as a minimum, nxt
and sel
objects.
My main concern is how to document the creation of user Input
classes, which could be nontrivial.
Thank you for this excellent idea. I've now pushed an alternative implementation. Unlike my previous suggestion this enables alternative input classes without imposing any restrictions on their constructor args. If you wish to offer a complete 5-button solution for ESP32 touchpads I'd be happy to publish it (with credit to yourself, of course). I'm sure such a class would find users. |
Looking at this some more, while I think abstracting the input class is a great idea, I'm not sure it's the simplest approach for the specific case of ESP32 touchpads. [EDIT] to remove heat-related nonsense: I have written a If we were to write a new |
I've pushed an update on branch The |
I have merged the branch and pushed an update. The touchpad interface works fine in my testing and the README.md is updated, so I believe this is complete. I have also updated the async library to support the callback interface for touch pads. Thank you for prompting me to do this. Observations or comments are welcome. |
Hey Peter I've been on holiday and some post-holiday corona recovery. |
Sorry to hear you've been ill. I have been impressed how well the touch interface works, both independently and with the GUI. Good luck with the badges. |
This enables alternative implementations that could, for instance, use
ESP touchpads: