change touch controller readouts to verbose logger

This commit is contained in:
hiruna 2023-06-01 20:08:43 +10:00
parent 16f9f93dab
commit 50b212aa56
4 changed files with 35 additions and 40 deletions

View file

@ -150,7 +150,7 @@ bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
data->point.x = touch_inputs.last_x;
data->point.y = touch_inputs.last_y;
data->state = touch_inputs.current_state;
ESP_LOGD(TAG, "X=%u Y=%u", data->point.x, data->point.y);
ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y);
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
xQueueOverwrite( ft6x36_touch_queue_handle, &touch_inputs );

View file

@ -138,7 +138,7 @@ bool gt911_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
data->point.x = last_x;
data->point.y = last_y;
data->state = LV_INDEV_STATE_PR;
ESP_LOGI(TAG, "X=%u Y=%u", data->point.x, data->point.y);
ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y);
ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y);
return false;
}

View file

@ -16,7 +16,7 @@
#include "../lvgl_tft/ra8875.h"
#ifndef CONFIG_LV_TFT_DISPLAY_CONTROLLER_RA8875
#error "Display controller must be RA8875"
#error "Display controller must be RA8875"
#endif
/*********************
@ -31,23 +31,23 @@
#define TPCR0_ADC_TIMING ((CONFIG_LV_TOUCH_RA8875_SAMPLE_TIME << 4) | CONFIG_LV_TOUCH_RA8875_ADC_CLOCK)
#if LVGL_TOUCH_RA8875_WAKEUP_ENABLE
#define TPCR0_VAL (0x08 | TPCR0_ADC_TIMING)
#define TPCR0_VAL (0x08 | TPCR0_ADC_TIMING)
#else
#define TPCR0_VAL (TPCR0_ADC_TIMING)
#define TPCR0_VAL (TPCR0_ADC_TIMING)
#endif
#if LVGL_TOUCH_RA8875_EXTERNAL_VREF
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
#define TPCR1_VAL (0x24)
#else
#define TPCR1_VAL (0x20)
#endif
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
#define TPCR1_VAL (0x24)
#else
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
#define TPCR1_VAL (0x04)
#else
#define TPCR1_VAL (0x00)
#endif
#define TPCR1_VAL (0x20)
#endif
#else
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
#define TPCR1_VAL (0x04)
#else
#define TPCR1_VAL (0x00)
#endif
#endif
/**********************
@ -58,7 +58,7 @@
* STATIC PROTOTYPES
**********************/
static void ra8875_corr(int * x, int * y);
static void ra8875_corr(int *x, int *y);
/**********************
* STATIC VARIABLES
@ -72,8 +72,7 @@ static void ra8875_corr(int * x, int * y);
* GLOBAL FUNCTIONS
**********************/
void ra8875_touch_init(void)
{
void ra8875_touch_init(void) {
struct {
uint8_t cmd; // Register address of command
uint8_t data; // Value to write to register
@ -81,7 +80,7 @@ void ra8875_touch_init(void)
{RA8875_REG_TPCR0, TPCR0_VAL}, // Touch Panel Control Register 0 (TPCR0)
{RA8875_REG_TPCR1, TPCR1_VAL}, // Touch Panel Control Register 1 (TPCR1)
};
#define INIT_CMDS_SIZE (sizeof(init_cmds)/sizeof(init_cmds[0]))
#define INIT_CMDS_SIZE (sizeof(init_cmds)/sizeof(init_cmds[0]))
ESP_LOGI(TAG, "Initializing RA8875 Touch...");
@ -92,8 +91,7 @@ void ra8875_touch_init(void)
ra8875_touch_enable(true);
}
void ra8875_touch_enable(bool enable)
{
void ra8875_touch_enable(bool enable) {
ESP_LOGI(TAG, "%s touch.", enable ? "Enabling" : "Disabling");
uint8_t val = enable ? (0x80 | TPCR0_VAL) : (TPCR0_VAL);
ra8875_write_cmd(RA8875_REG_TPCR0, val);
@ -104,8 +102,7 @@ void ra8875_touch_enable(bool enable)
* @param data store the read data here
* @return false: because no more data to be read
*/
bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
{
bool ra8875_touch_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
static int x = 0;
static int y = 0;
@ -121,9 +118,9 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
x = (x << 2) | (xy & 0x03);
y = (y << 2) | ((xy >> 2) & 0x03);
#if DEBUG
ESP_LOGI(TAG, "Touch Poll Raw: %d,%d", x, y);
#endif
ESP_LOGV(TAG, "Touch Poll Raw: %d,%d", x, y);
// Convert to display coordinates
ra8875_corr(&x, &y);
@ -135,9 +132,8 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
data->point.x = x;
data->point.y = y;
#if DEBUG
ESP_LOGI(TAG, "Touch Poll - Event: %d; %d,%d", data->state, data->point.x, data->point.y);
#endif
ESP_LOGV(TAG, "Touch Poll - Event: %d; %d,%d", data->state, data->point.x, data->point.y);
return false;
}
@ -147,8 +143,7 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
* STATIC FUNCTIONS
**********************/
static void ra8875_corr(int * x, int * y)
{
static void ra8875_corr(int *x, int *y) {
#if RA8875_XY_SWAP != 0
int tmp = *x;
*x = *y;
@ -158,17 +153,17 @@ static void ra8875_corr(int * x, int * y)
if ((*x) <= RA8875_X_MIN) {
(*x) = 0;
} else if ((*x) >= RA8875_X_MAX) {
(*x) = LV_HOR_RES-1;
(*x) = LV_HOR_RES - 1;
} else {
(*x) = (((*x) - RA8875_X_MIN) * (LV_HOR_RES-1)) / (RA8875_X_MAX - RA8875_X_MIN);
(*x) = (((*x) - RA8875_X_MIN) * (LV_HOR_RES - 1)) / (RA8875_X_MAX - RA8875_X_MIN);
}
if ((*y) <= RA8875_Y_MIN) {
(*y) = 0;
} else if ((*y) >= RA8875_Y_MAX) {
(*y) = LV_VER_RES-1;
(*y) = LV_VER_RES - 1;
} else {
(*y) = (((*y) - RA8875_Y_MIN) * (LV_VER_RES-1)) / (RA8875_Y_MAX - RA8875_Y_MIN);
(*y) = (((*y) - RA8875_Y_MIN) * (LV_VER_RES - 1)) / (RA8875_Y_MAX - RA8875_Y_MIN);
}
#if RA8875_X_INV != 0

View file

@ -94,19 +94,19 @@ bool xpt2046_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
x = xpt2046_cmd(CMD_X_READ);
y = xpt2046_cmd(CMD_Y_READ);
ESP_LOGI(TAG, "P(%d,%d)", x, y);
ESP_LOGV(TAG, "P(%d,%d)", x, y);
/*Normalize Data back to 12-bits*/
x = x >> 4;
y = y >> 4;
ESP_LOGI(TAG, "P_norm(%d,%d)", x, y);
ESP_LOGV(TAG, "P_norm(%d,%d)", x, y);
xpt2046_corr(&x, &y);
xpt2046_avg(&x, &y);
last_x = x;
last_y = y;
ESP_LOGI(TAG, "x = %d, y = %d", x, y);
ESP_LOGV(TAG, "x = %d, y = %d", x, y);
}
else
{