UI Module w/ Buttons, Checkboxes,... for Display w/ Touchscreen #884
Replies: 3 comments
-
Posted at 2014-11-01 by @allObjects Example code - re-formatted for narrow forum format - and explained:
Lines 2..4 are standard setup for ILI9341 module for TFT LCD module. Line 5 connects the display as output medium to the TOUCH UI module. Lines 6..8 connects the TOUCHR module to the the touch screen for the input - line 6 - and to the UI as the input handler by a callbck that callse the TOUCHUI's evt() method. Event information passed is:
Un-touch is detectable by x and y being undefined and by !t.t - !touchController.touching; UI module evt() iterates through all registered UI elements to find the one that 'owns' the touching spot and act on it. Lines 16,20,24,28,... begin with a definition of a ui element. For each element type the UI module has a method for creation, registration, visualisation, and callback invocation. For creation 8 required parameters are passed (parameters 9 and following are optional for labeling (and other purposes)).
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-11-01 by @gfwilliams Wow, this looks really good. Really compact too! It'd be great to get this added to the standard module list. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-18 by @allObjects Finally, something has happened continuation of this UI module got reworked, modularized, and somewhat generalized in conversation about Modular and extensible UI framework and ui elements. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-11-01 by @allObjects
9/2016: For updated and complemented, higly modularized and extensible version with slider, input field, keypad, radio button, check box, and button ui elements see Modular and extensible UI framework and ui elements conversation (sneak peek pic attached).
Something like attached module code I intend to use with my display with resistive touch screen. So far it support Buttons and Chechboxes w/ and w/o borders and w/ and w/o labels.
The touch controller is a software controller running on Espruino as well. The module code is described in post Resistive Touchscreen directly (no touch controller) at http://forum.espruino.com/comments/11918647/. Espruino touch screen moudule ADS7843 for same named hardware controller can be used as well.
Next UI elements in mind are: Slider, Spinner, and kind of Input and Output Field.
A screenshot and file with ready to run (inline module and example) code is attached. Narrow forum formatting not suitable for longer code lines, therefore click the link to get the code.
The example UI includes as ui elements 6 buttons and 2 checkboxes. Half of the buttons have a text label. Each element has its own callback. They create following console output:
Each element shows its name (hardcoded in the dedicated callback). The chckboxes show their status:
The callback are called on un-touch when received focus before. Touching or dragging into an element's display real estate gives focus to the element. Touching and dragging out of an element and dragging 'through' (in and out in) and then un-touching does not trigger callbacks.
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions