#3 Start adding L58: Find a way to instantiate existing class or refactor it to C
This commit is contained in:
parent
7d339be14a
commit
c9660bd69f
|
@ -62,6 +62,8 @@ if(CONFIG_LV_TOUCH_CONTROLLER)
|
||||||
list(APPEND SOURCES "lvgl_touch/xpt2046.c")
|
list(APPEND SOURCES "lvgl_touch/xpt2046.c")
|
||||||
elseif(CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
|
elseif(CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
|
||||||
list(APPEND SOURCES "lvgl_touch/ft6x36.c")
|
list(APPEND SOURCES "lvgl_touch/ft6x36.c")
|
||||||
|
elseif(CONFIG_LV_TOUCH_CONTROLLER_L58)
|
||||||
|
list(APPEND SOURCES "lvgl_touch/l58.cpp")
|
||||||
elseif(CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
|
elseif(CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
|
||||||
list(APPEND SOURCES "lvgl_touch/stmpe610.c")
|
list(APPEND SOURCES "lvgl_touch/stmpe610.c")
|
||||||
elseif(CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)
|
elseif(CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)
|
||||||
|
|
|
@ -147,19 +147,21 @@ void lvgl_driver_init(void)
|
||||||
|
|
||||||
touch_driver_init();
|
touch_driver_init();
|
||||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_I2C)
|
#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");
|
ESP_LOGI(TAG, "Initializing I2C master for touch");
|
||||||
|
|
||||||
lvgl_i2c_driver_init(TOUCH_I2C_PORT,
|
lvgl_i2c_driver_init(TOUCH_I2C_PORT,
|
||||||
TOUCH_I2C_SDA, TOUCH_I2C_SCL,
|
TOUCH_I2C_SDA, TOUCH_I2C_SCL,
|
||||||
TOUCH_I2C_SPEED_HZ);
|
TOUCH_I2C_SPEED_HZ);
|
||||||
|
|
||||||
touch_driver_init();
|
touch_driver_init();
|
||||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_ADC)
|
#elif defined (CONFIG_LV_TOUCH_DRIVER_ADC)
|
||||||
touch_driver_init();
|
touch_driver_init();
|
||||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_DISPLAY)
|
#elif defined (CONFIG_LV_TOUCH_DRIVER_DISPLAY) || defined (CONFIG_LV_TOUCH_CONTROLLER_L58)
|
||||||
touch_driver_init();
|
touch_driver_init();
|
||||||
#else
|
#else
|
||||||
#error "No protocol defined for touch controller"
|
#error "No protocol defined for touch controller"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,7 @@ menu "LVGL Touch controller"
|
||||||
default 4 if LV_TOUCH_CONTROLLER_ADCRAW
|
default 4 if LV_TOUCH_CONTROLLER_ADCRAW
|
||||||
default 5 if LV_TOUCH_CONTROLLER_FT81X
|
default 5 if LV_TOUCH_CONTROLLER_FT81X
|
||||||
default 6 if LV_TOUCH_CONTROLLER_RA8875
|
default 6 if LV_TOUCH_CONTROLLER_RA8875
|
||||||
|
default 7 if LV_TOUCH_CONTROLLER_L58
|
||||||
choice
|
choice
|
||||||
prompt "Select a touch panel controller model."
|
prompt "Select a touch panel controller model."
|
||||||
default LV_TOUCH_CONTROLLER_NONE
|
default LV_TOUCH_CONTROLLER_NONE
|
||||||
|
@ -24,6 +24,12 @@ menu "LVGL Touch controller"
|
||||||
config LV_TOUCH_CONTROLLER_FT6X06
|
config LV_TOUCH_CONTROLLER_FT6X06
|
||||||
select LV_TOUCH_DRIVER_PROTOCOL_I2C
|
select LV_TOUCH_DRIVER_PROTOCOL_I2C
|
||||||
bool "FT6X06"
|
bool "FT6X06"
|
||||||
|
|
||||||
|
config LV_TOUCH_CONTROLLER_L58
|
||||||
|
# Start only touch without protocol:
|
||||||
|
select CONFIG_LV_TOUCH_DRIVER_DISPLAY
|
||||||
|
bool "L58"
|
||||||
|
|
||||||
config LV_TOUCH_CONTROLLER_STMPE610
|
config LV_TOUCH_CONTROLLER_STMPE610
|
||||||
select LV_TOUCH_DRIVER_PROTOCOL_SPI
|
select LV_TOUCH_DRIVER_PROTOCOL_SPI
|
||||||
bool "STMPE610"
|
bool "STMPE610"
|
||||||
|
@ -90,6 +96,37 @@ menu "LVGL Touch controller"
|
||||||
bool "FSPI" if IDF_TARGET_ESP32S2
|
bool "FSPI" if IDF_TARGET_ESP32S2
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
menu "Touchpanel (L58) Lilygo Pin Assignments"
|
||||||
|
depends on LV_TOUCH_CONTROLLER_L58
|
||||||
|
|
||||||
|
config LV_TOUCH_I2C_SDA
|
||||||
|
int
|
||||||
|
prompt "GPIO for SDA (I2C)"
|
||||||
|
range 0 39 if IDF_TARGET_ESP32
|
||||||
|
range 0 43 if IDF_TARGET_ESP32S2
|
||||||
|
|
||||||
|
default 15
|
||||||
|
help
|
||||||
|
Configure the I2C touchpanel SDA pin here.
|
||||||
|
|
||||||
|
config LV_TOUCH_I2C_SCL
|
||||||
|
int "GPIO for clock signal SCL (I2C)"
|
||||||
|
range 0 39 if IDF_TARGET_ESP32
|
||||||
|
range 0 43 if IDF_TARGET_ESP32S2
|
||||||
|
|
||||||
|
default 14
|
||||||
|
help
|
||||||
|
Configure the I2C touchpanel SCL pin here.
|
||||||
|
config LV_TOUCH_INT
|
||||||
|
int "GPIO for Interrupt pin (INT)"
|
||||||
|
range 0 39 if IDF_TARGET_ESP32
|
||||||
|
range 0 43 if IDF_TARGET_ESP32S2
|
||||||
|
|
||||||
|
default 13
|
||||||
|
help
|
||||||
|
Configure the INT Pin (Low on event)
|
||||||
|
endmenu
|
||||||
|
|
||||||
menu "Touchpanel (XPT2046) Pin Assignments"
|
menu "Touchpanel (XPT2046) Pin Assignments"
|
||||||
depends on LV_TOUCH_CONTROLLER_XPT2046
|
depends on LV_TOUCH_CONTROLLER_XPT2046
|
||||||
|
|
||||||
|
|
55
lvgl_touch/l58.cpp
Normal file
55
lvgl_touch/l58.cpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2020 Martin Fasani
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
* software and associated documentation files (the “Software”), to deal in the Software
|
||||||
|
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
* to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
* substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <esp_log.h>
|
||||||
|
#include <driver/i2c.h>
|
||||||
|
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#include <lvgl.h>
|
||||||
|
#else
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#endif
|
||||||
|
#include "l58.h"
|
||||||
|
#include "tp_i2c.h"
|
||||||
|
#include "../lvgl_i2c_conf.h"
|
||||||
|
|
||||||
|
#define TAG "L58"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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()");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the touch screen X and Y positions values. Ignores multi touch
|
||||||
|
* @param drv:
|
||||||
|
* @param data: Store data here
|
||||||
|
* @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
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
58
lvgl_touch/l58.h
Normal file
58
lvgl_touch/l58.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef __L58_H
|
||||||
|
/*
|
||||||
|
* Copyright © 2020 Martin Fasani. Refectored from original driver in https://github.com/martinberlin/FT6X36-IDF (C++)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
* software and associated documentation files (the “Software”), to deal in the Software
|
||||||
|
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
* to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
* substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __L58_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
|
||||||
|
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the touch screen X and Y positions values. Ignores multi touch
|
||||||
|
* @param drv:
|
||||||
|
* @param data: Store data here
|
||||||
|
* @retval Always false
|
||||||
|
*/
|
||||||
|
bool l58_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* __FT6X06_H */
|
|
@ -5,7 +5,8 @@
|
||||||
#include "touch_driver.h"
|
#include "touch_driver.h"
|
||||||
#include "tp_spi.h"
|
#include "tp_spi.h"
|
||||||
#include "tp_i2c.h"
|
#include "tp_i2c.h"
|
||||||
|
// Is not being included in CMakeLists.txt (Research why)
|
||||||
|
#include "l58.cpp"
|
||||||
|
|
||||||
void touch_driver_init(void)
|
void touch_driver_init(void)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +14,8 @@ void touch_driver_init(void)
|
||||||
xpt2046_init();
|
xpt2046_init();
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
|
||||||
ft6x06_init(FT6236_I2C_SLAVE_ADDR);
|
ft6x06_init(FT6236_I2C_SLAVE_ADDR);
|
||||||
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_L58)
|
||||||
|
// Do nothing for now
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
|
||||||
stmpe610_init();
|
stmpe610_init();
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)
|
||||||
|
@ -32,6 +35,9 @@ bool touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||||
res = xpt2046_read(drv, data);
|
res = xpt2046_read(drv, data);
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_FT6X06)
|
||||||
res = ft6x36_read(drv, data);
|
res = ft6x36_read(drv, data);
|
||||||
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_L58)
|
||||||
|
res = l58_read(drv, data);
|
||||||
|
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_STMPE610)
|
||||||
res = stmpe610_read(drv, data);
|
res = stmpe610_read(drv, data);
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_ADCRAW)
|
||||||
|
|
Loading…
Reference in a new issue