Joshua Posted April 7, 2021 Report Share Posted April 7, 2021 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 geventListenerInit(&gl); gwinAttachListener(&gl); // ... GEvent* pe = geventEventWait(&gl, gDelayNone); if (pe != NULL) { log_debug("ui/main", "want this to log on any touch\n"); switch (pe->type) { ... Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted April 8, 2021 Report Share Posted April 8, 2021 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 comment Share on other sites More sharing options...
Joshua Posted April 9, 2021 Author Report Share Posted April 9, 2021 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 comment Share on other sites More sharing options...
Joel Bodenmann Posted April 12, 2021 Report Share Posted April 12, 2021 What GINPUT driver are you using? This might very well be a driver "problem" (or feature). Can you reproduce the problem when you take you application code and compile it into a native Windows, Linux or MacOS application? Link to comment Share on other sites More sharing options...
Joshua Posted April 12, 2021 Author Report Share Posted April 12, 2021 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 comment Share on other sites More sharing options...
Joshua Posted April 13, 2021 Author Report Share Posted April 13, 2021 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 comment Share on other sites More sharing options...
Joel Bodenmann Posted April 14, 2021 Report Share Posted April 14, 2021 The FT6x06 driver was contributed by a community member. It's likely that not everything in there is optional. We welcome any kind of contribution to improve the state of community-supplied drivers Link to comment Share on other sites More sharing options...
inmarket Posted April 20, 2021 Report Share Posted April 20, 2021 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 comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now