You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've done a simple touch tft task manager, and I tried both polling and interrupt.
I read in one of the threads here that even polling the touch functionality will pull the T_IRQ pin to LOW state.
So, if I understood that correctly, then I think both polling and interrupt are similar because both methods will pull the T_IRQ pin to LOW state.
I want to know the correct/efficient way to use each method, I will post my idea of using both methods taking into the consideration locking the touch read function to prevent the next unwanted touch readings.
I wanted to design two functions for Polling and Interrupt, but I think this one might work for the two methods.
uint8_t read_button(button &b){
uint16_t x, y;
uint8_t touch_state;
if(!tft_obj.tftTouchLock){
touch_state = tft.getTouch(&x, &y, 150);
if(!touch_state){return;} // there's no touch event, exit the function
tft_obj.tftTouchLock = 1; // if there's touch event, lock the function
b.buttonTimer = millis();
if(x > b.x && x < b.x + b.w && y > b.y && y < b.y + b.h){
tft.drawRect(b.x, b.y, b.w, b.h, TFT_YELLOW);
return b.index;
}
else{
return NOT_SELECTED;
}
}
}
void tft_touch_timer(void){
if((millis() - b.buttonTimer > 20) && (tft_obj.tftTouchLock)){
tft_obj.tftTouchLock = 0;
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I've done a simple touch tft task manager, and I tried both polling and interrupt.
I read in one of the threads here that even polling the touch functionality will pull the T_IRQ pin to LOW state.
So, if I understood that correctly, then I think both polling and interrupt are similar because both methods will pull the T_IRQ pin to LOW state.
I want to know the correct/efficient way to use each method, I will post my idea of using both methods taking into the consideration locking the touch read function to prevent the next unwanted touch readings.
I wanted to design two functions for Polling and Interrupt, but I think this one might work for the two methods.
Beta Was this translation helpful? Give feedback.
All reactions