Often sold as a "LVGL" development board. AliExpress
Full configuration can be found at esp32-2432s028.yaml.
esphome:
name: screen
includes:
- display_functions.h
on_boot:
- lambda: |-
uint8_t val = 0x40;
uint8_t len = 1;
my_display->send_command(esphome::ili9xxx::ILI9XXX_MADCTL, &val, len);
- Include the display_functions.h re-used display components library (found in this repoistory)
- Manual configuration of the Memory Addressing type for the display to bet set on boot.
esp32:
board: esp32dev
framework:
type: arduino
- Standard esp32 development board configuration
spi:
- clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
id: bus_tft
- clk_pin: GPIO25
mosi_pin: GPIO32
miso_pin: GPIO39
id: bus_ts
-
bus_tft is the SPI bus used by the TFT Display
-
bus_ts is the SPI bus used by the Touchscreen
-
TODO: SD Card support?
i2c:
- sda: GPIO27
scl: GPIO22
scan: true
id: bus_a
- I don't currently use i2c on the coffee table device however I define the bus anyway.
touchscreen:
platform: xpt2046
interrupt_pin: 36
cs_pin: 33
display: my_display
id: my_touchscreen
spi_id: bus_ts
update_interval: 50ms
report_interval: 1s
threshold: 400
calibration_x_min: 3775
calibration_x_max: 404
calibration_y_min: 3587
calibration_y_max: 289
transform:
swap_xy: true
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
touch.x,
touch.y,
touch.x_raw,
touch.y_raw
);
If you are running esphome prior to 2023.12; you will need the following code instead of the transform & on_touch blocks (remove transform as well);
...
swap_x_y: true
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
id(my_touchscreen).x,
id(my_touchscreen).y,
id(my_touchscreen).x_raw,
id(my_touchscreen).y_raw
);
- Touchscreen configuration for using this display in portrait orientation.
- Refer to the full configuration in this repository for my latest calibration values.
output:
- platform: ledc
pin: GPIO21
id: backlight_pin
- platform: ledc
id: output_red
pin: GPIO4
inverted: true
- platform: ledc
id: output_green
pin: GPIO16
inverted: true
- platform: ledc
id: output_blue
pin: GPIO17
inverted: true
- The TFT Backlight is on GPIO21 and defined using ledc and a monochromatic light
- LED outputs for the RGB elements on the onboard LED are also defined.
light:
- platform: monochromatic
output: backlight_pin
name: "Display Backlight"
id: back_light
restore_mode: ALWAYS_ON
- platform: rgb
name: LED
id: led
red: output_red
green: output_green
blue: output_blue
restore_mode: ALWAYS_OFF
- Light components for the backlight with a default of ALWAYS_ON
- RGB Light component for the LED on the board.`
sensor:
- platform: adc
pin: 34
name: "Brightness"
update_interval: 60s
- Measure the Light Dependent Resistor to adjust the brightness. The onboard LDR utilises a 1M Ohm voltage divider to provide ranges that seem to be between 0.08V in indoor daylight and 1.0V in reasonably dark room. This value is used for auto-brightness adjustment.
display:
- platform: ili9xxx
id: my_display
spi_id: bus_tft
rotation: 90
dc_pin: GPIO2
cs_pin: GPIO15
model: TFT_2.4R
data_rate: 40MHz
lambda: |-
- The lambda function for generating the weather station display can be found in the main includes/display_lambda.yaml