Merge dd78dccca4
into 26fe6e7703
This commit is contained in:
commit
a24411f95a
12 changed files with 295 additions and 37 deletions
|
@ -73,6 +73,8 @@ if(CONFIG_LV_TOUCH_CONTROLLER)
|
||||||
list(APPEND SOURCES "lvgl_touch/ra8875_touch.c")
|
list(APPEND SOURCES "lvgl_touch/ra8875_touch.c")
|
||||||
elseif(CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
elseif(CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||||
list(APPEND SOURCES "lvgl_touch/gt911.c")
|
list(APPEND SOURCES "lvgl_touch/gt911.c")
|
||||||
|
elseif(CONFIG_LV_TOUCH_CONTROLLER_CST816)
|
||||||
|
list(APPEND SOURCES "lvgl_touch/CST816.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI)
|
if(CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI)
|
||||||
|
|
|
@ -175,7 +175,7 @@ bool lvgl_spi_driver_init(int host,
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Initializing SPI bus...");
|
ESP_LOGI(TAG, "Initializing SPI bus...");
|
||||||
#if defined (CONFIG_IDF_TARGET_ESP32C3)
|
#if defined (CONFIG_IDF_TARGET_ESP32C3) || defined (CONFIG_IDF_TARGET_ESP32S3)
|
||||||
dma_channel = SPI_DMA_CH_AUTO;
|
dma_channel = SPI_DMA_CH_AUTO;
|
||||||
#endif
|
#endif
|
||||||
esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)dma_channel);
|
esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)dma_channel);
|
||||||
|
|
|
@ -34,6 +34,12 @@ extern "C" {
|
||||||
* color format being used, for RGB565 each pixel needs 2 bytes.
|
* color format being used, for RGB565 each pixel needs 2 bytes.
|
||||||
* When using the mono theme, the display pixels can be represented in one bit,
|
* When using the mono theme, the display pixels can be represented in one bit,
|
||||||
* so the buffer size can be divided by 8, e.g. see SSD1306 display size. */
|
* so the buffer size can be divided by 8, e.g. see SSD1306 display size. */
|
||||||
|
|
||||||
|
//[BJ] Source: https://github.com/lvgl/lvgl_esp32_drivers/issues/202
|
||||||
|
# define LV_HOR_RES_MAX 320
|
||||||
|
# define LV_VER_RES_MAX 240
|
||||||
|
# define SPI_HOST_MAX 3
|
||||||
|
|
||||||
#if defined (CONFIG_CUSTOM_DISPLAY_BUFFER_SIZE)
|
#if defined (CONFIG_CUSTOM_DISPLAY_BUFFER_SIZE)
|
||||||
#define DISP_BUF_SIZE CONFIG_CUSTOM_DISPLAY_BUFFER_BYTES
|
#define DISP_BUF_SIZE CONFIG_CUSTOM_DISPLAY_BUFFER_BYTES
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -739,6 +739,20 @@ menu "LVGL TFT Display controller"
|
||||||
help
|
help
|
||||||
Use software reset and ignores configured reset pin (some hardware does not use a reset pin).
|
Use software reset and ignores configured reset pin (some hardware does not use a reset pin).
|
||||||
|
|
||||||
|
config LV_DISPLAY_USE_TE_PIN
|
||||||
|
bool "Enable TE (Tearing effect) pin"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Enable the TE pin to control the display. You can disable
|
||||||
|
it when the display does not need MISO signal to be controlled.
|
||||||
|
|
||||||
|
config LV_DISPLAY_TE_PIN
|
||||||
|
int "GPIO for TE (Tearing effect) pin"
|
||||||
|
depends on LV_DISPLAY_USE_TE_PIN
|
||||||
|
default 38
|
||||||
|
help
|
||||||
|
Configure the display TE pin here.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
# menu will be visible only when LV_PREDEFINED_DISPLAY_NONE is y
|
# menu will be visible only when LV_PREDEFINED_DISPLAY_NONE is y
|
||||||
|
|
|
@ -53,28 +53,28 @@ static void ili9341_send_color(void * data, uint16_t length);
|
||||||
void ili9341_init(void)
|
void ili9341_init(void)
|
||||||
{
|
{
|
||||||
lcd_init_cmd_t ili_init_cmds[]={
|
lcd_init_cmd_t ili_init_cmds[]={
|
||||||
{0xCF, {0x00, 0x83, 0X30}, 3},
|
// {0xCF, {0x00, 0x83, 0X30}, 3},
|
||||||
{0xED, {0x64, 0x03, 0X12, 0X81}, 4},
|
// {0xED, {0x64, 0x03, 0X12, 0X81}, 4},
|
||||||
{0xE8, {0x85, 0x01, 0x79}, 3},
|
// {0xE8, {0x85, 0x01, 0x79}, 3},
|
||||||
{0xCB, {0x39, 0x2C, 0x00, 0x34, 0x02}, 5},
|
// {0xCB, {0x39, 0x2C, 0x00, 0x34, 0x02}, 5},
|
||||||
{0xF7, {0x20}, 1},
|
// {0xF7, {0x20}, 1},
|
||||||
{0xEA, {0x00, 0x00}, 2},
|
// {0xEA, {0x00, 0x00}, 2},
|
||||||
{0xC0, {0x26}, 1}, /*Power control*/
|
{0xC0, {0x26}, 1}, /*Power control*/
|
||||||
{0xC1, {0x11}, 1}, /*Power control */
|
{0xC1, {0x11}, 1}, /*Power control */
|
||||||
{0xC5, {0x35, 0x3E}, 2}, /*VCOM control*/
|
{0xC5, {0x35, 0x3E}, 2}, /*VCOM control*/
|
||||||
{0xC7, {0xBE}, 1}, /*VCOM control*/
|
{0xC7, {0xBE}, 1}, /*VCOM control*/
|
||||||
{0x36, {0x28}, 1}, /*Memory Access Control*/
|
{0x36, {0x08}, 1}, //{0x36, {0x28}, 1}, /*Memory Access Control*/
|
||||||
{0x3A, {0x55}, 1}, /*Pixel Format Set*/
|
{0x3A, {0x55}, 1}, /*Pixel Format Set*/
|
||||||
{0xB1, {0x00, 0x1B}, 2},
|
{0xB1, {0x00, 0x18}, 2},//{0xB1, {0x00, 0x1B}, 2}, //[BJ] frame rate.
|
||||||
{0xF2, {0x08}, 1},
|
//{0xF2, {0x08}, 1},
|
||||||
{0x26, {0x01}, 1},
|
{0x26, {0x01}, 1}, //[BJ] Gamma set
|
||||||
{0xE0, {0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0X87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00}, 15},
|
{0xE0, {0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0X87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00}, 15},//[BJ] + Gamma correction
|
||||||
{0XE1, {0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F}, 15},
|
{0XE1, {0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F}, 15},//[BJ] - Gamma correction
|
||||||
{0x2A, {0x00, 0x00, 0x00, 0xEF}, 4},
|
{0x2A, {0x00, 0x00, 0x00, 0xEF}, 4}, //[BJ] column address set
|
||||||
{0x2B, {0x00, 0x00, 0x01, 0x3f}, 4},
|
{0x2B, {0x00, 0x00, 0x01, 0x3f}, 4},//[BJ] page address set
|
||||||
{0x2C, {0}, 0},
|
{0x2C, {0}, 0},//[BJ] memory write.
|
||||||
{0xB7, {0x07}, 1},
|
{0xB7, {0x07}, 1},//[BJ] Entry mode set
|
||||||
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4},
|
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4}, //[BJ] display function control
|
||||||
{0x11, {0}, 0x80},
|
{0x11, {0}, 0x80},
|
||||||
{0x29, {0}, 0x80},
|
{0x29, {0}, 0x80},
|
||||||
{0, {0}, 0xff},
|
{0, {0}, 0xff},
|
||||||
|
@ -108,7 +108,7 @@ void ili9341_init(void)
|
||||||
cmd++;
|
cmd++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
// ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||||
|
|
||||||
#if ILI9341_INVERT_COLORS == 1
|
#if ILI9341_INVERT_COLORS == 1
|
||||||
ili9341_send_cmd(0x21);
|
ili9341_send_cmd(0x21);
|
||||||
|
@ -187,25 +187,25 @@ static void ili9341_send_color(void * data, uint16_t length)
|
||||||
static void ili9341_set_orientation(uint8_t orientation)
|
static void ili9341_set_orientation(uint8_t orientation)
|
||||||
{
|
{
|
||||||
// ESP_ASSERT(orientation < 4);
|
// ESP_ASSERT(orientation < 4);
|
||||||
|
// orientation = 2;
|
||||||
|
// const char *orientation_str[] = {
|
||||||
|
// "PORTRAIT", "PORTRAIT_INVERTED", "LANDSCAPE", "LANDSCAPE_INVERTED"
|
||||||
|
// };
|
||||||
|
|
||||||
const char *orientation_str[] = {
|
// ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
|
||||||
"PORTRAIT", "PORTRAIT_INVERTED", "LANDSCAPE", "LANDSCAPE_INVERTED"
|
|
||||||
};
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
|
// #if defined CONFIG_LV_PREDEFINED_DISPLAY_M5STACK
|
||||||
|
// uint8_t data[] = {0x68, 0x68, 0x08, 0x08};
|
||||||
|
// #elif defined (CONFIG_LV_PREDEFINED_DISPLAY_M5CORE2)
|
||||||
|
// uint8_t data[] = {0x08, 0x88, 0x28, 0xE8};
|
||||||
|
// #elif defined (CONFIG_LV_PREDEFINED_DISPLAY_WROVER4)
|
||||||
|
// uint8_t data[] = {0x6C, 0xEC, 0xCC, 0x4C};
|
||||||
|
// #elif defined (CONFIG_LV_PREDEFINED_DISPLAY_NONE)
|
||||||
|
// uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
|
||||||
|
// #endif
|
||||||
|
|
||||||
#if defined CONFIG_LV_PREDEFINED_DISPLAY_M5STACK
|
// ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
|
||||||
uint8_t data[] = {0x68, 0x68, 0x08, 0x08};
|
|
||||||
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_M5CORE2)
|
|
||||||
uint8_t data[] = {0x08, 0x88, 0x28, 0xE8};
|
|
||||||
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_WROVER4)
|
|
||||||
uint8_t data[] = {0x6C, 0xEC, 0xCC, 0x4C};
|
|
||||||
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_NONE)
|
|
||||||
uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
|
// ili9341_send_cmd(0x36);
|
||||||
|
// ili9341_send_data((void *) &data[orientation], 1);
|
||||||
ili9341_send_cmd(0x36);
|
|
||||||
ili9341_send_data((void *) &data[orientation], 1);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,14 @@ void st7789_init(void)
|
||||||
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4},
|
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4},
|
||||||
{ST7789_SLPOUT, {0}, 0x80},
|
{ST7789_SLPOUT, {0}, 0x80},
|
||||||
{ST7789_DISPON, {0}, 0x80},
|
{ST7789_DISPON, {0}, 0x80},
|
||||||
|
#ifdef CONFIG_LV_DISPLAY_USE_TE_PIN
|
||||||
|
{ST7789_TEON, {0}, 1}, //[BJ] turn on TE
|
||||||
|
#endif
|
||||||
|
//-----------
|
||||||
|
//[BJ] Below I am trying to change refresh rate of the screen
|
||||||
|
//{ST7789_FRCTR2,{0x1F},1}, //[BJ] set the refresh rate
|
||||||
|
//{ST7789_FRCTRL1,{0x01, 0x0F, 0x0F},3}, //[BJ] divide the refresh by 2.
|
||||||
|
// ----------------------------------------
|
||||||
{0, {0}, 0xff},
|
{0, {0}, 0xff},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,6 +102,11 @@ void st7789_init(void)
|
||||||
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
|
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LV_DISPLAY_USE_TE_PIN
|
||||||
|
gpio_pad_select_gpio(ST7789_TE);
|
||||||
|
gpio_set_direction(ST7789_TE, GPIO_MODE_INPUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
//Reset the display
|
//Reset the display
|
||||||
#if !defined(ST7789_SOFT_RST)
|
#if !defined(ST7789_SOFT_RST)
|
||||||
gpio_set_level(ST7789_RST, 0);
|
gpio_set_level(ST7789_RST, 0);
|
||||||
|
@ -208,7 +221,7 @@ void st7789_send_data(void * data, uint16_t length)
|
||||||
|
|
||||||
static void st7789_send_color(void * data, size_t length)
|
static void st7789_send_color(void * data, size_t length)
|
||||||
{
|
{
|
||||||
disp_wait_for_pending_transactions();
|
// disp_wait_for_pending_transactions();
|
||||||
gpio_set_level(ST7789_DC, 1);
|
gpio_set_level(ST7789_DC, 1);
|
||||||
disp_spi_send_colors(data, length);
|
disp_spi_send_colors(data, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ extern "C"
|
||||||
|
|
||||||
#define ST7789_DC CONFIG_LV_DISP_PIN_DC
|
#define ST7789_DC CONFIG_LV_DISP_PIN_DC
|
||||||
#define ST7789_RST CONFIG_LV_DISP_PIN_RST
|
#define ST7789_RST CONFIG_LV_DISP_PIN_RST
|
||||||
|
#define ST7789_TE CONFIG_LV_DISPLAY_TE_PIN
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_LV_DISP_USE_RST
|
#if CONFIG_LV_DISP_USE_RST
|
||||||
#if CONFIG_LV_DISP_ST7789_SOFT_RESET
|
#if CONFIG_LV_DISP_ST7789_SOFT_RESET
|
||||||
|
|
123
lvgl_touch/CST816.c
Normal file
123
lvgl_touch/CST816.c
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2022 Band Industries Inc.
|
||||||
|
|
||||||
|
* 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>
|
||||||
|
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#include <lvgl.h>
|
||||||
|
#else
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#endif
|
||||||
|
#include "CST816.h"
|
||||||
|
|
||||||
|
#include "lvgl_i2c/i2c_manager.h"
|
||||||
|
|
||||||
|
#define TAG "CST816"
|
||||||
|
|
||||||
|
uint8_t CST816_addr;
|
||||||
|
|
||||||
|
static esp_err_t _cst816_i2c_read(uint8_t slave_addr, uint8_t register_addr, uint8_t *data_buf, uint8_t 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) {
|
||||||
|
// return lvgl_i2c_write(CONFIG_LV_I2C_TOUCH_PORT, slave_addr, register_addr, &data, 1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize for cst816 communication via I2C
|
||||||
|
* @param dev_addr: Device address on communication Bus (I2C slave address of cst816).
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void cst816_init(uint8_t dev_addr) {
|
||||||
|
CST816_addr = dev_addr;
|
||||||
|
uint8_t version;
|
||||||
|
uint8_t versionInfo[3];
|
||||||
|
esp_err_t ret;
|
||||||
|
ESP_LOGI(TAG, "Initializing cst816 %d", dev_addr);
|
||||||
|
if ((ret = _cst816_i2c_read(dev_addr, 0x15, &version, 1) != ESP_OK))
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Error reading version from device: %s",
|
||||||
|
esp_err_to_name(ret)); // Only show error the first time
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((ret = _cst816_i2c_read(dev_addr, 0xA7, versionInfo, 3) != ESP_OK))
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Error reading versionInfo from device: %s",
|
||||||
|
esp_err_to_name(ret)); // Only show error the first time
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "CST816 version %d, versionInfo: %d.%d.%d", version, versionInfo[0], versionInfo[1], versionInfo[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the touch screen X and Y positions values. Ignores multi touch
|
||||||
|
* @param drv:
|
||||||
|
* @param data: Store data here
|
||||||
|
* @retval Always false
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool cst816_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t data_raw[8] ;
|
||||||
|
_cst816_i2c_read(CST816_addr, 0x01, data_raw, 6);
|
||||||
|
// printf("Touch data: ");
|
||||||
|
// for(int i = 0; i < 6; i++)
|
||||||
|
// {
|
||||||
|
// printf("0x%02X ", data_raw[i]);
|
||||||
|
// }
|
||||||
|
// printf("\r\n");
|
||||||
|
|
||||||
|
uint8_t gestureID = data_raw[0];
|
||||||
|
uint8_t points = data_raw[1];
|
||||||
|
uint8_t event = data_raw[2] >> 6;
|
||||||
|
uint16_t point_x = 0;
|
||||||
|
uint16_t point_y = 0;
|
||||||
|
if(points == 0)
|
||||||
|
{
|
||||||
|
data->state = LV_INDEV_STATE_RELEASED;
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
data->state = LV_INDEV_STATE_PRESSED;
|
||||||
|
point_x = (data_raw[3] | ((data_raw[2] & 0x0F) << 8));
|
||||||
|
point_y = (data_raw[5] | ((data_raw[4] & 0x0F) << 8));
|
||||||
|
|
||||||
|
#if CONFIG_LV_SWAPXY_CST816
|
||||||
|
int temp;
|
||||||
|
temp = point_y;
|
||||||
|
point_y = point_x;
|
||||||
|
point_x = temp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_LV_INVERT_X_CST816
|
||||||
|
point_x = CONFIG_LV_TOUCH_X_MAX_CST816 - point_x;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_LV_INVERT_Y_CST816
|
||||||
|
point_y = CONFIG_LV_TOUCH_Y_MAX_CST816 - point_y;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
data->point.x = point_x;
|
||||||
|
data->point.y = point_y;
|
||||||
|
ESP_LOGI(TAG, "gestureID %d, points %d, event %d X=%u Y=%u", gestureID, points, event, data->point.x, data->point.y);
|
||||||
|
return false;
|
||||||
|
}
|
56
lvgl_touch/CST816.h
Normal file
56
lvgl_touch/CST816.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef __CST816_H
|
||||||
|
/*
|
||||||
|
* Copyright © 2022 Band Industries Inc.
|
||||||
|
|
||||||
|
* 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 __CST816_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CST816_I2C_SLAVE_ADDR 0x15
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize for cst816 communication via I2C
|
||||||
|
* @param dev_addr: Device address on communication Bus (I2C slave address of CST816).
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void cst816_init(uint8_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 cst816_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* __CST816_H */
|
|
@ -10,6 +10,7 @@ menu "LVGL Touch controller"
|
||||||
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_GT911
|
default 7 if LV_TOUCH_CONTROLLER_GT911
|
||||||
|
default 8 if LV_TOUCH_CONTROLLER_CST816
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "Select a touch panel controller model."
|
prompt "Select a touch panel controller model."
|
||||||
|
@ -40,6 +41,9 @@ menu "LVGL Touch controller"
|
||||||
config LV_TOUCH_CONTROLLER_GT911
|
config LV_TOUCH_CONTROLLER_GT911
|
||||||
select LV_I2C_TOUCH
|
select LV_I2C_TOUCH
|
||||||
bool "GT911"
|
bool "GT911"
|
||||||
|
config LV_TOUCH_CONTROLLER_CST816
|
||||||
|
select LV_I2C_TOUCH
|
||||||
|
bool "CST816"
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config LV_TOUCH_DRIVER_PROTOCOL_SPI
|
config LV_TOUCH_DRIVER_PROTOCOL_SPI
|
||||||
|
@ -441,6 +445,38 @@ menu "LVGL Touch controller"
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
menu "Touchpanel Configuration (CST816)"
|
||||||
|
depends on LV_TOUCH_CONTROLLER_CST816
|
||||||
|
|
||||||
|
config LV_TOUCH_X_MAX_CST816
|
||||||
|
int
|
||||||
|
prompt "Maximum X coordinate ADC value"
|
||||||
|
range 0 1023
|
||||||
|
default 320
|
||||||
|
|
||||||
|
config LV_TOUCH_Y_MAX_CST816
|
||||||
|
int
|
||||||
|
prompt "Maximum Y coordinate ADC value"
|
||||||
|
range 0 1023
|
||||||
|
default 240
|
||||||
|
|
||||||
|
config LV_SWAPXY_CST816
|
||||||
|
bool
|
||||||
|
prompt "Swap X with Y coordinate."
|
||||||
|
default n
|
||||||
|
|
||||||
|
config LV_INVERT_X_CST816
|
||||||
|
bool
|
||||||
|
prompt "Invert X coordinate value."
|
||||||
|
default n
|
||||||
|
|
||||||
|
config LV_INVERT_Y_CST816
|
||||||
|
bool
|
||||||
|
prompt "Invert Y coordinate value."
|
||||||
|
default n
|
||||||
|
|
||||||
|
endmenu
|
||||||
|
|
||||||
menu "Touchpanel Configuration (GT911)"
|
menu "Touchpanel Configuration (GT911)"
|
||||||
depends on LV_TOUCH_CONTROLLER_GT911
|
depends on LV_TOUCH_CONTROLLER_GT911
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ void touch_driver_init(void)
|
||||||
ra8875_touch_init();
|
ra8875_touch_init();
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||||
gt911_init(GT911_I2C_SLAVE_ADDR);
|
gt911_init(GT911_I2C_SLAVE_ADDR);
|
||||||
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_CST816)
|
||||||
|
cst816_init(CST816_I2C_SLAVE_ADDR);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +49,8 @@ bool touch_driver_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||||
res = ra8875_touch_read(drv, data);
|
res = ra8875_touch_read(drv, data);
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||||
res = gt911_read(drv, data);
|
res = gt911_read(drv, data);
|
||||||
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_CST816)
|
||||||
|
res = cst816_read(drv, data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LVGL_VERSION_MAJOR >= 8
|
#if LVGL_VERSION_MAJOR >= 8
|
||||||
|
|
|
@ -34,6 +34,8 @@ extern "C" {
|
||||||
#include "ra8875_touch.h"
|
#include "ra8875_touch.h"
|
||||||
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_GT911)
|
||||||
#include "gt911.h"
|
#include "gt911.h"
|
||||||
|
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_CST816)
|
||||||
|
#include "CST816.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue