1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

fix(core/embed): fix touch driver on dev kits

[no changelog]
This commit is contained in:
cepetr 2024-06-21 12:48:31 +02:00 committed by cepetr
parent e30a0e6231
commit 0ea965d07e
3 changed files with 20 additions and 7 deletions

View File

@ -66,6 +66,7 @@ MODEL_FEATURE = model_mercury
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC1)) else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC1))
MCU = STM32F4 MCU = STM32F4
LAYOUT_FILE = embed/models/D001/model_D001.h LAYOUT_FILE = embed/models/D001/model_D001.h
OPENOCD_TARGET = target/stm32f4x.cfg
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC2)) else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC2))
MCU = STM32U5 MCU = STM32U5
LAYOUT_FILE = embed/models/D002/model_D002.h LAYOUT_FILE = embed/models/D002/model_D002.h

View File

@ -633,9 +633,12 @@ uint32_t touch_get_event(void) {
uint32_t xy = touch_pack_xy(driver->prev_state.X, driver->prev_state.Y); uint32_t xy = touch_pack_xy(driver->prev_state.X, driver->prev_state.Y);
event = TOUCH_END | xy; event = TOUCH_END | xy;
} else if (new_state.TouchDetected) { } else if (new_state.TouchDetected) {
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); uint32_t xy = touch_pack_xy(new_state.X, new_state.Y);
event = TOUCH_MOVE | xy; event = TOUCH_MOVE | xy;
} }
}
driver->prev_state = new_state; driver->prev_state = new_state;

View File

@ -1193,11 +1193,16 @@ uint8_t touch_get_version(void) {
} }
secbool touch_activity(void) { secbool touch_activity(void) {
if (sitronix_touching) { touch_driver_t *driver = &g_touch_driver;
return sectrue;
} else { if (sectrue != driver->initialized) {
return secfalse; 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) { uint32_t touch_get_event(void) {
@ -1210,6 +1215,7 @@ uint32_t touch_get_event(void) {
TS_State_t new_state = {0}; TS_State_t new_state = {0};
BSP_TS_GetState(0, &new_state); 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.TouchX = new_state.TouchX > 120 ? new_state.TouchX - 120 : 0;
new_state.TouchY = new_state.TouchY > 120 ? new_state.TouchY - 120 : 0; new_state.TouchY = new_state.TouchY > 120 ? new_state.TouchY - 120 : 0;
@ -1223,9 +1229,12 @@ uint32_t touch_get_event(void) {
touch_pack_xy(driver->prev_state.TouchX, driver->prev_state.TouchY); touch_pack_xy(driver->prev_state.TouchX, driver->prev_state.TouchY);
event = TOUCH_END | xy; event = TOUCH_END | xy;
} else if (new_state.TouchDetected) { } else if (new_state.TouchDetected) {
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); uint32_t xy = touch_pack_xy(new_state.TouchX, new_state.TouchY);
event = TOUCH_MOVE | xy; event = TOUCH_MOVE | xy;
} }
}
driver->prev_state = new_state; driver->prev_state = new_state;