Jump to content

Detect any touch event

Recommended Posts

Hey there,

I am wondering how I can detect any touch event, not just when touching a "pressable" widget. My goal is to turn the screen off after x seconds with no user input, then once the user touches the screen again, for it to turn back on.

My event code follows the code samples closely: 

    // Init event listener
   // ...
    GEventpe = geventEventWait(&glgDelayNone);
    if (pe != NULL) {
        log_debug("ui/main""want this to log on any touch\n");
        switch (pe->type) {
Link to post
Share on other sites

Hello & welcome to the µGFX community!

There are various ways of achieving this. For example, you can have a look at the /demos/applications/notepad demo which is a small paint-like application. To draw without handling the touch (mouse) inputs through widgets. Instead, it uses ginputGetMouseStatus() to retrieve the current mouse status.

You can use the GTIMER module to implement the screen timeout easily.

Link to post
Share on other sites

Thanks Joel, ginputGetMouseStatus works great. However, for some reason when I first start my app, it reports that the touchscreen is pressed, until I tap it with my finger. Do you know why this would happen? 

Link to post
Share on other sites

I'm using the FT6x06 driver. I discovered that when I log the coordinates read in `read_xyz`, when the app starts it detects a touch but the coordinates are x=4095 and y=-1, which don't make sense to me. I could modify the driver to check for this but perhaps it points to a problem elsewhere?

Link to post
Share on other sites

After more investigation it seems the FT6x06_TOUCH_POINTS register on my display is initialized to 0xFF instead of 0x00 as on the datasheet. I have modified the touch check to see if the number of touch points is valid (1 or 2)

Link to post
Share on other sites

A simple way is to just add a timeout value of x seconds instead of gDelayNone.

If you get a NULL response then you have a timeout and the screen can be turned off. A non-NULL response can turn the screen back on if it was off.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...