Jump to content

Recommended Posts

Posted

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);
 
   // ...
 
    GEventpe = geventEventWait(&glgDelayNone);
    if (pe != NULL) {
        log_debug("ui/main""want this to log on any touch\n");
        switch (pe->type) {
           ...
Posted

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.

Posted

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? 

Posted

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?

Posted

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?

Posted

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)

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...