您的位置:首页 > 新闻 > 热点要闻 > 湖南衡阳今日疫情_扬州网站建设制作_代发广告平台_网页推广怎么做

湖南衡阳今日疫情_扬州网站建设制作_代发广告平台_网页推广怎么做

2025/2/25 3:44:17 来源:https://blog.csdn.net/weixin_42880082/article/details/145683603  浏览:    关键词:湖南衡阳今日疫情_扬州网站建设制作_代发广告平台_网页推广怎么做
湖南衡阳今日疫情_扬州网站建设制作_代发广告平台_网页推广怎么做

ESP32 ESP-IDF TFT-LCD(ST7735 128x160) LVGL基本配置和使用


  • 📍项目地址:https://github.com/lvgl/lv_port_esp32
  • 参考文章:https://blog.csdn.net/chentuo2000/article/details/126668088
  • https://blog.csdn.net/p1279030826/article/details/120128339
  • 🔖ESP-IDF版本:v5.4
  • ESP32引脚功能图:
    在这里插入图片描述
  • 通过git命令将项目和所需的子模块全部下载到本地:(需要提前安装好git工具)
git clone --recurse-submodules https://github.com/lvgl/lv_port_esp32.git

SPI接口和引脚说明

ESP32 提供了两个独立的SPI主机接口,HSPI 和 VSPI.

  • ESP32与ST7735 HSPI连接:
    在这里插入图片描述
  • ESP32与ST7735 VSPI连接图:
    在这里插入图片描述

📑配置和参数修改说明

  • 🌿在st7735s.h参数修改:
//st7735s.h
#define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 / 1 offset)
#define COLSTART            0       //默认参数:26
#define ROWSTART           0    // 默认参数:1
  • 🌿在SDK配置编辑器中(menuconfig)
  • 屏幕像素参数配置:
    在这里插入图片描述
    在这里插入图片描述
  • VSPI引脚:(可以参考前面的图进行配置)
    在这里插入图片描述

  • 字体选择:
    在这里插入图片描述

  • demo屏幕显示示例选择:在这里插入图片描述

  • 触摸组件控制功能没有开启

  • 在这里插入图片描述

🛠初次编译报错处理

  • 在没有使用触摸组件情况下,编译器会报找不到相关定义: error: 'CONFIG_LV_AXP192_PIN_SDA'

参考上面文章的做法,将启用相关宏定义 CONFIG_LV_M5STICKC_HANDLE_AXP192 的判断,来跳过对应的代码。

//st7735s.h
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
#define AXP192_SDA   CONFIG_LV_AXP192_PIN_SDA
#define AXP192_SCL   CONFIG_LV_AXP192_PIN_SCL
#endif
//st7735s.c
static void i2c_master_init()
{
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192i2c_config_t i2c_config = {.mode               = I2C_MODE_MASTER,.sda_io_num         = AXP192_SDA,.scl_io_num         = AXP192_SCL,.sda_pullup_en      = GPIO_PULLUP_ENABLE,.scl_pullup_en      = GPIO_PULLUP_ENABLE,.master.clk_speed   = 400000};i2c_param_config(I2C_NUM_0, &i2c_config);i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
#endif
}
  • main.c中报错error: implicit declaration of function 'esp_timer_start_periodic' [-Wimplicit-function-declaration]添加对应的头文件
#include "esp_timer.h" // 添加这一行
  • 🌿编译找不到gpio_pad_select_gpio函数,使用函数替代:
esp_rom_gpio_pad_select_gpio
  • 编译成功并烧录后,如果配置的demo显示示例选择的是:Show demo widgets,屏幕可以显示一行:Hello World
    在这里插入图片描述
    所执行的是,main.c中的下面对应的函数:
static void create_demo_application(void)
{/* When using a monochrome display we only show "Hello World" centered on the* screen */
#if defined CONFIG_LV_TFT_DISPLAY_MONOCHROME || \defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S/* use a pretty small demo for monochrome displays *//* Get the current screen  */lv_obj_t * scr = lv_disp_get_scr_act(NULL);/*Create a Label on the currently active screen*/lv_obj_t * label1 =  lv_label_create(scr, NULL);/*Modify the Label's text*/lv_label_set_text(label1, "Hello\nworld");/* Align the Label to the center* NULL means align on parent (which is the screen now)* 0, 0 at the end means an x, y offset after alignment*/lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);
#else/* Otherwise we show the selected demo */#if defined CONFIG_LV_USE_DEMO_WIDGETSlv_demo_widgets();#elif defined CONFIG_LV_USE_DEMO_KEYPAD_AND_ENCODERlv_demo_keypad_encoder();#elif defined CONFIG_LV_USE_DEMO_BENCHMARKlv_demo_benchmark();#elif defined CONFIG_LV_USE_DEMO_STRESSlv_demo_stress();#else#error "No demo application selected."#endif
#endif
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com