• ESP32-S2 st7789 SPI TFT彩屏240X320


    例子乐鑫官方 esp-iot-solution/examples/hmi/lvgl_example

    点左下角齿轮(SDK Configuration Editor)选择开发板为

    Saola With Esp32S2 Onboard From Espressif

    设置USB输出调试文字

    修改头文件中引脚:

     D:\esp-iot-solution\examples\common_components\boards\esp32s2-saola-1\board.h

    1. #define BOARD_IO_SPI2_SCK 36 //FSPICLK 接屏幕的SCL引脚
    2. #define BOARD_IO_SPI2_MOSI 35 //FSPID 截屏幕的SDA引脚
    3. #define BOARD_IO_SPI2_MISO 37 //不用接屏幕

    修改内容:

    D:\esp-iot-solution\examples\hmi\lvgl_example\main\app_main.c

    1. void app_main()
    2. {
    3. printf("Hello world!\n");
    4. /* Print chip information */
    5. esp_chip_info_t chip_info;
    6. uint32_t flash_size;
    7. esp_chip_info(&chip_info);
    8. printf("This is %s chip with %d CPU core(s), WiFi%s%s, ",
    9. CONFIG_IDF_TARGET,
    10. chip_info.cores,
    11. (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
    12. (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
    13. printf("silicon revision %d, ", chip_info.revision);
    14. // if(lv_list_get_size(NULL, &flash_size) != ESP_OK) {
    15. // printf("Get flash size failed");
    16. // return;
    17. // }
    18. // printf("%uMB %s flash\n", flash_size / (1024 * 1024),
    19. // (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
    20. printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());
    21. for (int i = 5; i >= 0; i--) {
    22. printf("Restarting in %d seconds...\n", i);
    23. vTaskDelay(1000 / portTICK_PERIOD_MS);
    24. }
    25. printf("Restarting now.\n");
    26. fflush(stdout);
    27. // esp_restart();
    28. iot_board_init();
    29. spi_bus_handle_t spi2_bus = iot_board_get_handle(BOARD_SPI2_ID);
    30. //60MHz刚好合适,高了屏幕闪烁,低了FPS太低
    31. #define BOARD_LCD_SPI_CLOCK_FREQ 60000000
    32. scr_driver_t lcd_drv;
    33. touch_panel_driver_t touch_drv;
    34. scr_interface_spi_config_t spi_lcd_cfg = {
    35. .spi_bus = spi2_bus,
    36. .pin_num_cs = 34, //FSPICS0 接屏幕的CS引脚
    37. .pin_num_dc = 33, //FSPIHD 接屏幕的A0引脚
    38. .clk_freq = BOARD_LCD_SPI_CLOCK_FREQ,
    39. .swap_data = true,
    40. };
    41. scr_interface_driver_t *iface_drv;
    42. scr_interface_create(SCREEN_IFACE_SPI, &spi_lcd_cfg, &iface_drv);
    43. scr_controller_config_t lcd_cfg = {
    44. .interface_drv = iface_drv,
    45. .pin_num_rst = 9, //FSPIHD 接屏幕的RESET引脚
    46. .pin_num_bckl = 38,//FSPIWP 接屏幕的BL引脚 背光
    47. .rst_active_level = 0,
    48. .bckl_active_level = 1,
    49. .offset_hor = 0,
    50. .offset_ver = 0,
    51. .width = 240,
    52. .height = 320,
    53. .rotate = SCR_DIR_TBRL,//防止镜像显示
    54. };
    55. scr_find_driver(SCREEN_CONTROLLER_ST7789, &lcd_drv);
    56. lcd_drv.init(&lcd_cfg);
    57. // touch_panel_config_t touch_cfg = {
    58. // .interface_spi = {
    59. // .spi_bus = spi2_bus,
    60. // .pin_num_cs = BOARD_TOUCH_SPI_CS_PIN,
    61. // .clk_freq = 10000000,
    62. // },
    63. // .interface_type = TOUCH_PANEL_IFACE_SPI,
    64. // .pin_num_int = -1,
    65. // .direction = TOUCH_DIR_TBLR,
    66. // .width = 240,
    67. // .height = 320,
    68. // };
    69. // touch_panel_find_driver(TOUCH_PANEL_CONTROLLER_XPT2046, &touch_drv);
    70. // touch_drv.init(&touch_cfg);
    71. // touch_drv.calibration_run(&lcd_drv, false);
    72. /* Initialize LittlevGL GUI */
    73. lvgl_init(&lcd_drv, NULL);// &touch_drv);
    74. lvgl_acquire();
    75. #ifdef CONFIG_LV_DEMO_BENCHMARK
    76. lv_demo_benchmark();
    77. #elif defined CONFIG_LV_DEMO_PRINTER
    78. lv_demo_printer();
    79. #elif defined CONFIG_LV_DEMO_WIDGETS
    80. lv_demo_widgets();
    81. #elif defined CONFIG_LV_EX_GET_STARTED
    82. lv_ex_get_started_1();
    83. #elif defined CONFIG_LV_DEMO_STRESS
    84. lv_demo_stress();
    85. #elif defined CONFIG_LV_EX_STYLE
    86. lv_ex_style_1();
    87. #endif
    88. lvgl_release();
    89. ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version());
    90. ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
    91. }

    BENCHMARK

    STRESS

    ESP32-S2 SPI TFT彩屏60MHz

  • 相关阅读:
    Leetcode LCR122:路径加密
    计算机网络层(2)
    nginx配置ip黑名单
    《动手学深度学习 Pytorch版》 5.2 参数管理
    Java 中的数据类型有哪些?
    图--拓扑排序
    MySQL——几种常见的嵌套查询
    用于物体识别和跟踪的下游任务自监督学习-2-背景
    Qt实现2D绘图
    1457. Pseudo-Palindromic Paths in a Binary Tree
  • 原文地址:https://blog.csdn.net/brook0344/article/details/126961896