I wrote my project and functionally it is OK, one thing which is annoying is that I have a high latency sometimes since the moment I touch one of the screen's buttons until the action the button should trigger actually starts. I though of adding interrupts handling to my project but I am not sure if it is supported by this screen or by the arduino in general. can anyone confrim or deny whether this should work or not ? code example would be great.
the screen itself works just fine and touch response latency is quite good for my needs. the think is that I have other things running which are consuming the controller's time, so sometimes I have high latency until my functions which checks the touch screen's HW status is finally called.
my main loop looks like this:
checkTouchScreen();
doA();
doB();
doC();
doA(), doB(), doC() are functionalities that I want to call each time, but In case I have a touch screen I want to give it priority over these calls. ( I could try calling checkTouchScreen(); as a workaround but that is not a clean/stable solution).
I think that this should be possible since in the screen's website https://www.waveshare.com/3.5inch-tft-touch-shield.htm I see that they have TP_IRQ pin (Touch panel interrupt), so just need to find the code example for it.
I will try the libraries later to see if they have any interrupt handling example.
Whether interrupts are useful or not depends on what action needs to be performed; a simple toggling of a led or setting a variable would be OK.
If your doX() functions are time consuming, there is probably something wrong with your implementation and you might have to rework them; as you haven't posted your code yet, this is just some general advise.
Break your doX() functions up in small pieces/ steps and keep track which step is complete. Call the function repeatedly as you currently are doing and execute the next step.
Don't use delay and definitely not in loops (for / while) if it can be prevented, use millis() for timing and if needed make use of finite state machines.