#3 Add touch hook for Lilygo L58

This commit is contained in:
martinberlin 2021-05-30 20:13:32 +02:00
parent c9660bd69f
commit debae0b814
4 changed files with 18 additions and 14 deletions

View file

@ -147,9 +147,7 @@ void lvgl_driver_init(void)
touch_driver_init();
#elif defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_I2C)
// Why initializing this when I said is only CONFIG_LV_TOUCH_DRIVER_DISPLAY
ESP_LOGI(TAG, "Initializing I2C master for touch");
lvgl_i2c_driver_init(TOUCH_I2C_PORT,
TOUCH_I2C_SDA, TOUCH_I2C_SCL,
TOUCH_I2C_SPEED_HZ);

View file

@ -25,21 +25,22 @@
#include <lvgl/lvgl.h>
#endif
#include "l58.h"
#include "tp_i2c.h"
#include "../lvgl_i2c_conf.h"
// Cale touch implementation
#include "L58Touch.h"
L58Touch Touch(CONFIG_LV_TOUCH_INT);
#define TAG "L58"
TPoint point;
/**
* @brief Initialize for FT6x36 communication via I2C
* @param dev_addr: Device address on communication Bus (I2C slave address of FT6X36).
* @retval None
*/
void l58_init(uint16_t dev_addr) {
ESP_LOGI(TAG, "l58_init()");
void l58_init() {
ESP_LOGI(TAG, "l58_init() Touch initialized");
Touch.begin(960, 540);
}
/**
@ -49,7 +50,13 @@ void l58_init(uint16_t dev_addr) {
* @retval Always false
*/
bool l58_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
//printf("Touch event %d\n", gpio_get_level(CONFIG_LV_TOUCH_INT)); // Working
point = Touch.loop();
data->point.x = point.x;
data->point.y = point.y;
if (point.event == 3) {
data->state = LV_INDEV_STATE_PR;
} else {
data->state = LV_INDEV_STATE_REL;
}
return false;
}

View file

@ -39,10 +39,9 @@ extern "C" {
/**
* @brief Initialize for FT6x36 communication via I2C
* @param dev_addr: Device address on communication Bus (I2C slave address of FT6X36).
* @retval None
*/
void l58_init(uint16_t dev_addr);
void l58_init();
/**
* @brief Get the touch screen X and Y positions values. Ignores multi touch

View file

@ -6,7 +6,7 @@
#include "tp_spi.h"
#include "tp_i2c.h"
// Is not being included in CMakeLists.txt (Research why)
#include "l58.cpp"
#include "l58.h"
void touch_driver_init(void)
{
@ -15,7 +15,7 @@ void touch_driver_init(void)
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
ft6x06_init(FT6236_I2C_SLAVE_ADDR);
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_L58)
// Do nothing for now
l58_init();
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
stmpe610_init();
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)