ft6x36: Replace ESP_LOG with LVGL logging

This commit is contained in:
C47D 2021-10-13 23:27:31 -05:00
parent 4a9cfeb6fb
commit 5d55edc37c

View file

@ -18,7 +18,6 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include <esp_log.h>
#ifdef LV_LVGL_H_INCLUDE_SIMPLE #ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include <lvgl.h> #include <lvgl.h>
#else #else
@ -28,8 +27,7 @@
#include "lvgl_i2c/i2c_manager.h" #include "lvgl_i2c/i2c_manager.h"
#define TAG "FT6X36" #define TAG "FT6X36: "
ft6x36_status_t ft6x36_status; ft6x36_status_t ft6x36_status;
uint8_t current_dev_addr; // set during init uint8_t current_dev_addr; // set during init
@ -46,13 +44,13 @@ esp_err_t ft6x06_i2c_read8(uint8_t slave_addr, uint8_t register_addr, uint8_t *d
*/ */
uint8_t ft6x36_get_gesture_id() { uint8_t ft6x36_get_gesture_id() {
if (!ft6x36_status.inited) { if (!ft6x36_status.inited) {
ESP_LOGE(TAG, "Init first!"); LV_LOG_ERROR(TAG, "Init first!");
return 0x00; return 0x00;
} }
uint8_t data_buf; uint8_t data_buf;
esp_err_t ret; esp_err_t ret;
if ((ret = ft6x06_i2c_read8(current_dev_addr, FT6X36_GEST_ID_REG, &data_buf) != ESP_OK)) if ((ret = ft6x06_i2c_read8(current_dev_addr, FT6X36_GEST_ID_REG, &data_buf) != ESP_OK))
ESP_LOGE(TAG, "Error reading from device: %s", esp_err_to_name(ret)); LV_LOG_ERROR(TAG, "Error reading from device: %s", esp_err_to_name(ret));
return data_buf; return data_buf;
} }
@ -67,23 +65,23 @@ void ft6x06_init(uint16_t dev_addr) {
current_dev_addr = dev_addr; current_dev_addr = dev_addr;
uint8_t data_buf; uint8_t data_buf;
esp_err_t ret; esp_err_t ret;
ESP_LOGI(TAG, "Found touch panel controller"); LV_LOG_INFO(TAG, "Found touch panel controller");
if ((ret = ft6x06_i2c_read8(dev_addr, FT6X36_PANEL_ID_REG, &data_buf) != ESP_OK)) if ((ret = ft6x06_i2c_read8(dev_addr, FT6X36_PANEL_ID_REG, &data_buf) != ESP_OK))
ESP_LOGE(TAG, "Error reading from device: %s", LV_LOG_ERROR(TAG, "Error reading from device: %s",
esp_err_to_name(ret)); // Only show error the first time esp_err_to_name(ret)); // Only show error the first time
ESP_LOGI(TAG, "\tDevice ID: 0x%02x", data_buf); LV_LOG_INFO(TAG, "\tDevice ID: 0x%02x", data_buf);
ft6x06_i2c_read8(dev_addr, FT6X36_CHIPSELECT_REG, &data_buf); ft6x06_i2c_read8(dev_addr, FT6X36_CHIPSELECT_REG, &data_buf);
ESP_LOGI(TAG, "\tChip ID: 0x%02x", data_buf); LV_LOG_INFO(TAG, "\tChip ID: 0x%02x", data_buf);
ft6x06_i2c_read8(dev_addr, FT6X36_DEV_MODE_REG, &data_buf); ft6x06_i2c_read8(dev_addr, FT6X36_DEV_MODE_REG, &data_buf);
ESP_LOGI(TAG, "\tDevice mode: 0x%02x", data_buf); LV_LOG_INFO(TAG, "\tDevice mode: 0x%02x", data_buf);
ft6x06_i2c_read8(dev_addr, FT6X36_FIRMWARE_ID_REG, &data_buf); ft6x06_i2c_read8(dev_addr, FT6X36_FIRMWARE_ID_REG, &data_buf);
ESP_LOGI(TAG, "\tFirmware ID: 0x%02x", data_buf); LV_LOG_INFO(TAG, "\tFirmware ID: 0x%02x", data_buf);
ft6x06_i2c_read8(dev_addr, FT6X36_RELEASECODE_REG, &data_buf); ft6x06_i2c_read8(dev_addr, FT6X36_RELEASECODE_REG, &data_buf);
ESP_LOGI(TAG, "\tRelease code: 0x%02x", data_buf); LV_LOG_INFO(TAG, "\tRelease code: 0x%02x", data_buf);
} }
@ -95,7 +93,7 @@ void ft6x06_init(uint16_t dev_addr) {
*/ */
bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
if (!ft6x36_status.inited) { if (!ft6x36_status.inited) {
ESP_LOGE(TAG, "Init first!"); LV_LOG_ERROR(TAG, "Init first!");
return 0x00; return 0x00;
} }
uint8_t data_buf[5]; // 1 byte status, 2 bytes X, 2 bytes Y uint8_t data_buf[5]; // 1 byte status, 2 bytes X, 2 bytes Y
@ -104,7 +102,7 @@ bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
esp_err_t ret = lvgl_i2c_read(CONFIG_LV_I2C_TOUCH_PORT, current_dev_addr, FT6X36_TD_STAT_REG, &data_buf[0], 5); esp_err_t ret = lvgl_i2c_read(CONFIG_LV_I2C_TOUCH_PORT, current_dev_addr, FT6X36_TD_STAT_REG, &data_buf[0], 5);
if (ret != ESP_OK) { if (ret != ESP_OK) {
ESP_LOGE(TAG, "Error talking to touch IC: %s", esp_err_to_name(ret)); LV_LOG_ERROR(TAG, "Error talking to touch IC: %s", esp_err_to_name(ret));
} }
uint8_t touch_pnt_cnt = data_buf[0]; // Number of detected touch points uint8_t touch_pnt_cnt = data_buf[0]; // Number of detected touch points
@ -132,6 +130,6 @@ bool ft6x36_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_LOGD(TAG, "X=%u Y=%u", data->point.x, data->point.y); LV_LOG_INFO(TAG, "X=%u Y=%u", data->point.x, data->point.y);
return false; return false;
} }