firmware icon indicating copy to clipboard operation
firmware copied to clipboard

Add module "Touch" to js

Open DESVOR8 opened this issue 6 months ago • 0 comments

Is your feature request related to a problem? Please describe. I've always struggled with using touchscreens in my JS scripts.

Describe the solution you'd like

What if we add a "touch" module with the following methods:


touch.has_touchScreen() - Boolean, true if the HAS_TOUCH flag is defined
touch.is_touching() - Boolean, true if the user is touching the screen anywhere
touch.getXPosition() - returns the touch location on the screen along the X axis from 0 to TFT_WIDTH, and -1 if there is no touch
touch.getYPosition() - returns the touch location on the screen along the Y axis from 0 to TFT_HEIGHT, and -1 if there is no touch
touch.attach(function) - allows you to call a function when a touch is detected
touch.isInZone(X, Y, WIDTH, HEIGHT) - Boolean, true if there is a touch and it is within the designated area Zone
touch.attachToZone(X, Y, WIDTH, HEIGHT, FUNCTION) - Calls a function when a touch is detected in a specific zone. This is useful if you need to add an exit button, for example. It also returns a number, which is the zone ID, which is needed if you need to disable or delete the attachment zone.
touch.unattach(ID) - Deletes the attachment zone and returns a Boolean value, false if the deletion failed (not found), and accepts -1 or nothing if you need to delete the touch.attachment.
touch.pauseAttachment() - Pauses all attachments in the zone.
touch.resumeAttachment() - Resumes all attachments in the zone.
touch.removeAllAttachments() - Deletes all attachments.

Describe alternatives you've considered Only keyboard.getSelPress() and other keyboard.*.

Additional context Bruce 1.14 Cyd(not cyd, just esp32-wroom with connected touch screen & screen) user

DESVOR8 avatar May 26 '26 07:05 DESVOR8