change touch controller readouts to verbose logger
This commit is contained in:
parent
16f9f93dab
commit
50b212aa56
4 changed files with 35 additions and 40 deletions
|
@ -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.x = touch_inputs.last_x;
|
||||||
data->point.y = touch_inputs.last_y;
|
data->point.y = touch_inputs.last_y;
|
||||||
data->state = touch_inputs.current_state;
|
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
|
#if CONFIG_LV_FT6X36_COORDINATES_QUEUE
|
||||||
xQueueOverwrite( ft6x36_touch_queue_handle, &touch_inputs );
|
xQueueOverwrite( ft6x36_touch_queue_handle, &touch_inputs );
|
||||||
|
|
|
@ -138,7 +138,7 @@ bool gt911_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
|
||||||
data->point.x = last_x;
|
data->point.x = last_x;
|
||||||
data->point.y = last_y;
|
data->point.y = last_y;
|
||||||
data->state = LV_INDEV_STATE_PR;
|
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);
|
ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "../lvgl_tft/ra8875.h"
|
#include "../lvgl_tft/ra8875.h"
|
||||||
|
|
||||||
#ifndef CONFIG_LV_TFT_DISPLAY_CONTROLLER_RA8875
|
#ifndef CONFIG_LV_TFT_DISPLAY_CONTROLLER_RA8875
|
||||||
#error "Display controller must be RA8875"
|
#error "Display controller must be RA8875"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
|
@ -31,23 +31,23 @@
|
||||||
|
|
||||||
#define TPCR0_ADC_TIMING ((CONFIG_LV_TOUCH_RA8875_SAMPLE_TIME << 4) | CONFIG_LV_TOUCH_RA8875_ADC_CLOCK)
|
#define TPCR0_ADC_TIMING ((CONFIG_LV_TOUCH_RA8875_SAMPLE_TIME << 4) | CONFIG_LV_TOUCH_RA8875_ADC_CLOCK)
|
||||||
#if LVGL_TOUCH_RA8875_WAKEUP_ENABLE
|
#if LVGL_TOUCH_RA8875_WAKEUP_ENABLE
|
||||||
#define TPCR0_VAL (0x08 | TPCR0_ADC_TIMING)
|
#define TPCR0_VAL (0x08 | TPCR0_ADC_TIMING)
|
||||||
#else
|
#else
|
||||||
#define TPCR0_VAL (TPCR0_ADC_TIMING)
|
#define TPCR0_VAL (TPCR0_ADC_TIMING)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LVGL_TOUCH_RA8875_EXTERNAL_VREF
|
#if LVGL_TOUCH_RA8875_EXTERNAL_VREF
|
||||||
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
|
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
|
||||||
#define TPCR1_VAL (0x24)
|
#define TPCR1_VAL (0x24)
|
||||||
#else
|
|
||||||
#define TPCR1_VAL (0x20)
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
|
#define TPCR1_VAL (0x20)
|
||||||
#define TPCR1_VAL (0x04)
|
#endif
|
||||||
#else
|
#else
|
||||||
#define TPCR1_VAL (0x00)
|
#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE
|
||||||
#endif
|
#define TPCR1_VAL (0x04)
|
||||||
|
#else
|
||||||
|
#define TPCR1_VAL (0x00)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void ra8875_corr(int * x, int * y);
|
static void ra8875_corr(int *x, int *y);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
|
@ -72,8 +72,7 @@ static void ra8875_corr(int * x, int * y);
|
||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
void ra8875_touch_init(void)
|
void ra8875_touch_init(void) {
|
||||||
{
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t cmd; // Register address of command
|
uint8_t cmd; // Register address of command
|
||||||
uint8_t data; // Value to write to register
|
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_TPCR0, TPCR0_VAL}, // Touch Panel Control Register 0 (TPCR0)
|
||||||
{RA8875_REG_TPCR1, TPCR1_VAL}, // Touch Panel Control Register 1 (TPCR1)
|
{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...");
|
ESP_LOGI(TAG, "Initializing RA8875 Touch...");
|
||||||
|
|
||||||
|
@ -92,8 +91,7 @@ void ra8875_touch_init(void)
|
||||||
ra8875_touch_enable(true);
|
ra8875_touch_enable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ra8875_touch_enable(bool enable)
|
void ra8875_touch_enable(bool enable) {
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "%s touch.", enable ? "Enabling" : "Disabling");
|
ESP_LOGI(TAG, "%s touch.", enable ? "Enabling" : "Disabling");
|
||||||
uint8_t val = enable ? (0x80 | TPCR0_VAL) : (TPCR0_VAL);
|
uint8_t val = enable ? (0x80 | TPCR0_VAL) : (TPCR0_VAL);
|
||||||
ra8875_write_cmd(RA8875_REG_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
|
* @param data store the read data here
|
||||||
* @return false: because no more data to be read
|
* @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 x = 0;
|
||||||
static int y = 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);
|
x = (x << 2) | (xy & 0x03);
|
||||||
y = (y << 2) | ((xy >> 2) & 0x03);
|
y = (y << 2) | ((xy >> 2) & 0x03);
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
ESP_LOGI(TAG, "Touch Poll Raw: %d,%d", x, y);
|
ESP_LOGV(TAG, "Touch Poll Raw: %d,%d", x, y);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Convert to display coordinates
|
// Convert to display coordinates
|
||||||
ra8875_corr(&x, &y);
|
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.x = x;
|
||||||
data->point.y = y;
|
data->point.y = y;
|
||||||
|
|
||||||
#if DEBUG
|
ESP_LOGV(TAG, "Touch Poll - Event: %d; %d,%d", data->state, data->point.x, data->point.y);
|
||||||
ESP_LOGI(TAG, "Touch Poll - Event: %d; %d,%d", data->state, data->point.x, data->point.y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +143,7 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void ra8875_corr(int * x, int * y)
|
static void ra8875_corr(int *x, int *y) {
|
||||||
{
|
|
||||||
#if RA8875_XY_SWAP != 0
|
#if RA8875_XY_SWAP != 0
|
||||||
int tmp = *x;
|
int tmp = *x;
|
||||||
*x = *y;
|
*x = *y;
|
||||||
|
@ -158,17 +153,17 @@ static void ra8875_corr(int * x, int * y)
|
||||||
if ((*x) <= RA8875_X_MIN) {
|
if ((*x) <= RA8875_X_MIN) {
|
||||||
(*x) = 0;
|
(*x) = 0;
|
||||||
} else if ((*x) >= RA8875_X_MAX) {
|
} else if ((*x) >= RA8875_X_MAX) {
|
||||||
(*x) = LV_HOR_RES-1;
|
(*x) = LV_HOR_RES - 1;
|
||||||
} else {
|
} 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) {
|
if ((*y) <= RA8875_Y_MIN) {
|
||||||
(*y) = 0;
|
(*y) = 0;
|
||||||
} else if ((*y) >= RA8875_Y_MAX) {
|
} else if ((*y) >= RA8875_Y_MAX) {
|
||||||
(*y) = LV_VER_RES-1;
|
(*y) = LV_VER_RES - 1;
|
||||||
} else {
|
} 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
|
#if RA8875_X_INV != 0
|
||||||
|
|
|
@ -94,19 +94,19 @@ bool xpt2046_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||||
|
|
||||||
x = xpt2046_cmd(CMD_X_READ);
|
x = xpt2046_cmd(CMD_X_READ);
|
||||||
y = xpt2046_cmd(CMD_Y_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*/
|
/*Normalize Data back to 12-bits*/
|
||||||
x = x >> 4;
|
x = x >> 4;
|
||||||
y = y >> 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_corr(&x, &y);
|
||||||
xpt2046_avg(&x, &y);
|
xpt2046_avg(&x, &y);
|
||||||
last_x = x;
|
last_x = x;
|
||||||
last_y = y;
|
last_y = y;
|
||||||
|
|
||||||
ESP_LOGI(TAG, "x = %d, y = %d", x, y);
|
ESP_LOGV(TAG, "x = %d, y = %d", x, y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue