‎2023-03-15 10:52 AM
I am having trouble figuring out this seemingly simple thing. Assuming I have the coordinates of a touch point in a touch screen, how do I draw pixel to that location?
Solved! Go to Solution.
‎2023-03-16 07:51 PM
Hi,
​
The "issue" here is that the easiest way would be to use a widget (like a line or box widget) to draw that pixel using TouchGFX Designer. I don't know what you are planning to do but I guess it is not just putting one pixel or 2, but you would need to know in advance how many times (and therefore how many widgets) you would need to write pixels . An "advanced/complex" way to do this, I'll share a project doing that, would be to draw that one pixel (using the line widget in my case) and save a screenshot of that area (using cacheable containers and bitmaps) so that you can do it multiple time using only one line widget instead of many. This was done in my project to draw curves based on the touch of a user, It might look complex at first but the code is actually quite "simple".
​
Otherwise what you could do I guess is save those coordinates, send them to your main.c through the model and set the pixel of the framebuffer there, a bit like what we do in this article to check if the display is working.
​
I'm sure there are other and better ways so if anyone has something that makes more sense or is cleaner please share :beaming_face_with_smiling_eyes:
/Romain
‎2023-03-16 07:51 PM
Hi,
​
The "issue" here is that the easiest way would be to use a widget (like a line or box widget) to draw that pixel using TouchGFX Designer. I don't know what you are planning to do but I guess it is not just putting one pixel or 2, but you would need to know in advance how many times (and therefore how many widgets) you would need to write pixels . An "advanced/complex" way to do this, I'll share a project doing that, would be to draw that one pixel (using the line widget in my case) and save a screenshot of that area (using cacheable containers and bitmaps) so that you can do it multiple time using only one line widget instead of many. This was done in my project to draw curves based on the touch of a user, It might look complex at first but the code is actually quite "simple".
​
Otherwise what you could do I guess is save those coordinates, send them to your main.c through the model and set the pixel of the framebuffer there, a bit like what we do in this article to check if the display is working.
​
I'm sure there are other and better ways so if anyone has something that makes more sense or is cleaner please share :beaming_face_with_smiling_eyes:
/Romain
‎2023-03-16 07:55 PM
In the project shared, the line/pixels are drawn when there is a "drag" and not when just on the click. In your case just put the code from the "handleDragEvent()" function into the "handleClickEvent()" I guess.
/Romain
‎2023-03-16 09:02 PM
Thank you I was looking for this too. :grinning_face:
‎2023-03-17 08:13 AM
Thank you very much! I will follow your suggestions.