ELECROW 7.0" ESP32 HMI Display Documentation
The ELECROW 7.0" ESP32 HMI Display is a touchscreen display module featuring an ESP32 microcontroller, suitable for various IoT applications. This display is compatible with Arduino, LVGL, MicroPython, and PlatformIO, making it a versatile component for developers. This documentation provides an overview of the component's features, specifications, and code examples to get you started.
Features and Specifications
7.0" TFT LCD display with 800x480 resolution
ESP32 microcontroller with Wi-Fi and Bluetooth capabilities
Touchscreen interface with gesture recognition
Compatible with Arduino, LVGL, MicroPython, and PlatformIO
operating voltage: 5V
Communication interfaces: UART, SPI, I2C, I2S, and GPIO
Dimensions: 164mm x 104mm x 12mm (without acrylic case)
### Example 1: Arduino - Basic Display Initialization and Touchscreen Interaction
This example demonstrates how to initialize the display and read touchscreen events using Arduino.
```c
#include <Arduino.h>
#include <TFT_eSPI.h> // Include the TFT_eSPI library
// Initialize the display
TFT_eSPI tft = TFT_eSPI();
void setup() {
Serial.begin(115200);
tft.init(); // Initialize the display
// Set the screen orientation
tft.setRotation(1);
// Clear the screen
tft.fillScreen(TFT_BLACK);
// Draw a simple button
tft.fillRoundRect(100, 100, 200, 50, 10, TFT_RED);
tft.setTextColor(TFT_WHITE);
tft.setTextSize(2);
tft.setCursor(110, 110);
tft.println("Click me!");
}
void loop() {
// Read touchscreen events
TS_Point p = tft.getTouch();
if (p.z > 0) {
Serial.print("Touch at: ");
Serial.print(p.x);
Serial.print(", ");
Serial.println(p.y);
// Check if the button is pressed
if ((p.x > 100 && p.x < 300) && (p.y > 100 && p.y < 150)) {
Serial.println("Button pressed!");
}
}
delay(100);
}
```
### Example 2: MicroPython - LVGL UI with Button and Label
This example demonstrates how to create a simple LVGL UI with a button and label using MicroPython.
```python
import lvgl as lv
import utime
# Initialize the display
lv.init()
# Create a screen object
scr = lv.obj()
lv.scr_load(scr)
# Create a button
btn = lv.btn(scr)
btn.set_pos(100, 100)
btn.set_size(200, 50)
label = lv.label(btn)
label.set_text("Click me!")
# Create a label
label = lv.label(scr)
label.set_pos(100, 200)
label.set_text("Waiting for button press...")
# Set up button event handler
def on_btn_click(e):
label.set_text("Button pressed!")
btn.set_event_cb(on_btn_click, lv.EVENT.CLICKED)
# Start the LVGL task
while True:
lv.task_handler()
utime.sleep_ms(10)
```
datasheet: [ELECROW 7.0" ESP32 HMI Display Datasheet](https://cdn-shop.adafruit.com/product-files/4363/ELECROW+7.0+ESP32+HMI+Display+Datasheet.pdf)
library documentation: [TFT_eSPI Library Documentation](https://github.com/Bodmer/TFT_eSPI)
community support: [ELECROW Forum](https://forum.elecrow.com/)
By following this documentation and exploring the provided code examples, you'll be well on your way to integrating the ELECROW 7.0" ESP32 HMI Display into your IoT projects.