wirano / st77903_demo Goto Github PK
View Code? Open in Web Editor NEWA ESP32-S3 demo for ST77903 driven LCD, with a LVGL port.
License: MIT License
A ESP32-S3 demo for ST77903 driven LCD, with a LVGL port.
License: MIT License
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_err.h"
#include "esp_log.h"
#include "driver/i2c.h"
#include "esp_lcd_touch_cst816s.h"
#define CST816D_SDA 8
#define CST816D_SCL 9
#define CST816D_RST -1 // 高电平
#define CST816D_INT -1 // CST816D可以悬空,CST816T接地
#define CONFIG_LCD_HRES 400
#define CONFIG_LCD_VRES 400
static const char *TAG = "example";
void app_main(void)
{
uint16_t touch_x[1];
uint16_t touch_y[1];
uint16_t touch_strength[1];
uint8_t touch_cnt = 0;
esp_lcd_touch_handle_t tp = NULL;
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = CST816D_SDA,
.scl_io_num = CST816D_SCL,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = 400000, // 400kHz
};
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &i2c_conf));
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, i2c_conf.mode, 0, 0, 0));
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
ESP_LOGI(TAG, "Initialize touch IO (I2C)");
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)I2C_NUM_0, &tp_io_config, &tp_io_handle));
esp_lcd_touch_config_t tp_cfg = {
.x_max = CONFIG_LCD_HRES,
.y_max = CONFIG_LCD_VRES,
.rst_gpio_num = CST816D_RST,
.int_gpio_num = CST816D_INT,
.levels = {
.reset = 0,
.interrupt = 0,
},
.flags = {
.swap_xy = 0,
.mirror_x = 0,
.mirror_y = 0,
},
};
ESP_LOGI(TAG, "Initialize touch controller CST816D");
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_cst816s(tp_io_handle, &tp_cfg, &tp));
while (1)
{
esp_lcd_touch_read_data(tp);
bool touchpad_pressed = esp_lcd_touch_get_coordinates(tp, touch_x, touch_y, touch_strength, &touch_cnt, 1);
if (touchpad_pressed)
{
printf("x:%d,y:%d\n", touch_x[0], touch_y[0]);
}
}
}
Leave footprints for reference only
https://components.espressif.com/components/espressif/esp_lcd_touch_cst816s
Official sample code
请问,ST77935的初始化参数代码, 怎么结合手册看, 无法看明白, 比如CMD为0xf0, 手册里压根没有这个CMD啊
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.