Saltar a contenido

81. Pantalla Yellow display: lvgl esp32s020

Placa que incluye un esp32 y pantalla táctil con varias entradas y salidas: imagen

Comprado en Alliexpress

81.1 Características

  • Dual-core MCU, integrated WI-FI and Bluetooth functions
  • Frequency can reach 240MHz
  • 520KB SRAM, 448KB ROM, Flash size is 4MB
  • Module size 50.0×86.0mm
  • Operating Voltage: 5V
  • Power consumption: approximately 115mA
  • Product weight: approximately 50g
  • The module includes:
  • 2.8-inch color TFT display screen with ILI9341 driver chip
  • Display resolution: 240x320px with resistive touchscreen
  • Backlight control circuit
  • TF card interface for external storage
  • Serial interface
  • Temperature and humidity sensor interface (DHT11 interface) and reserved IO port interface
  • It can be programmed with: Arduino IDE, MicroPython, ESP-IDF

81.2 pines

pines

81.3 Libreria LVGL

LVGL es una librería opensource con elementos diversos para crear intefaces gráficos complejas.
Dispone de ejemplos

81.4 Librerías necesarias

ESP32 se comunicaca con la pantalla y el panel táctil medianteel bus SPI.

Necesitaresmo:

  • Libreria TFT_eSPI para el panel
  • XPT2046_Touchscreen para el panel táctil
  • LVGL 9 Library

81.5 Config Files for TFT_eSPI and LVGL Library

81.6 IDE PlatformIO

Pasos: (Basado en este repositorio)

81.6.1 Crear un proyecto nuevo con placa Expressif ESP32 Develop

81.6.2 Añadir librerias:

  1. lib_deps = https://github.com/rzeldent/esp32-smartdisplay.git
  2. Usando el menu de Platformio:

81.6.3 Crear el fichero de setting para lvgl

LVGL necesita un fichero lv_conf.h . Este fichero contiene información sobre los fonts, profundidad de colores, fondo por defeco, estilos, etc.

81.6.4 Usar las "flags siguiente para el proyecto

build_flags =
    -Ofast
    -Wall
    '-D BOARD_NAME="${this.board}"'
    '-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO'
    #'-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG'
    #'-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE'
    '-D LV_CONF_PATH=${platformio.include_dir}/lv_conf.h'

81.6.5 Ejemplo de fichero platformio.ini

Se añaden los pines para tft y touch de esta placa

[platformio]
src_dir = .
default_envs = cyd

[env]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps = 
    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
    bodmer/TFT_eSPI@^2.5.43

build_flags = 
    -DUSER_SETUP_LOADED
    -DUSE_HSPI_PORT
    -DTFT_MISO=12
    -DTFT_MOSI=13
    -DTFT_SCLK=14
    -DTFT_CS=15
    -DTFT_DC=2
    -DTFT_RST=-1
    -DTFT_BL=21
    -DTFT_BACKLIGHT_ON=HIGH
    -DSPI_FREQUENCY=55000000
    -DSPI_READ_FREQUENCY=20000000
    -DSPI_TOUCH_FREQUENCY=2500000
    -DLOAD_GLCD
    -DLOAD_FONT2
    -DLOAD_FONT4
    -DLOAD_FONT6
    -DLOAD_FONT7
    -DLOAD_FONT8
    -DLOAD_GFXFF

[env:cyd]
build_flags = 
    ${env.build_flags}
    -DILI9341_2_DRIVER
    -DTFT_RGB_ORDER=TFT_BGR
    -DTFT_INVERSION_ON
lib_deps = 
    lvgl/lvgl@^9.2.2
    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
    bodmer/TFT_eSPI@^2.5.43

81.6.6 Inicializar el display y entrada tactil en el proyecto

#include <Arduino.h>
#include <esp32_smartdisplay.h>

void setup()
{
  smartdisplay_init();

  auto display = lv_display_get_default();
  // lv_display_set_rotation(display, LV_DISPLAY_ROTATION_90);
  // lv_display_set_rotation(display, LV_DISPLAY_ROTATION_180);
  // lv_display_set_rotation(display, LV_DISPLAY_ROTATION_270);
}
y actualizar tick y bucle de dibujo:

auto lv_last_tick = millis();

void loop()
{
    auto const now = millis();
    // Update the ticker
    lv_tick_inc(now - lv_last_tick);
    lv_last_tick = now;
    // Update the UI
    lv_timer_handler();
}

81.7 Pantalla táctil

  1. Rango crudo de datos
    Los controladores de pantallas táctiles (como los basados en chips resistivos, como XPT2046) trabajan con convertidores ADC (analógico a digital) para medir las posiciones táctiles.
    Estos convertidores suelen tener un rango crudo que varía entre valores específicos (por ejemplo, 0 a 4095 en un ADC de 12 bits).
    En la práctica, el rango utilizable del panel táctil no cubre todo el rango de 0 a 4095 debido a:
  2. Tolerancias físicas del panel.
  3. Ruido o calibración del controlador.

81.7.1 Calibrado.

81.8 Apendice

81.8.1 Enlaces