Skip to content

Commit

Permalink
fix(core/embed): fix touch driver on dev kits
Browse files Browse the repository at this point in the history
  • Loading branch information
cepetr committed Jul 8, 2024
1 parent e30a0e6 commit b267ff6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ MODEL_FEATURE = model_mercury
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC1))
MCU = STM32F4
LAYOUT_FILE = embed/models/D001/model_D001.h
OPENOCD_TARGET = target/stm32f4x.cfg
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC2))
MCU = STM32U5
LAYOUT_FILE = embed/models/D002/model_D002.h
Expand Down
7 changes: 5 additions & 2 deletions core/embed/trezorhal/stm32f4/touch/stmpe811.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,11 @@ uint32_t touch_get_event(void) {
uint32_t xy = touch_pack_xy(driver->prev_state.X, driver->prev_state.Y);
event = TOUCH_END | xy;
} else if (new_state.TouchDetected) {
uint32_t xy = touch_pack_xy(new_state.X, new_state.Y);
event = TOUCH_MOVE | xy;
if ((new_state.X != driver->prev_state.X) ||
(new_state.Y != driver->prev_state.Y)) {
uint32_t xy = touch_pack_xy(new_state.X, new_state.Y);
event = TOUCH_MOVE | xy;
}
}

driver->prev_state = new_state;
Expand Down
19 changes: 14 additions & 5 deletions core/embed/trezorhal/stm32u5/touch/sitronix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,11 +1193,16 @@ uint8_t touch_get_version(void) {
}

secbool touch_activity(void) {
if (sitronix_touching) {
return sectrue;
} else {
touch_driver_t *driver = &g_touch_driver;

if (sectrue != driver->initialized) {
return secfalse;
}

TS_State_t new_state = {0};
BSP_TS_GetState(0, &new_state);

return sitronix_touching ? sectrue : secfalse;
}

uint32_t touch_get_event(void) {
Expand All @@ -1210,6 +1215,7 @@ uint32_t touch_get_event(void) {
TS_State_t new_state = {0};
BSP_TS_GetState(0, &new_state);

new_state.TouchDetected = (sitronix_touching != 0);
new_state.TouchX = new_state.TouchX > 120 ? new_state.TouchX - 120 : 0;
new_state.TouchY = new_state.TouchY > 120 ? new_state.TouchY - 120 : 0;

Expand All @@ -1223,8 +1229,11 @@ uint32_t touch_get_event(void) {
touch_pack_xy(driver->prev_state.TouchX, driver->prev_state.TouchY);
event = TOUCH_END | xy;
} else if (new_state.TouchDetected) {
uint32_t xy = touch_pack_xy(new_state.TouchX, new_state.TouchY);
event = TOUCH_MOVE | xy;
if ((new_state.TouchX != driver->prev_state.TouchX) ||
(new_state.TouchY != driver->prev_state.TouchY)) {
uint32_t xy = touch_pack_xy(new_state.TouchX, new_state.TouchY);
event = TOUCH_MOVE | xy;
}
}

driver->prev_state = new_state;
Expand Down

0 comments on commit b267ff6

Please sign in to comment.