Skip to content

Commit

Permalink
- ESP32_2432S024N does not have touch!
Browse files Browse the repository at this point in the history
- Optiomize x/y calculation
  • Loading branch information
rzeldent committed Sep 23, 2023
1 parent 89e4417 commit 67796ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/esp32_smartdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void smartdisplay_init()
// Clear screen
lv_obj_clean(lv_scr_act());

#if !defined(ESP32_8048S070N)
#if !defined(ESP32_2432S024N) && !defined(ESP32_8048S070N)
// Setup touch
lvgl_touch_init();
static lv_indev_drv_t indev_drv;
Expand Down
21 changes: 8 additions & 13 deletions src/touch_cst820.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,21 @@ bool cst820_read_touch(uint16_t *x, uint16_t *y, uint8_t *gesture)
if (!cst820_read_register(0x03, data, 4))
return false;

*x = ((data[0] & 0x0f) << 8) | data[1];
*y = ((data[2] & 0x0f) << 8) | data[3];

#ifdef TFT_ORIENTATION_PORTRAIT
*x = TFT_WIDTH - *x;
*y = TFT_HEIGHT - *y;
*x = TFT_WIDTH - (((data[0] & 0x0f) << 8) | data[1]);
*y = TFT_HEIGHT - (((data[2] & 0x0f) << 8) | data[3]);
#else
#ifdef TFT_ORIENTATION_LANDSCAPE
uint16_t swap;
swap = *x;
*x = *y;
*y = TFT_WIDTH - swap;
*x = ((data[2] & 0x0f) << 8) | data[3];
*y = TFT_WIDTH - (((data[0] & 0x0f) << 8) | data[1]);
#else
#ifdef TFT_ORIENTATION_PORTRAIT_INV
*x = ((data[0] & 0x0f) << 8) | data[1];
*y = ((data[2] & 0x0f) << 8) | data[3];
#else
#ifdef TFT_ORIENTATION_LANDSCAPE_INV
uint16_t swap;
swap = *x;
*x = TFT_HEIGHT - *y;
*y = swap;
*x = TFT_HEIGHT - (((data[2] & 0x0f) << 8) | data[3]);
*y = ((data[0] & 0x0f) << 8) | data[1];
#else
#error TFT_ORIENTATION not defined!
#endif
Expand Down

0 comments on commit 67796ea

Please sign in to comment.