Skip to content

Commit

Permalink
Workaround for interrupt occurs when touch panel is idle.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli committed Oct 11, 2023
1 parent 1170668 commit 1355c79
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions radio/src/targets/pl18/tp_cst340.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,6 @@ static uint8_t cst340_TS_DetectTouch()
{
uint8_t nbTouch;
uint8_t reg = TS_IO_Read(TOUCH_CST340_I2C_ADDRESS, CST340_FINGER1_REG);
#if defined(DEBUG)
TRACE("cst340_TS_DetectTouch: reg=%d", reg);
#endif
if( reg == 0x06 )
nbTouch = 1;
else
Expand Down Expand Up @@ -484,9 +481,24 @@ void handleTouch()
}
}

static bool lastHasTouch = false;
bool touchPanelEventOccured()
{
return touchEventOccured;
bool result = touchEventOccured;
uint8_t hasTouch = false;
if (touchEventOccured) {
hasTouch = tc->detectTouch();
if (!hasTouch && !lastHasTouch) {
touchEventOccured = false;
result = false;
}
lastHasTouch = hasTouch;
}

#if defined(DEBUG)
TRACE("TouchEvent: %d, %d, %d, %d", touchEventOccured, lastHasTouch, hasTouch, result);
#endif
return result;
}

TouchState touchPanelRead()
Expand Down

0 comments on commit 1355c79

Please sign in to comment.