reverted back to using the lvgl i2c_manager

This commit is contained in:
Bassam 2022-08-12 13:07:15 +03:00
parent 1afab3cd91
commit f29723c800
3 changed files with 26 additions and 49 deletions

View file

@ -88,7 +88,7 @@ endif()
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS ${LVGL_INCLUDE_DIRS}
REQUIRES lvgl band_audio_hal)
REQUIRES lvgl)
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_LVGL_H_INCLUDE_SIMPLE")

View file

@ -27,23 +27,18 @@
#include "CST816.h"
#include "lvgl_i2c/i2c_manager.h"
#include "band_es8388.h"
#define TAG "CST816"
cst816_status_t cst816_status;
uint8_t CST816_addr;
//[BJ] TODO: Below functions are ADF specific, if I am to contribute to main repo this needs to be resolved!
static esp_err_t _cst816_i2c_read(uint8_t slave_addr, uint8_t register_addr, uint8_t *data_buf, uint8_t len) {
return band_i2c_read(slave_addr, register_addr, data_buf, len);
//return lvgl_i2c_read(CONFIG_LV_I2C_TOUCH_PORT, slave_addr, register_addr | I2C_REG_16, data_buf, len);
return lvgl_i2c_read(CONFIG_LV_I2C_TOUCH_PORT, slave_addr, register_addr, data_buf, len);
}
static esp_err_t _cst816_i2c_write8(uint8_t slave_addr, uint8_t register_addr, uint8_t data) {
//uint8_t buffer = data;
return band_i2c_write(slave_addr, register_addr, &data, 1);
//return lvgl_i2c_write(CONFIG_LV_I2C_TOUCH_PORT, slave_addr, register_addr | I2C_REG_16, &buffer, 1);
}
// static esp_err_t _cst816_i2c_write8(uint8_t slave_addr, uint8_t register_addr, uint8_t data) {
// return lvgl_i2c_write(CONFIG_LV_I2C_TOUCH_PORT, slave_addr, register_addr, &data, 1);
// }
/**
* @brief Initialize for cst816 communication via I2C
@ -51,9 +46,7 @@ static esp_err_t _cst816_i2c_write8(uint8_t slave_addr, uint8_t register_addr, u
* @retval None
*/
void cst816_init(uint8_t dev_addr) {
if (!cst816_status.inited)
{
cst816_status.i2c_dev_addr = dev_addr;
CST816_addr = dev_addr;
uint8_t version;
uint8_t versionInfo[3];
esp_err_t ret;
@ -71,8 +64,6 @@ void cst816_init(uint8_t dev_addr) {
return;
}
ESP_LOGI(TAG, "CST816 version %d, versionInfo: %d.%d.%d", version, versionInfo[0], versionInfo[1], versionInfo[2]);
cst816_status.inited = true;
}
}
/**
@ -81,18 +72,12 @@ void cst816_init(uint8_t dev_addr) {
* @param data: Store data here
* @retval Always false
*/
#define SWAPXY 1
#define INVERTX 1
#define INVERTY 0
bool cst816_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
uint8_t data_raw[8];
_cst816_i2c_read(cst816_status.i2c_dev_addr, 0x01, data_raw, 6);
uint8_t data_raw[8] ;
_cst816_i2c_read(CST816_addr, 0x01, data_raw, 6);
uint8_t gestureID = data_raw[0];
uint8_t points = data_raw[1];

View file

@ -33,15 +33,7 @@
extern "C" {
#endif
#define CST816_I2C_SLAVE_ADDR 0x15<<1
#define CST816_PRODUCT_ID_LEN 4
typedef struct {
bool inited;
uint8_t i2c_dev_addr;
} cst816_status_t;
#define CST816_I2C_SLAVE_ADDR 0x15
/**
* @brief Initialize for cst816 communication via I2C