Skip to content

Beginning touch support #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: arduino
Choose a base branch
from
Open

Conversation

KurtE
Copy link

@KurtE KurtE commented Jun 5, 2025

Add a callback function for the touch device
within the fixups for the GIGA. This callback
simply remembers the last touch that happened and
sets a semaphore.

There is also a function added to retrieve this data.

Needed to add the callback function into the exports file.

EDIT: As I mentioned in
#92

This is maybe not a complete setup yet. Currently the zephyr touch device is configured for only one touch
Where it believe is supposed to support up to 5. Also with it only doing one touch, it does not support
gestures. I will integrate our WIP touch code into the Arduino_GIGATouch library such that it is all
available for us or others to fill this in.

Add a callback function for the touch device
within the fixups for the GIGA.  This callback
simply remembers the last touch that happened and
sets a semaphore.

There is also a function added to retrieve this data.

Needed to add the callback function into the exports file.
@KurtE
Copy link
Author

KurtE commented Jun 5, 2025

Wondering, an alternative implementation for this would be instead of having a handler here, that
receives all of the messages and creates a simple record of X, y, ... Instead just have method which sets
the call back function. Which is set the callback we define here simply calls it...

void (*user_callback)(struct input_event *evt, void *user_data) = 0;
void touch_event_callback(struct input_event *evt, void *user_data)
{
    //printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
    if (user_callback) (*user_callback)(evt, user_data);
}
...

Or could do combination of both....

Thoughts?

@KurtE
Copy link
Author

KurtE commented Jun 6, 2025

Talking to self (and maybe others)

In certain ways, I think the idea of setting a callback function like I mentioned in the previous comment, might make sense,

but one thing (of many) I don't understand, is how to do that in a safe way. That is Suppose, I setup and run our example Touch Paint sketch, which registers it's callback. Then suppose I decide to run some simple sketch like blink. After Blink loads, my guess is that the callback pointer would be set to wherever it was in the previous sketch, and if the user touches the screen, we will
call off to potential garbage...

Or is there some method we call at sketch startup that can clear the callback(s)...

EDIT: One option, is maybe add the InitVariant for the GIGA, and set it to NULL at that point...

… in the fixups.c

Also add clear out the callback in the initVariant such that if new program is launched it does not use old address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant