|
1 | 1 | # ESP32 `std` Demo |
2 | 2 |
|
3 | | -Contains examples for `std` demo using LILYGO T-Display |
| 3 | +Contains examples for `std` demo using LILYGO T-Display. This demo runs a Ratatui interface on the ESP32, showcasing various UI widgets (like `Charts`, `Gauge`, and `Tabs`) while reading physical button presses and monitoring the board's battery voltage. |
4 | 4 |
|
5 | 5 | ## Pinmap |
6 | 6 |
|
7 | 7 |  |
8 | 8 |
|
9 | | -<br> |
| 9 | +### Essential Pins |
10 | 10 |
|
11 | | -<details> |
12 | | -<summary><h4>Pin Table</h4></summary> |
13 | | - |
14 | | -### **Left Header Pins** (Top to Bottom) |
15 | | - |
16 | | -| Pin Label | Primary Name | Secondary Functions | |
17 | | -| :--- | :--- | :--- | |
18 | | -| **G** | GND | Ground | |
19 | | -| **G** | GND | Ground | |
20 | | -| **21** | GPIO 21 | Wire_SDA (I2C) | |
21 | | -| **22** | GPIO 22 | Wire_SCL (I2C) | |
22 | | -| **17** | GPIO 17 | | |
23 | | -| **2** | GPIO 2 | ADC12, TOUCH2 | |
24 | | -| **15** | GPIO 15 | ADC13, TOUCH3 | |
25 | | -| **13** | GPIO 13 | ADC14, TOUCH4 | |
26 | | -| **12** | GPIO 12 | ADC15, TOUCH5 | |
27 | | -| **G** | GND | Ground | |
28 | | -| **G** | GND | Ground | |
29 | | -| **3V** | 3V3 | Power (3.3V) | |
30 | | - |
31 | | - |
32 | | -### **Right Header Pins** (Top to Bottom) |
33 | | - |
34 | | -| Pin Label | Primary Name | Secondary Functions | |
35 | | -| :--- | :--- | :--- | |
36 | | -| **3V** | 3V3 | Power (3.3V) | |
37 | | -| **36** | GPIO 36 | SVP, ADC0 | |
38 | | -| **37** | GPIO 37 | | |
39 | | -| **38** | GPIO 38 | | |
40 | | -| **39** | GPIO 39 | SVN, ADC3 | |
41 | | -| **32** | GPIO 32 | ADC4, TOUCH9 | |
42 | | -| **33** | GPIO 33 | ADC5, TOUCH8 | |
43 | | -| **25** | GPIO 25 | ADC18, DAC1 | |
44 | | -| **26** | GPIO 26 | ADC19, DAC2 | |
45 | | -| **27** | GPIO 27 | ADC17, TOUCH7 | |
46 | | -| **G** | GND | Ground | |
47 | | -| **5V** | 5V | Power (5V) | |
48 | | - |
49 | | - |
50 | | -### **Internal Display Pins (ST7789V)** |
51 | | - |
52 | | -| Pin / GPIO | Function | Description | |
| 11 | +| Component | Pin (GPIO) | Description | |
53 | 12 | | :--- | :--- | :--- | |
54 | | -| **19** | MOSI | SPI Data | |
55 | | -| **18** | SCLK | SPI Clock | |
56 | | -| **5** | CS | Chip Select | |
57 | | -| **16** | DC | Data/Command | |
58 | | -| **23** | RST | Reset | |
59 | | -| **4** | BL | Backlight | |
60 | | - |
61 | | - |
62 | | -### **Onboard Buttons** |
63 | | - |
64 | | -| Button Location | Pin / Name | |
65 | | -| :--- | :--- | |
66 | | -| **Left Button** | GPIO0 | |
67 | | -| **Right Button** | GPIO35 | |
68 | | -| **Side Button** | RST (Reset) | |
69 | | - |
70 | | -</details> |
71 | | - |
72 | | -## Wiring |
73 | | - |
74 | | -Internally the LILYGO T-Display is wired as follows |
75 | | - |
76 | | -| Component | Pin (GPIO) | Function | Direction / Type | |
77 | | -| :--- | :--- | :--- | :--- | |
78 | | -| **Display Backlight** | GPIO 4 | Backlight Control | Output | |
79 | | -| **Display SPI** | GPIO 18 | SCLK (SPI Clock) | Output | |
80 | | -| **Display SPI** | GPIO 19 | MOSI (SPI Data Out) | Output | |
81 | | -| **Display SPI** | GPIO 5 | CS (Chip Select) | Output | |
82 | | -| **Display SPI** | GPIO 16 | DC (Data/Command) | Output | |
83 | | -| **Display Reset** | GPIO 23 | Reset Pin (RST) | Output | |
84 | | -| **Button** | GPIO 0 | User Input (Triggers on Negative Edge) | Input (Interrupt) | |
85 | | -| **Battery Reader** | GPIO 34 | ADC Input (Measures Battery Voltage) | Analog Input (ADC1) | |
86 | | - |
87 | | -<br> |
| 13 | +| **Display MOSI** | 19 | SPI Data Out | |
| 14 | +| **Display SCLK** | 18 | SPI Clock | |
| 15 | +| **Display CS** | 5 | Chip Select | |
| 16 | +| **Display DC** | 16 | Data/Command | |
| 17 | +| **Display RST** | 23 | Reset Pin | |
| 18 | +| **Display BL** | 4 | Backlight Control | |
| 19 | +| **Left Button** | 0 | User Input | |
| 20 | +| **Battery ADC** | 34 | Battery Voltage Reader | |
88 | 21 |
|
89 | 22 | ## Notes |
90 | 23 |
|
91 | | -**Hardware Specifications:** |
92 | | -* **Board:** LILYGO TTGO T-Display V1.1 (ESP32-based) |
93 | | -* **Display:** 1.14-inch IPS LCD |
94 | | -* **Display Controller:** ST7789V |
95 | | -* **Resolution:** 135 x 240 pixels |
96 | | -* **Onboard Buttons:** |
97 | | - * Left Button: GPIO 0 (Configured for negative-edge interrupts) |
98 | | - * Right Button: GPIO 35 |
99 | | -* **Battery Monitoring:** Read via ADC1 on GPIO 34. |
| 24 | +If you're adapting this demo for a different board or screen, there are some points to keep in mind : |
100 | 25 |
|
101 | | -**Software & Driver Configurations:** |
102 | | -* **Framework:** Rust using `esp-idf-svc` (ESP-IDF bindings). |
103 | | -* **UI Library:** `ratatui` (running via the `mousefood` embedded backend). |
104 | | -* **SPI Settings:** 80 MHz baud rate, SPI Mode 3, Write-only (no MISO connection needed). |
105 | | -* **Display Driver (`mipidsi`):** |
106 | | - * **Color Inversion:** Enabled (`ColorInversion::Inverted`). |
107 | | - * **Hardware Offset:** Requires an X/Y offset of `(52, 40)` to render correctly on this specific panel. |
108 | | - * **Orientation:** Rotated 90 degrees (`Rotation::Deg90`) for a landscape view. |
109 | | -* **ADC Settings (Battery):** Configured for 12-bit resolution with 11dB attenuation (`DB_11`) and Line calibration to accurately read voltages up to ~3.3V. |
| 26 | +* **Screen Configuration:** The driver (`ST7789`), screen size (`135x240`), and hardware offset (`52, 40`) are specific to the T-Display panel. You will need to adjust these values in the code to match your specific display. |
| 27 | +* **Battery Voltage Reader:** The T-Display PCB uses a voltage divider that halves the battery voltage before it reaches the ADC on GPIO 34. This is why the ADC reading is multiplied by 2 in the code. If you are building a custom circuit, you will need to replicate this voltage divider setup to safely measure battery levels. |
0 commit comments