Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
528c8d5500 | ||
|
|
117715dc3b | ||
|
|
328dc06983 | ||
|
|
480708c992 | ||
|
|
9a0761f6da | ||
|
|
e6c09b7a9a | ||
|
|
4fa0c81087 | ||
|
|
04eb77fb2d | ||
|
|
7878f1bafd | ||
|
|
60bb859fc9 | ||
|
|
e8fdc60fea | ||
|
|
8b7978507c | ||
|
|
a8ae034911 | ||
|
|
ee5888ed97 | ||
|
|
9d9591c26e | ||
|
|
288aacf1b4 | ||
|
|
d75708993a | ||
|
|
146420a0bc | ||
|
|
4f9f686d81 | ||
|
|
e0c6784ecf | ||
|
|
72b47f6dd6 | ||
|
|
69d35e9a28 | ||
|
|
a3034f7c42 | ||
|
|
93bb0deba1 | ||
|
|
27a3ee840e | ||
|
|
92c1446824 | ||
|
|
544c6ae3b8 |
@@ -0,0 +1,10 @@
|
|||||||
|
# -------------------------------------------------------------------------------------
|
||||||
|
# Hersteller-Paket des 7-Zoll-Displays (JC1060P470C-I-W)
|
||||||
|
# Der Ordner ist im Original ~587 MB gross. Ins Repo kommen nur Schaltplaene, Specs,
|
||||||
|
# Datenblaetter, Handbuch und die Arduino-Demos; ausgeschlossen bleiben Werkzeuge,
|
||||||
|
# Archive und die mitgelieferten Fremdbibliotheken - die sind anderweitig beziehbar.
|
||||||
|
# -------------------------------------------------------------------------------------
|
||||||
|
JC_Display_Firmware_7zoll/8-Burn operation/flash_download_tool_3.9.7/
|
||||||
|
JC_Display_Firmware_7zoll/1-Demo/Demo_Arduino/*/lvgl/
|
||||||
|
JC_Display_Firmware_7zoll/1-Demo/Demo_IDF/
|
||||||
|
JC_Display_Firmware_7zoll/7-Character&Picture_Molding_Tool/
|
||||||
@@ -11,17 +11,17 @@ für zwei Mikrocontroller, die per UART (230400 8N1, JSON-Zeilen) verbunden sind
|
|||||||
Änderungshistorie: `Changelog.txt` (Root), Version steht in `String version = "…"`.
|
Änderungshistorie: `Changelog.txt` (Root), Version steht in `String version = "…"`.
|
||||||
|
|
||||||
- **ESP32-P4 – UART-Touch-Display (spiegelt den S3-Zustand).**
|
- **ESP32-P4 – UART-Touch-Display (spiegelt den S3-Zustand).**
|
||||||
Ordner: `JC_Display_Firmware/` (Hauptsketch `JC_Display_Firmware.ino`,
|
Ordner: `P4_Display_Firmware/` (Hauptsketch `P4_Display_Firmware.ino`,
|
||||||
UI in `ui.cpp`/`ui.h`, UART-Protokoll in `protocol_client.*`, LVGL 9.x).
|
UI in `ui.cpp`/`ui.h`, UART-Protokoll in `protocol_client.*`, LVGL 9.x).
|
||||||
Hat **kein eigenes WLAN** (der ESP32-C6-Co-Prozessor ist ungenutzt); alle Daten
|
Hat **kein eigenes WLAN** (der ESP32-C6-Co-Prozessor ist ungenutzt); alle Daten
|
||||||
kommen über UART vom S3. Eigene Version `DISPLAY_FW_VERSION` +
|
kommen über UART vom S3. Eigene Version `DISPLAY_FW_VERSION` +
|
||||||
`JC_Display_Firmware/Changelog.txt`.
|
`P4_Display_Firmware/Changelog.txt`.
|
||||||
|
|
||||||
Wenn ich „S3/Controller/Maschine" sage, ist `Dual_PID_FastHeatUp.ino` gemeint;
|
Wenn ich „S3/Controller/Maschine" sage, ist `Dual_PID_FastHeatUp.ino` gemeint;
|
||||||
„P4/Display" ist der Ordner `JC_Display_Firmware/`.
|
„P4/Display" ist der Ordner `P4_Display_Firmware/`.
|
||||||
|
|
||||||
**Nicht anfassen:** Der Ordner `Sicherungen/` enthält nur datierte Versions-Backups
|
**Nicht anfassen:** Der Ordner `Sicherungen/` enthält nur datierte Versions-Backups
|
||||||
(`.ino`) — niemals dort editieren. Unter `JC_Display_Firmware/JC4880P443C_I_W/` liegen
|
(`.ino`) — niemals dort editieren. Unter `P4_Display_Firmware/JC4880P443C_I_W/` liegen
|
||||||
reine Hersteller-Demos/Beispiele (Board-Support), ebenfalls nicht als Projektcode behandeln.
|
reine Hersteller-Demos/Beispiele (Board-Support), ebenfalls nicht als Projektcode behandeln.
|
||||||
|
|
||||||
# Agent Instructions
|
# Agent Instructions
|
||||||
@@ -33,8 +33,8 @@ reine Hersteller-Demos/Beispiele (Board-Support), ebenfalls nicht als Projektcod
|
|||||||
## Git-Workflow
|
## Git-Workflow
|
||||||
|
|
||||||
- Host: Gitea `git.mueller.black`, Repo `thomas/Dual-PID`, User `thomas`, CLI `tea`.
|
- Host: Gitea `git.mueller.black`, Repo `thomas/Dual-PID`, User `thomas`, CLI `tea`.
|
||||||
- Aenderungen immer ueber Feature-Branch + Merge-Request (`tea pr create`), nie direkt auf `main` committen oder pushen.
|
- Aenderungen immer ueber Feature-Branch + Merge-Request, nie direkt auf `main` committen oder pushen.
|
||||||
- Pull/Merge-Requests dürfen immer selbstständig gemergt werden (Auto-Merge, kein grünes CI erforderlich, via `tea pr merge` oder Gitea-API); danach den Merge kurz melden.
|
- PR anlegen **und** mergen bevorzugt über die **Gitea-REST-API** (PowerShell `Invoke-RestMethod` auf `https://git.mueller.black/api/v1/repos/thomas/Dual-PID/pulls[/<nr>/merge]`, Token aus `C:\Users\Thomas\AppData\Local\tea\config.yml`, nur in Variable, nie ausgeben), da die `tea`-CLI gegen `git.mueller.black` oft hängt und nie zurückkehrt. `tea pr create`/`tea pr merge` nur als Ausweichweg. PRs dürfen selbstständig gemergt werden (Auto-Merge, kein grünes CI erforderlich); danach den Merge kurz melden.
|
||||||
- Kein Force-Push, kein History-Rewrite auf geteilten Branches.
|
- Kein Force-Push, kein History-Rewrite auf geteilten Branches.
|
||||||
- Commit-Identitaet bleibt `raw-designs` / `Thomas@raw-designs.de` (globale Git-Config, nicht aendern).
|
- Commit-Identitaet bleibt `raw-designs` / `Thomas@raw-designs.de` (globale Git-Config, nicht aendern).
|
||||||
- Commit-Messages im Conventional-Commits-Format (feat/fix/docs/refactor/...).
|
- Commit-Messages im Conventional-Commits-Format (feat/fix/docs/refactor/...).
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# JC4880P443C-I-W Touch-Display — UART-Protokoll & Architektur
|
# P4-Touch-Display — UART-Protokoll & Architektur
|
||||||
|
|
||||||
Status: Entwurf v1.0 der Doku · Firmware-Protokollversion: **1** (vorhanden, abgeschaltet) ·
|
Status: Entwurf v1.0 der Doku · Firmware-Protokollversion: **1** (vorhanden, abgeschaltet) ·
|
||||||
Ziel-Protokollversion: **2** (geplante Erweiterungen)
|
Ziel-Protokollversion: **2** (geplante Erweiterungen)
|
||||||
@@ -16,11 +16,11 @@ Bewusste Designentscheidung (siehe Projektbesprechung):
|
|||||||
|
|
||||||
- Das **Webinterface bleibt auf der Hauptplatine** (ESP32-S3). Es bleibt unverändert
|
- Das **Webinterface bleibt auf der Hauptplatine** (ESP32-S3). Es bleibt unverändert
|
||||||
die zentrale Steuerungs- und Konnektivitätsinstanz.
|
die zentrale Steuerungs- und Konnektivitätsinstanz.
|
||||||
- Das **JC-Display ist ein vollwertiges Touch-Bediengerät**, das über UART angebunden
|
- Das **P4-Display ist ein vollwertiges Touch-Bediengerät**, das über UART angebunden
|
||||||
ist und denselben Funktionsumfang bietet wie das Webinterface — aber **kein** eigenes
|
ist und denselben Funktionsumfang bietet wie das Webinterface — aber **kein** eigenes
|
||||||
WLAN/Webserver betreibt.
|
WLAN/Webserver betreibt.
|
||||||
- Das **OLED (SH1106G) bleibt optional** und wird wie bisher über ein **Compile-Flag**
|
- Das **OLED (SH1106G) bleibt optional** und wird wie bisher über ein **Compile-Flag**
|
||||||
gewählt (`ENABLE_DISPLAY`). Es ist unabhängig vom JC-Display.
|
gewählt (`ENABLE_DISPLAY`). Es ist unabhängig vom P4-Display.
|
||||||
|
|
||||||
```
|
```
|
||||||
+----------------------------+ UART (GPIO43/44) +---------------------------+
|
+----------------------------+ UART (GPIO43/44) +---------------------------+
|
||||||
@@ -34,13 +34,13 @@ Bewusste Designentscheidung (siehe Projektbesprechung):
|
|||||||
| - OLED (optional) | | ST7701 / GT911 / ES8311 |
|
| - OLED (optional) | | ST7701 / GT911 / ES8311 |
|
||||||
+----------------------------+ +---------------------------+
|
+----------------------------+ +---------------------------+
|
||||||
|
|
||||||
* Der ESP32-C6 auf dem JC-Display (WLAN/BT) wird in diesem Projekt NICHT für die
|
* Der ESP32-C6 auf dem P4-Display (WLAN/BT) wird in diesem Projekt NICHT für die
|
||||||
Maschinensteuerung benötigt. WLAN/Webinterface laufen weiterhin auf der S3.
|
Maschinensteuerung benötigt. WLAN/Webinterface laufen weiterhin auf der S3.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rollenverteilung
|
### Rollenverteilung
|
||||||
|
|
||||||
| Aufgabe | S3 (Hauptplatine) | P4 (JC-Display) |
|
| Aufgabe | S3 (Hauptplatine) | P4 (P4-Display) |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Echtzeit-Regelung (PID, SSR, Sicherheit) | **ja** | nein |
|
| Echtzeit-Regelung (PID, SSR, Sicherheit) | **ja** | nein |
|
||||||
| Sensoren (NTC, MAX6675, Waage) | **ja** | nein |
|
| Sensoren (NTC, MAX6675, Waage) | **ja** | nein |
|
||||||
@@ -76,7 +76,7 @@ schickt Bedienwünsche als Kommandos. So bleiben Web-UI, OLED und Touch-Display
|
|||||||
```
|
```
|
||||||
|
|
||||||
> **Hinweis (bewusst akzeptiert):** GPIO43/44 sind beim ESP32-S3 zugleich die Standard-
|
> **Hinweis (bewusst akzeptiert):** GPIO43/44 sind beim ESP32-S3 zugleich die Standard-
|
||||||
> Pins der seriellen Debug-Konsole (UART0). Solange das JC-Display dort angeschlossen ist,
|
> Pins der seriellen Debug-Konsole (UART0). Solange das P4-Display dort angeschlossen ist,
|
||||||
> steht die klassische serielle Debug-Ausgabe an diesen Pins nicht parallel zur Verfügung.
|
> steht die klassische serielle Debug-Ausgabe an diesen Pins nicht parallel zur Verfügung.
|
||||||
> Debug/Logging erfolgt dann über USB-CDC bzw. das Webinterface. Diese Pins wurden
|
> Debug/Logging erfolgt dann über USB-CDC bzw. das Webinterface. Diese Pins wurden
|
||||||
> ausdrücklich beibehalten, weil sie auf der Platine herausgeführt sind.
|
> ausdrücklich beibehalten, weil sie auf der Platine herausgeführt sind.
|
||||||
@@ -519,7 +519,7 @@ Für ein vollwertiges 480×800-Touch-UI fehlen v1 noch einige Daten/Funktionen.
|
|||||||
## 9. OLED-Koexistenz (Compile-Flag)
|
## 9. OLED-Koexistenz (Compile-Flag)
|
||||||
|
|
||||||
- OLED bleibt über `ENABLE_DISPLAY` (Compile-Flag) wählbar — unverändert.
|
- OLED bleibt über `ENABLE_DISPLAY` (Compile-Flag) wählbar — unverändert.
|
||||||
- Das JC-Display wird über `TOUCH_UART_ENABLED` (Compile-Flag) aktiviert.
|
- Das P4-Display wird über `TOUCH_UART_ENABLED` (Compile-Flag) aktiviert.
|
||||||
- **Geplante Änderung:** beide Flags strikt **unabhängig** halten, damit alle Kombinationen
|
- **Geplante Änderung:** beide Flags strikt **unabhängig** halten, damit alle Kombinationen
|
||||||
baubar sind:
|
baubar sind:
|
||||||
|
|
||||||
@@ -562,7 +562,7 @@ Puffergrößen/Chunking, optionaler CRC + Handshake, `action`-Stringliste dokume
|
|||||||
**Löschen:** Nichts.
|
**Löschen:** Nichts.
|
||||||
|
|
||||||
**Fully-Kiosk bleibt erhalten** (Entscheidung) — als eigenständige, optionale Funktion
|
**Fully-Kiosk bleibt erhalten** (Entscheidung) — als eigenständige, optionale Funktion
|
||||||
neben dem JC-Display. Lastbewertung der S3:
|
neben dem P4-Display. Lastbewertung der S3:
|
||||||
- Einziger Aufruf `sendFullyKioskLoadUrl()` wird **nur bei Standby-Zustandswechsel**
|
- Einziger Aufruf `sendFullyKioskLoadUrl()` wird **nur bei Standby-Zustandswechsel**
|
||||||
getriggert (`if (standbyModeActive != lastStandbyModeActive)`), **nicht periodisch**
|
getriggert (`if (standbyModeActive != lastStandbyModeActive)`), **nicht periodisch**
|
||||||
(wenige Male pro Tag).
|
(wenige Male pro Tag).
|
||||||
@@ -586,10 +586,10 @@ neben dem JC-Display. Lastbewertung der S3:
|
|||||||
6. **[offen, optional]** CRC + ggf. Puffer-Feinjustage (§8.3) — bewusst nicht als toter,
|
6. **[offen, optional]** CRC + ggf. Puffer-Feinjustage (§8.3) — bewusst nicht als toter,
|
||||||
ungetesteter Code eingebaut; bei Bedarf später.
|
ungetesteter Code eingebaut; bei Bedarf später.
|
||||||
7. **[offen, durch dich]** `TOUCH_UART_ENABLED` auf 1 setzen + Build verifizieren, **sobald**
|
7. **[offen, durch dich]** `TOUCH_UART_ENABLED` auf 1 setzen + Build verifizieren, **sobald**
|
||||||
das JC-Display physisch an Serial1 (GPIO43/44) hängt. Bewusst noch **0**, damit die
|
das P4-Display physisch an Serial1 (GPIO43/44) hängt. Bewusst noch **0**, damit die
|
||||||
serielle Debug-Konsole (GPIO43/44) im aktuellen Betrieb erhalten bleibt.
|
serielle Debug-Konsole (GPIO43/44) im aktuellen Betrieb erhalten bleibt.
|
||||||
|
|
||||||
### Phase B — P4-Seite (JC-Display, Projekt `JC_Display_Firmware/`)
|
### Phase B — P4-Seite (P4-Display, Projekt `P4_Display_Firmware/`)
|
||||||
Grundgerüst angelegt (Arduino-ESP32 P4 + LVGL 9 + ArduinoJson 7). Aufteilung:
|
Grundgerüst angelegt (Arduino-ESP32 P4 + LVGL 9 + ArduinoJson 7). Aufteilung:
|
||||||
`config.h`, `machine_state.h`, `protocol_client.*`, `ui.*`, `display_hal.*`, `.ino`, `README.md`.
|
`config.h`, `machine_state.h`, `protocol_client.*`, `ui.*`, `display_hal.*`, `.ino`, `README.md`.
|
||||||
|
|
||||||
@@ -603,7 +603,7 @@ Grundgerüst angelegt (Arduino-ESP32 P4 + LVGL 9 + ArduinoJson 7). Aufteilung:
|
|||||||
(`display_hal.cpp`, Schalter `JC_USE_REAL_PANEL`): MIPI-DSI/ST7701, GT911 (I²C SDA=7/SCL=8),
|
(`display_hal.cpp`, Schalter `JC_USE_REAL_PANEL`): MIPI-DSI/ST7701, GT911 (I²C SDA=7/SCL=8),
|
||||||
Backlight GPIO23, LCD-Reset GPIO5; LVGL-Port mit eigenem Task + Lock. Stub-Modus bleibt für
|
Backlight GPIO23, LCD-Reset GPIO5; LVGL-Port mit eigenem Task + Lock. Stub-Modus bleibt für
|
||||||
Schreibtisch-Tests. Vendor-BSP-Dateien sind in den Sketch zu kopieren (siehe Projekt-README).
|
Schreibtisch-Tests. Vendor-BSP-Dateien sind in den Sketch zu kopieren (siehe Projekt-README).
|
||||||
5. **[festgelegt]** UART-Pins am JC-Display: **P4 GPIO50 (TX) / GPIO51 (RX)** vom Expand-IO-Header
|
5. **[festgelegt]** UART-Pins am P4-Display: **P4 GPIO50 (TX) / GPIO51 (RX)** vom Expand-IO-Header
|
||||||
JP1 (Schaltplan `4_USB&IO.png`). Gegenseite S3 unverändert GPIO43/44.
|
JP1 (Schaltplan `4_USB&IO.png`). Gegenseite S3 unverändert GPIO43/44.
|
||||||
6. **[offen]** Weitere Screens: Einstellungen (Brew/Service/Sensor), Profil-Auswahl/-Editor,
|
6. **[offen]** Weitere Screens: Einstellungen (Brew/Service/Sensor), Profil-Auswahl/-Editor,
|
||||||
PID/AutoTune-Bedienung; Ausrichtung Hochformat (Rotation 0 in `pins_config.h`).
|
PID/AutoTune-Bedienung; Ausrichtung Hochformat (Rotation 0 in `pins_config.h`).
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
# JC4880P443C-I-W — Touch-Display-Firmware (ESP32-P4)
|
|
||||||
|
|
||||||
Client-Firmware für das Guition-Smart-Display **JC4880P443C-I-W**, die als
|
|
||||||
UART-Touch-Bedienung für die Dual-PID-Siebträgersteuerung dient.
|
|
||||||
|
|
||||||
Die **Hauptplatine (ESP32-S3, `Dual_PID_FastHeatUp.ino`)** bleibt die Steuerzentrale
|
|
||||||
inkl. WLAN/Webinterface. Dieses Display ist ein **reiner UART-Client**: es empfängt den
|
|
||||||
Zustand und sendet Bedienkommandos. Protokoll: siehe
|
|
||||||
[`../Doku/JC-Display_UART-Protokoll.md`](../Doku/JC-Display_UART-Protokoll.md).
|
|
||||||
|
|
||||||
## Hardware (laut Vendor-Paket im Ordner `JC4880P443C_I_W/`)
|
|
||||||
|
|
||||||
| Komponente | Bauteil / Pin |
|
|
||||||
|---|---|
|
|
||||||
| Haupt-MCU (UI) | ESP32-P4 |
|
|
||||||
| WLAN/BT (hier ungenutzt) | ESP32-C6 |
|
|
||||||
| Display | ST7701, 480×800 IPS, **MIPI-DSI** |
|
|
||||||
| Touch | GT911, I²C **SDA=GPIO7 / SCL=GPIO8** |
|
|
||||||
| Backlight | **GPIO23** (LEDC-PWM) · LCD-Reset **GPIO5** |
|
|
||||||
| Freie Expansion-IO (JP1) | GPIO 52/51/50/49/35/34/33/32/31/30/29/28, ES_I2C, +3V3/+5V/GND |
|
|
||||||
|
|
||||||
## Verkabelung zur Hauptplatine (UART, gekreuzt)
|
|
||||||
|
|
||||||
Pins aus dem Expand-IO-Header **JP1** (Schaltplan `JC4880P443C_I_W/5-Schematic/4_USB&IO.png`):
|
|
||||||
|
|
||||||
```
|
|
||||||
S3 GPIO43 (TX) ----> P4 GPIO31 (RX) (DISPLAY_UART_RX_PIN)
|
|
||||||
S3 GPIO44 (RX) <---- P4 GPIO33 (TX) (DISPLAY_UART_TX_PIN)
|
|
||||||
S3 GND ------ P4 GND
|
|
||||||
```
|
|
||||||
> Die rechte JP1-Spalte (`C6_U01TXD`/`C6_I10RXD`/…) gehört zum **ESP32-C6** — nicht
|
|
||||||
> verwenden. 3,3-V-Logik beidseitig → keine Pegelwandlung nötig.
|
|
||||||
|
|
||||||
## Projektstruktur (eigener Code)
|
|
||||||
|
|
||||||
| Datei | Zweck |
|
|
||||||
|---|---|
|
|
||||||
| `JC_Display_Firmware.ino` | setup()/loop(), verdrahtet die Module |
|
|
||||||
| `config.h` | Pins, UART, Protokoll-Parameter |
|
|
||||||
| `machine_state.h` | Spiegel des `state`-Objekts der S3 |
|
|
||||||
| `protocol_client.h/.cpp` | UART-Protokoll: hello/state/ack/profiles/… + Heartbeat |
|
|
||||||
| `ui.h/.cpp` | LVGL-Dashboard (hardwareunabhängig) |
|
|
||||||
| `display_hal.h/.cpp` | LVGL-/UI-Verdrahtung + Lock-Wrapper |
|
|
||||||
| `board_bringup.c` | esp_lcd-Hardware-Bringup (C; nur bei `JC_USE_REAL_PANEL=1`) |
|
|
||||||
|
|
||||||
## Abhängigkeiten
|
|
||||||
|
|
||||||
- **Arduino-ESP32** ≥ 3.1 (mit ESP32-P4-Support), Board: *ESP32P4 Dev Module*,
|
|
||||||
**PSRAM aktiviert**.
|
|
||||||
- **LVGL** 9.x + `lv_conf.h`. Tipp: die `lv_conf.h` aus dem Vendor-Beispiel
|
|
||||||
(`JC4880P443C_I_W/1-Demo/arduino_examples/lvgl_v9_sw_rotation/lv_conf.h`) übernehmen
|
|
||||||
und `LV_FONT_MONTSERRAT_40` aktivieren (große Temperaturanzeige).
|
|
||||||
- **ArduinoJson** 7.x.
|
|
||||||
|
|
||||||
## Zwei Betriebsmodi (`JC_USE_REAL_PANEL` in `display_hal.h`)
|
|
||||||
|
|
||||||
### `0` = Stub-Modus (Standard)
|
|
||||||
Kompiliert **ohne** Display-Treiber (eigenes Minimal-LVGL, rendert ins Leere). Ideal, um
|
|
||||||
**Protokoll/UART/Logik** am Schreibtisch zu testen (Debug über USB-CDC `Serial`). Läuft auf
|
|
||||||
jedem ESP32 mit LVGL+ArduinoJson.
|
|
||||||
|
|
||||||
### `1` = echte Hardware (Hersteller-BSP)
|
|
||||||
`display_hal.cpp` baut auf der **erprobten Hersteller-Portierung** auf. Dazu folgende
|
|
||||||
Dateien aus `JC4880P443C_I_W/1-Demo/arduino_examples/lvgl_v9_sw_rotation/` **in diesen
|
|
||||||
Sketch-Ordner kopieren**:
|
|
||||||
|
|
||||||
```
|
|
||||||
pins_config.h
|
|
||||||
lvgl_port_v9.h
|
|
||||||
lvgl_port_v9.c
|
|
||||||
src/lcd/ (komplett: esp_lcd_st7701*.c/.h, st7701_lcd.*)
|
|
||||||
src/touch/ (komplett: esp_lcd_touch*.c/.h, gt911_touch.*)
|
|
||||||
```
|
|
||||||
|
|
||||||
Der Init-Ablauf (MIPI-DSI-PHY-LDO, ST7701, GT911, LEDC-Backlight, `lvgl_port_init`) ist
|
|
||||||
1:1 aus dem Vendor-Beispiel `lvgl_sw_rotation.c` übernommen — nur der Demo-Aufruf
|
|
||||||
(`lv_demo_widgets()`) wurde durch `ui_init()` ersetzt.
|
|
||||||
|
|
||||||
**Wichtig:** Im realen Modus läuft LVGL in einem **eigenen FreeRTOS-Task**. UI-Zugriffe aus
|
|
||||||
der Arduino-`loop()` (z. B. `ui_update` bei jedem state-Push) sind daher in
|
|
||||||
`hal_lock()/hal_unlock()` (= `lvgl_port_lock/unlock`) gekapselt — ist in der `.ino`
|
|
||||||
bereits umgesetzt.
|
|
||||||
|
|
||||||
### Ausrichtung
|
|
||||||
Das Vendor-Beispiel nutzt **90° (Querformat 800×480)**. Das hiesige Dashboard ist für
|
|
||||||
**Hochformat 480×800** ausgelegt → in `pins_config.h`
|
|
||||||
`EXAMPLE_LVGL_PORT_ROTATION_DEGREE_` auf **0** setzen (oder das UI-Layout in `ui.cpp` auf
|
|
||||||
Querformat anpassen).
|
|
||||||
|
|
||||||
## Status
|
|
||||||
|
|
||||||
**Fertig & hardwareunabhängig:**
|
|
||||||
- Vollständiger UART-Protokoll-Client (v2): hello-Handshake, state-Parsing, ack/error,
|
|
||||||
Profile, Heartbeat, Link-Timeout.
|
|
||||||
- Dashboard: Live-Temperaturen Wasser/Dampf (ist/soll), Duty-Balken, Status-Banner
|
|
||||||
(Farbe nach `statusKey`), Verbindungs- & WLAN-Anzeige, Bezugs-Timer, Bedien-Buttons.
|
|
||||||
- Senden für `setPid`, `startAutotune`/`stopAutotune`, `getProfileDetails` vorhanden.
|
|
||||||
|
|
||||||
**Board-Bringup:** auf die konkreten JC-Pins/Treiber gesetzt (ST7701/GT911, Backlight,
|
|
||||||
I²C) — sobald die BSP-Dateien kopiert und `JC_USE_REAL_PANEL=1` gesetzt ist, lauffähig.
|
|
||||||
|
|
||||||
**Noch offen (UI-Ausbau):** weitere Screens — Einstellungen (Brew/Service/Sensor),
|
|
||||||
Profil-Auswahl/-Editor, PID/AutoTune-Bedienung.
|
|
||||||
|
|
||||||
## Inbetriebnahme / Fehlersuche (Lessons learned)
|
|
||||||
|
|
||||||
- **Stromversorgung:** Jedes Board **eigene** Versorgung. Zwischen P4 und S3 nur
|
|
||||||
**GND + TX + RX** — **kein** 3V3/5V! Den S3 nicht über den 3V3-Header des Displays
|
|
||||||
speisen (reicht nicht / Regler-Rückspeisung).
|
|
||||||
- **Pins nach Silkscreen:** Die UART-Pads am Board nach Aufdruck **`GPIO50`/`GPIO51`**
|
|
||||||
identifizieren, nicht nach Header-Pin-Nummern.
|
|
||||||
- **S3-Seite:** muss mit `TOUCH_UART_ENABLED 1` geflasht sein und laufen. Da `Serial`
|
|
||||||
(Debug) und der Touch-UART beide auf GPIO43/44 liegen, ggf. **„USB CDC On Boot:
|
|
||||||
Enabled"** verwenden, damit der Debug-Port nicht die UART-Pins blockiert.
|
|
||||||
|
|
||||||
### Diagnose-Schalter (in `config.h`)
|
|
||||||
|
|
||||||
- `SHOW_DEBUG_OVERLAY 1` → blendet unten ein grünes Panel ein: gesendete `hello`,
|
|
||||||
empfangene Bytes/Zeilen, Parse-Fehler, letzte Rohzeile, Link-Status.
|
|
||||||
- `UART_SELFTEST_INTERNAL_LOOPBACK 1` → legt TX chip-intern auf RX (ohne Draht/Pins).
|
|
||||||
Läuft „RX byte" hoch, sind Firmware+UART ok → Problem liegt an Pins/Verkabelung.
|
|
||||||
**Nach dem Test wieder auf 0!**
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
// =====================================================================================
|
|
||||||
// board_bringup.c - ESP32-P4 / ST7701 / GT911 Hardware-Bringup (JC4880P443C-I-W)
|
|
||||||
// =====================================================================================
|
|
||||||
// BEWUSST eine .c-Datei (wird als C kompiliert): die esp_lcd-Init-Makros nutzen
|
|
||||||
// Compound-Literals und Out-of-Order-Designated-Initializer, die in C++ (Arduino .cpp)
|
|
||||||
// zu Fehlern fuehren. Der Ablauf ist 1:1 aus dem Hersteller-Beispiel
|
|
||||||
// arduino_examples/lvgl_v9_sw_rotation/lvgl_sw_rotation.c uebernommen - lediglich der
|
|
||||||
// Demo-Aufruf (lv_demo_widgets) entfaellt; das UI wird ueber display_hal.cpp aufgebaut.
|
|
||||||
//
|
|
||||||
// Nur aktiv bei JC_USE_REAL_PANEL == 1. Erwartet die Vendor-BSP-Dateien im Sketch:
|
|
||||||
// pins_config.h, lvgl_port_v9.h/.c, src/lcd/*, src/touch/*
|
|
||||||
// =====================================================================================
|
|
||||||
|
|
||||||
#include "config.h" // liefert JC_USE_REAL_PANEL (C-sicher)
|
|
||||||
|
|
||||||
#if JC_USE_REAL_PANEL
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "freertos/FreeRTOS.h"
|
|
||||||
#include "freertos/task.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "driver/ledc.h"
|
|
||||||
#include "driver/i2c_master.h"
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "esp_cache.h"
|
|
||||||
#include "esp_ldo_regulator.h"
|
|
||||||
#include "esp_lcd_panel_io.h"
|
|
||||||
#include "esp_lcd_panel_ops.h"
|
|
||||||
#include "esp_lcd_mipi_dsi.h"
|
|
||||||
#include "src/touch/esp_lcd_touch_gt911.h"
|
|
||||||
#include "src/lcd/esp_lcd_st7701.h"
|
|
||||||
#include "lvgl_port_v9.h"
|
|
||||||
|
|
||||||
#define BSP_MIPI_DSI_PHY_PWR_LDO_CHAN (3)
|
|
||||||
#define BSP_MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV (2500)
|
|
||||||
#define BSP_LCD_H_RES (480)
|
|
||||||
#define BSP_LCD_V_RES (800)
|
|
||||||
#define BSP_I2C_NUM (I2C_NUM_1)
|
|
||||||
#define BSP_I2C_SDA (GPIO_NUM_7)
|
|
||||||
#define BSP_I2C_SCL (GPIO_NUM_8)
|
|
||||||
#define BSP_LCD_TOUCH_RST (GPIO_NUM_NC)
|
|
||||||
#define BSP_LCD_TOUCH_INT (GPIO_NUM_NC)
|
|
||||||
#define BSP_LCD_RST (GPIO_NUM_5)
|
|
||||||
#define BSP_LCD_BACKLIGHT GPIO_NUM_23
|
|
||||||
#define LCD_LEDC_CH LEDC_CHANNEL_0
|
|
||||||
|
|
||||||
static i2c_master_bus_handle_t s_i2c_handle = NULL;
|
|
||||||
|
|
||||||
void jc_backlight_init(void)
|
|
||||||
{
|
|
||||||
const ledc_channel_config_t ch = {
|
|
||||||
.gpio_num = BSP_LCD_BACKLIGHT,
|
|
||||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
|
||||||
.channel = LCD_LEDC_CH,
|
|
||||||
.intr_type = LEDC_INTR_DISABLE,
|
|
||||||
.timer_sel = 1,
|
|
||||||
.duty = 0,
|
|
||||||
.hpoint = 0
|
|
||||||
};
|
|
||||||
const ledc_timer_config_t tm = {
|
|
||||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
|
||||||
.duty_resolution = LEDC_TIMER_10_BIT,
|
|
||||||
.timer_num = 1,
|
|
||||||
.freq_hz = 5000,
|
|
||||||
.clk_cfg = LEDC_AUTO_CLK
|
|
||||||
};
|
|
||||||
ledc_timer_config(&tm);
|
|
||||||
ledc_channel_config(&ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jc_backlight_set(int percent)
|
|
||||||
{
|
|
||||||
if (percent > 100) percent = 100;
|
|
||||||
if (percent < 0) percent = 0;
|
|
||||||
uint32_t duty = (1023 * percent) / 100;
|
|
||||||
ledc_set_duty(LEDC_LOW_SPEED_MODE, LCD_LEDC_CH, duty);
|
|
||||||
ledc_update_duty(LEDC_LOW_SPEED_MODE, LCD_LEDC_CH);
|
|
||||||
}
|
|
||||||
|
|
||||||
IRAM_ATTR static bool on_vsync(esp_lcd_panel_handle_t panel,
|
|
||||||
esp_lcd_dpi_panel_event_data_t *edata, void *ctx)
|
|
||||||
{
|
|
||||||
return lvgl_port_notify_lcd_vsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bringt Panel + Touch + LVGL-Port hoch (LVGL laeuft danach in eigenem Task).
|
|
||||||
void jc_board_bringup(void)
|
|
||||||
{
|
|
||||||
jc_backlight_init();
|
|
||||||
|
|
||||||
i2c_master_bus_config_t i2c_bus_conf = {
|
|
||||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
|
||||||
.sda_io_num = BSP_I2C_SDA,
|
|
||||||
.scl_io_num = BSP_I2C_SCL,
|
|
||||||
.i2c_port = BSP_I2C_NUM,
|
|
||||||
};
|
|
||||||
i2c_new_master_bus(&i2c_bus_conf, &s_i2c_handle);
|
|
||||||
|
|
||||||
static esp_ldo_channel_handle_t phy_pwr_chan = NULL;
|
|
||||||
esp_ldo_channel_config_t ldo_cfg = {
|
|
||||||
.chan_id = BSP_MIPI_DSI_PHY_PWR_LDO_CHAN,
|
|
||||||
.voltage_mv = BSP_MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV,
|
|
||||||
};
|
|
||||||
esp_ldo_acquire_channel(&ldo_cfg, &phy_pwr_chan);
|
|
||||||
|
|
||||||
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
|
|
||||||
esp_lcd_dsi_bus_config_t bus_config = ST7701_PANEL_BUS_DSI_2CH_CONFIG();
|
|
||||||
esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus);
|
|
||||||
|
|
||||||
esp_lcd_panel_io_handle_t io = NULL;
|
|
||||||
esp_lcd_dbi_io_config_t dbi_config = ST7701_PANEL_IO_DBI_CONFIG();
|
|
||||||
esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io);
|
|
||||||
|
|
||||||
esp_lcd_panel_handle_t disp_panel = NULL;
|
|
||||||
esp_lcd_dpi_panel_config_t dpi_config = ST7701_480_360_PANEL_60HZ_DPI_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565);
|
|
||||||
dpi_config.num_fbs = LVGL_PORT_LCD_BUFFER_NUMS;
|
|
||||||
|
|
||||||
st7701_vendor_config_t vendor_config = {
|
|
||||||
.mipi_config = {
|
|
||||||
.dsi_bus = mipi_dsi_bus,
|
|
||||||
.dpi_config = &dpi_config,
|
|
||||||
},
|
|
||||||
.flags = {
|
|
||||||
.use_mipi_interface = 1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
esp_lcd_panel_dev_config_t lcd_dev_config = {
|
|
||||||
.bits_per_pixel = 16,
|
|
||||||
.rgb_ele_order = ESP_LCD_COLOR_SPACE_RGB,
|
|
||||||
.reset_gpio_num = BSP_LCD_RST,
|
|
||||||
.vendor_config = &vendor_config,
|
|
||||||
};
|
|
||||||
esp_lcd_new_panel_st7701(io, &lcd_dev_config, &disp_panel);
|
|
||||||
esp_lcd_panel_reset(disp_panel);
|
|
||||||
esp_lcd_panel_init(disp_panel);
|
|
||||||
|
|
||||||
// Alle Framebuffer einmal auf Schwarz loeschen. Im Avoid-Tear-Direct-Mode (mehrere
|
|
||||||
// Buffer) kopiert LVGL pro Frame nur die geaenderten Bereiche in den naechsten Buffer;
|
|
||||||
// bis alle Buffer einmal vollstaendig bemalt sind, wuerde sonst uninitialisierter
|
|
||||||
// Speicher (weisses Rauschen) durchblitzen. Schwarz faellt gegen das dunkle Theme
|
|
||||||
// nicht auf. Cache-Writeback noetig, da die Buffer im PSRAM liegen und der DMA liest.
|
|
||||||
{
|
|
||||||
void *fbs[3] = { NULL, NULL, NULL };
|
|
||||||
size_t fb_size = (size_t)BSP_LCD_H_RES * BSP_LCD_V_RES * 2; // RGB565 = 2 Byte/Pixel
|
|
||||||
#if LVGL_PORT_LCD_BUFFER_NUMS >= 3
|
|
||||||
esp_lcd_dpi_panel_get_frame_buffer(disp_panel, 3, &fbs[0], &fbs[1], &fbs[2]);
|
|
||||||
#elif LVGL_PORT_LCD_BUFFER_NUMS == 2
|
|
||||||
esp_lcd_dpi_panel_get_frame_buffer(disp_panel, 2, &fbs[0], &fbs[1]);
|
|
||||||
#else
|
|
||||||
esp_lcd_dpi_panel_get_frame_buffer(disp_panel, 1, &fbs[0]);
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
if (fbs[i]) {
|
|
||||||
memset(fbs[i], 0, fb_size);
|
|
||||||
esp_cache_msync(fbs[i], fb_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_lcd_dpi_panel_event_callbacks_t cbs = {
|
|
||||||
#if LVGL_PORT_AVOID_TEAR_MODE
|
|
||||||
.on_refresh_done = on_vsync,
|
|
||||||
#else
|
|
||||||
.on_color_trans_done = on_vsync,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
esp_lcd_dpi_panel_register_event_callbacks(disp_panel, &cbs, NULL);
|
|
||||||
|
|
||||||
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
|
|
||||||
esp_lcd_touch_handle_t tp_handle;
|
|
||||||
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
|
|
||||||
tp_io_config.scl_speed_hz = 100000;
|
|
||||||
esp_lcd_new_panel_io_i2c(s_i2c_handle, &tp_io_config, &tp_io_handle);
|
|
||||||
const esp_lcd_touch_config_t tp_cfg = {
|
|
||||||
.x_max = BSP_LCD_H_RES,
|
|
||||||
.y_max = BSP_LCD_V_RES,
|
|
||||||
.rst_gpio_num = BSP_LCD_TOUCH_RST,
|
|
||||||
.int_gpio_num = BSP_LCD_TOUCH_INT,
|
|
||||||
.levels = {
|
|
||||||
.reset = 0,
|
|
||||||
.interrupt = 0,
|
|
||||||
},
|
|
||||||
.flags = {
|
|
||||||
.swap_xy = 0,
|
|
||||||
.mirror_x = 0,
|
|
||||||
.mirror_y = 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp_handle);
|
|
||||||
|
|
||||||
lvgl_port_interface_t interface =
|
|
||||||
(dpi_config.flags.use_dma2d) ? LVGL_PORT_INTERFACE_MIPI_DSI_DMA
|
|
||||||
: LVGL_PORT_INTERFACE_MIPI_DSI_NO_DMA;
|
|
||||||
lvgl_port_init(disp_panel, tp_handle, interface);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // JC_USE_REAL_PANEL
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
// =====================================================================================
|
|
||||||
// JC4880P443C-I-W - Touch-Display-Firmware fuer die Dual-PID-Siebtraegersteuerung
|
|
||||||
// config.h - zentrale Konfiguration (Pins, UART, Protokoll)
|
|
||||||
// =====================================================================================
|
|
||||||
//
|
|
||||||
// Ziel-Hardware: Guition JC4880P443C-I-W
|
|
||||||
// - MCU: ESP32-P4 (UI / LVGL)
|
|
||||||
// - WLAN: ESP32-C6 (hier NICHT genutzt - WLAN/Webinterface laufen auf der Hauptplatine)
|
|
||||||
// - Display: ST7701 (480 x 800 IPS, MIPI-DSI)
|
|
||||||
// - Touch: GT911 (kapazitiv, I2C)
|
|
||||||
// - Audio: ES8311 (optional)
|
|
||||||
//
|
|
||||||
// Diese Firmware ist ein reiner UART-Client. Quelle der Wahrheit ist die Hauptplatine
|
|
||||||
// (ESP32-S3, Dual_PID_FastHeatUp.ino). Siehe Doku/JC-Display_UART-Protokoll.md.
|
|
||||||
// =====================================================================================
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Panel-Modus (C-sicher hier definiert, da auch board_bringup.c ihn liest)
|
|
||||||
// 0 = Stub-Modus (kein Display-Treiber; Protokoll/Logik-Test)
|
|
||||||
// 1 = echte Hardware (Hersteller-BSP; siehe README)
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
#ifndef JC_USE_REAL_PANEL
|
|
||||||
#define JC_USE_REAL_PANEL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// DIAGNOSE: interner UART-Loopback-Selbsttest
|
|
||||||
// 1 = TX wird chip-intern auf RX gelegt (kein Draht, keine Pin-Unsicherheit).
|
|
||||||
// -> Laeuft "RX byte" im Debug-Panel hoch, sind Firmware+UART ok und das
|
|
||||||
// Problem liegt definitiv an Pins/Verkabelung. Bleibt es 0, ist es die
|
|
||||||
// Firmware/UART-Seite. NACH dem Test wieder auf 0 setzen!
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
#ifndef UART_SELFTEST_INTERNAL_LOOPBACK
|
|
||||||
#define UART_SELFTEST_INTERNAL_LOOPBACK 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// DIAGNOSE: gruenes On-Screen-Debug-Panel (UART-Zaehler/letzte Rohzeile)
|
|
||||||
// 0 = aus (normale UI). 1 = Panel unten einblenden (fuer UART-Fehlersuche).
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
#ifndef SHOW_DEBUG_OVERLAY
|
|
||||||
#define SHOW_DEBUG_OVERLAY 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// UART zur Hauptplatine
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Gegenseite (S3): Serial1, 230400 8N1, TX=GPIO43 / RX=GPIO44.
|
|
||||||
// Verkabelung gekreuzt: S3-TX(43) -> P4-RX, S3-RX(44) -> P4-TX, GND <-> GND.
|
|
||||||
//
|
|
||||||
// Pins laut Schaltplan "4_USB&IO.png" (Expand-IO-Header JP1). Frei herausgefuehrte
|
|
||||||
// P4-GPIOs dort: 52/51/50/49/35/34/33/32/31/30/29/28 (+ ES_I2C, +3V3/+5V/GND).
|
|
||||||
// Die rechte Header-Spalte (C6_U01TXD/C6_I10RXD/...) gehoert zum ESP32-C6 -> NICHT nutzen.
|
|
||||||
// Gewaehlt: P4-TX = GPIO33, P4-RX = GPIO31.
|
|
||||||
// JP1 GPIO33 (P4 TX) ----> S3 GPIO44 (RX)
|
|
||||||
// JP1 GPIO31 (P4 RX) <---- S3 GPIO43 (TX)
|
|
||||||
// JP1 GND ---- S3 GND
|
|
||||||
#define DISPLAY_UART_PORT Serial1
|
|
||||||
#define DISPLAY_UART_BAUDRATE 230400
|
|
||||||
#define DISPLAY_UART_TX_PIN 33
|
|
||||||
#define DISPLAY_UART_RX_PIN 31
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Firmware
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
#define DISPLAY_FW_VERSION "1.4.2" // Firmware-Stand der P4-Display-Steuerung (Info-Seite)
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Protokoll
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
#define PROTO_EXPECTED_VERSION 2 // muss zur S3-Firmware passen (TOUCH_UART_PROTOCOL_VERSION)
|
|
||||||
// Die State-Zeile der S3 kann mit langem Status-/Profil-/SSID-Text ueber 2 KB gehen. Wird
|
|
||||||
// das Limit erreicht, verwirft der Client die GANZE Zeile und das Display friert auf dem
|
|
||||||
// letzten Stand ein -> Reserve deutlich groesser als der reale Bedarf (~2,3 KB).
|
|
||||||
#define PROTO_RX_LINE_MAX 4096 // max. eingehende Zeilenlaenge (Bytes)
|
|
||||||
#define PROTO_HEARTBEAT_MS 5000 // Intervall fuer 'ping' (S3-Timeout = 15 s)
|
|
||||||
#define PROTO_HELLO_RETRY_MS 2000 // erneuter 'hello'-Versuch, solange nicht verbunden
|
|
||||||
#define PROTO_LINK_TIMEOUT_MS 8000 // ohne empfangene Nachricht -> Verbindung gilt als tot
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Display / LVGL
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Querformat: Panel ist physisch 480x800, per Rotation 90 (pins_config.h) -> 800x480.
|
|
||||||
#define DISP_HOR_RES 800
|
|
||||||
#define DISP_VER_RES 480
|
|
||||||
#define LVGL_TICK_MS 5
|
|
||||||
|
|
||||||
// Debug-Ausgaben ueber USB-CDC (nicht ueber den Display-UART!)
|
|
||||||
#define DBG_SERIAL Serial
|
|
||||||
#define DBG_BAUD 115200
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define EXAMPLE_LVGL_PORT_TASK_MAX_DELAY_MS 500 //range 2 to 2000
|
|
||||||
#define EXAMPLE_LVGL_PORT_TASK_MIN_DELAY_MS 5 //range 1 to 100
|
|
||||||
#define EXAMPLE_LVGL_PORT_TASK_PRIORITY 4
|
|
||||||
#define EXAMPLE_LVGL_PORT_TASK_STACK_SIZE_KB 32 //KB (erhoeht: komplexe UI, Listen-Rendering, JSON in Callbacks)
|
|
||||||
#define EXAMPLE_LVGL_PORT_TASK_CORE -1 //range -1 to 1
|
|
||||||
#define EXAMPLE_LVGL_PORT_TICK 2 //ragne 1 to 100
|
|
||||||
|
|
||||||
#define EXAMPLE_LVGL_PORT_AVOID_TEAR_ENABLE 1
|
|
||||||
|
|
||||||
#ifdef EXAMPLE_LVGL_PORT_AVOID_TEAR_ENABLE
|
|
||||||
// 2 = Triple-Buffer + LVGL Full-Refresh: zeichnet bei jeder Aenderung das komplette
|
|
||||||
// Bild, daher zeigen statische Flaechen (z.B. Tab-Leiste) nie alten Bufferinhalt.
|
|
||||||
// (Mode 3 = Direct-Mode flackert bei nie neu gezeichneten Bereichen.)
|
|
||||||
// Bei Rotation 90 nutzen beide Modi ohnehin 3 Framebuffer -> kein Mehrverbrauch.
|
|
||||||
#define EXAMPLE_LVGL_PORT_AVOID_TEAR_MODE 2 //range 1 to 3
|
|
||||||
|
|
||||||
#define EXAMPLE_LVGL_PORT_ROTATION_DEGREE_ 270 // 0,90,180,270 (270 = Querformat 800x480, um 180 Grad gedreht vs. 90)
|
|
||||||
#define EXAMPLE_LVGL_PORT_PPA_ROTATION_ENABLE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define LCD_H_RES 480
|
|
||||||
#define LCD_V_RES 800
|
|
||||||
|
|
||||||
#define LCD_RST -1
|
|
||||||
#define LCD_LED -1
|
|
||||||
|
|
||||||
#define TP_I2C_SDA 7
|
|
||||||
#define TP_I2C_SCL 8
|
|
||||||
#define TP_RST -1
|
|
||||||
#define TP_INT -1
|
|
||||||
|
After Width: | Height: | Size: 55 KiB |
@@ -0,0 +1,17 @@
|
|||||||
|
# 请使用arduino_esp32_v3.1版本
|
||||||
|
|
||||||
|
# lv_conf.h文件必要设置(lvgl_v8)
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define LV_COLOR_DEPTH 16
|
||||||
|
|
||||||
|
#define LV_COLOR_16_SWAP 0
|
||||||
|
|
||||||
|
#define LV_MEM_CUSTOM 1
|
||||||
|
|
||||||
|
#define LV_TICK_CUSTOM 1
|
||||||
|
|
||||||
|
#define LV_MEMCPY_MEMSET_STD 1
|
||||||
|
|
||||||
|
#define LV_ATTRIBUTE_FAST_MEM IRAM_ATTR
|
||||||
|
```
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#pragma GCC push_options
|
||||||
|
#pragma GCC optimize("O3")
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "lvgl.h"
|
||||||
|
#include "demos/lv_demos.h"
|
||||||
|
#include "pins_config.h"
|
||||||
|
#include "src/lcd/jd9165_lcd.h"
|
||||||
|
#include "src/touch/gt911_touch.h"123
|
||||||
|
|
||||||
|
jd9165_lcd lcd = jd9165_lcd(LCD_RST);
|
||||||
|
gt911_touch touch = gt911_touch(TP_I2C_SDA, TP_I2C_SCL, TP_RST, TP_INT);
|
||||||
|
|
||||||
|
static lv_disp_draw_buf_t draw_buf;
|
||||||
|
static lv_color_t *buf;
|
||||||
|
static lv_color_t *buf1;
|
||||||
|
|
||||||
|
// 显示刷新
|
||||||
|
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
|
||||||
|
{
|
||||||
|
const int offsetx1 = area->x1;
|
||||||
|
const int offsetx2 = area->x2;
|
||||||
|
const int offsety1 = area->y1;
|
||||||
|
const int offsety2 = area->y2;
|
||||||
|
lcd.lcd_draw_bitmap(offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, &color_p->full);
|
||||||
|
lv_disp_flush_ready(disp); // 告诉lvgl刷新完成
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||||
|
{
|
||||||
|
bool touched;
|
||||||
|
uint16_t touchX, touchY;
|
||||||
|
|
||||||
|
touched = touch.getTouch(&touchX, &touchY);
|
||||||
|
|
||||||
|
if (!touched)
|
||||||
|
{
|
||||||
|
data->state = LV_INDEV_STATE_REL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data->state = LV_INDEV_STATE_PR;
|
||||||
|
|
||||||
|
// 设置坐标
|
||||||
|
data->point.x = touchX;
|
||||||
|
data->point.y = touchY;
|
||||||
|
Serial.printf("x=%d,y=%d \r\n",touchX,touchY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lvgl_port_update_callback(lv_disp_drv_t *drv)
|
||||||
|
{
|
||||||
|
switch (drv->rotated) {
|
||||||
|
case LV_DISP_ROT_NONE:
|
||||||
|
touch.set_rotation(0);
|
||||||
|
break;
|
||||||
|
case LV_DISP_ROT_90:
|
||||||
|
touch.set_rotation(1);
|
||||||
|
break;
|
||||||
|
case LV_DISP_ROT_180:
|
||||||
|
touch.set_rotation(2);
|
||||||
|
break;
|
||||||
|
case LV_DISP_ROT_270:
|
||||||
|
touch.set_rotation(3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.println("ESP32P4 MIPI DSI LVGL");
|
||||||
|
lcd.begin();
|
||||||
|
touch.begin();
|
||||||
|
|
||||||
|
lv_init();
|
||||||
|
size_t buffer_size = sizeof(int32_t) * LCD_H_RES * LCD_V_RES;
|
||||||
|
// buf = (int32_t *)heap_caps_malloc(buffer_size, MALLOC_CAP_SPIRAM);
|
||||||
|
// buf1 = (int32_t *)heap_caps_malloc(buffer_size, MALLOC_CAP_SPIRAM);
|
||||||
|
buf = (lv_color_t *)heap_caps_malloc(buffer_size, MALLOC_CAP_SPIRAM);
|
||||||
|
buf1 = (lv_color_t *)heap_caps_malloc(buffer_size, MALLOC_CAP_SPIRAM);
|
||||||
|
assert(buf);
|
||||||
|
assert(buf1);
|
||||||
|
|
||||||
|
lv_disp_draw_buf_init(&draw_buf, buf, buf1, LCD_H_RES * LCD_V_RES);
|
||||||
|
|
||||||
|
static lv_disp_drv_t disp_drv;
|
||||||
|
/*Initialize the display*/
|
||||||
|
lv_disp_drv_init(&disp_drv);
|
||||||
|
disp_drv.hor_res = LCD_H_RES;
|
||||||
|
disp_drv.ver_res = LCD_V_RES;
|
||||||
|
disp_drv.flush_cb = my_disp_flush;
|
||||||
|
disp_drv.draw_buf = &draw_buf;
|
||||||
|
disp_drv.full_refresh = true;
|
||||||
|
lv_disp_drv_register(&disp_drv);
|
||||||
|
|
||||||
|
static lv_indev_drv_t indev_drv;
|
||||||
|
lv_indev_drv_init(&indev_drv);
|
||||||
|
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||||
|
indev_drv.read_cb = my_touchpad_read;
|
||||||
|
lv_indev_drv_register(&indev_drv);
|
||||||
|
|
||||||
|
// lv_disp_set_rotation(NULL, 0);
|
||||||
|
|
||||||
|
lv_demo_widgets(); /* 小部件示例 */
|
||||||
|
// lv_demo_music(); /* 类似智能手机的现代音乐播放器演示 */
|
||||||
|
// lv_demo_stress(); /* LVGL 压力测试 */
|
||||||
|
// lv_demo_benchmark(); /* 用于测量 LVGL 性能或比较不同设置的演示 */
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
lv_timer_handler();
|
||||||
|
delay(5);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define LCD_H_RES 1024
|
||||||
|
#define LCD_V_RES 600
|
||||||
|
|
||||||
|
#define LCD_RST 27
|
||||||
|
#define LCD_LED 23
|
||||||
|
|
||||||
|
#define TP_I2C_SDA 7
|
||||||
|
#define TP_I2C_SCL 8
|
||||||
|
#define TP_RST 22
|
||||||
|
#define TP_INT 21
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
|
#if SOC_MIPI_DSI_SUPPORTED
|
||||||
|
#include "esp_check.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_lcd_panel_commands.h"
|
||||||
|
#include "esp_lcd_panel_interface.h"
|
||||||
|
#include "esp_lcd_panel_io.h"
|
||||||
|
#include "esp_lcd_mipi_dsi.h"
|
||||||
|
#include "esp_lcd_panel_vendor.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_lcd_jd9165.h"
|
||||||
|
|
||||||
|
#define JD9165_CMD_GS_BIT (1 << 0)
|
||||||
|
#define JD9165_CMD_SS_BIT (1 << 1)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
esp_lcd_panel_io_handle_t io;
|
||||||
|
int reset_gpio_num;
|
||||||
|
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
||||||
|
uint8_t colmod_val; // save surrent value of LCD_CMD_COLMOD register
|
||||||
|
const jd9165_lcd_init_cmd_t *init_cmds;
|
||||||
|
uint16_t init_cmds_size;
|
||||||
|
struct {
|
||||||
|
unsigned int reset_level: 1;
|
||||||
|
} flags;
|
||||||
|
// To save the original functions of MIPI DPI panel
|
||||||
|
esp_err_t (*del)(esp_lcd_panel_t *panel);
|
||||||
|
esp_err_t (*init)(esp_lcd_panel_t *panel);
|
||||||
|
} jd9165_panel_t;
|
||||||
|
|
||||||
|
static const char *TAG = "jd9165";
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_del(esp_lcd_panel_t *panel);
|
||||||
|
static esp_err_t panel_jd9165_init(esp_lcd_panel_t *panel);
|
||||||
|
static esp_err_t panel_jd9165_reset(esp_lcd_panel_t *panel);
|
||||||
|
static esp_err_t panel_jd9165_invert_color(esp_lcd_panel_t *panel, bool invert_color_data);
|
||||||
|
static esp_err_t panel_jd9165_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y);
|
||||||
|
static esp_err_t panel_jd9165_disp_on_off(esp_lcd_panel_t *panel, bool on_off);
|
||||||
|
|
||||||
|
esp_err_t esp_lcd_new_panel_jd9165(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||||
|
esp_lcd_panel_handle_t *ret_panel)
|
||||||
|
{
|
||||||
|
ESP_RETURN_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, TAG, "invalid arguments");
|
||||||
|
jd9165_vendor_config_t *vendor_config = (jd9165_vendor_config_t *)panel_dev_config->vendor_config;
|
||||||
|
ESP_RETURN_ON_FALSE(vendor_config && vendor_config->mipi_config.dpi_config && vendor_config->mipi_config.dsi_bus, ESP_ERR_INVALID_ARG, TAG,
|
||||||
|
"invalid vendor config");
|
||||||
|
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)calloc(1, sizeof(jd9165_panel_t));
|
||||||
|
ESP_RETURN_ON_FALSE(jd9165, ESP_ERR_NO_MEM, TAG, "no mem for jd9165 panel");
|
||||||
|
|
||||||
|
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||||
|
gpio_config_t io_conf = {
|
||||||
|
.mode = GPIO_MODE_OUTPUT,
|
||||||
|
.pin_bit_mask = 1ULL << panel_dev_config->reset_gpio_num,
|
||||||
|
};
|
||||||
|
ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for RST line failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (panel_dev_config->color_space) {
|
||||||
|
case LCD_RGB_ELEMENT_ORDER_RGB:
|
||||||
|
jd9165->madctl_val = 0;
|
||||||
|
break;
|
||||||
|
case LCD_RGB_ELEMENT_ORDER_BGR:
|
||||||
|
jd9165->madctl_val |= LCD_CMD_BGR_BIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
jd9165->io = io;
|
||||||
|
jd9165->init_cmds = vendor_config->init_cmds;
|
||||||
|
jd9165->init_cmds_size = vendor_config->init_cmds_size;
|
||||||
|
jd9165->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||||
|
jd9165->flags.reset_level = panel_dev_config->flags.reset_active_high;
|
||||||
|
|
||||||
|
// Create MIPI DPI panel
|
||||||
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||||
|
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(vendor_config->mipi_config.dsi_bus, vendor_config->mipi_config.dpi_config, &panel_handle), err, TAG,
|
||||||
|
"create MIPI DPI panel failed");
|
||||||
|
ESP_LOGD(TAG, "new MIPI DPI panel @%p", panel_handle);
|
||||||
|
|
||||||
|
// Save the original functions of MIPI DPI panel
|
||||||
|
jd9165->del = panel_handle->del;
|
||||||
|
jd9165->init = panel_handle->init;
|
||||||
|
// Overwrite the functions of MIPI DPI panel
|
||||||
|
panel_handle->del = panel_jd9165_del;
|
||||||
|
panel_handle->init = panel_jd9165_init;
|
||||||
|
panel_handle->reset = panel_jd9165_reset;
|
||||||
|
panel_handle->mirror = panel_jd9165_mirror;
|
||||||
|
panel_handle->invert_color = panel_jd9165_invert_color;
|
||||||
|
panel_handle->disp_on_off = panel_jd9165_disp_on_off;
|
||||||
|
panel_handle->user_data = jd9165;
|
||||||
|
*ret_panel = panel_handle;
|
||||||
|
ESP_LOGD(TAG, "new jd9165 panel @%p", jd9165);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (jd9165) {
|
||||||
|
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||||
|
gpio_reset_pin(panel_dev_config->reset_gpio_num);
|
||||||
|
}
|
||||||
|
free(jd9165);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const jd9165_lcd_init_cmd_t vendor_specific_init_default[] = {
|
||||||
|
// {cmd, { data }, data_size, delay_ms}
|
||||||
|
//{0x11, (uint8_t []){0x00}, 1, 120},
|
||||||
|
//{0x29, (uint8_t []){0x00}, 1, 20},
|
||||||
|
|
||||||
|
{0x30, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0xF7, (uint8_t[]){0x49,0x61,0x02,0x00}, 4, 0},
|
||||||
|
{0x30, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
{0x04, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x05, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x06, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x0B, (uint8_t[]){0x11}, 1, 0},
|
||||||
|
{0x17, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x20, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x1F, (uint8_t[]){0x05}, 1, 0},
|
||||||
|
{0x23, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x25, (uint8_t[]){0x19}, 1, 0},
|
||||||
|
{0x28, (uint8_t[]){0x18}, 1, 0},
|
||||||
|
{0x29, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x2A, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
{0x2B, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x2C, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x02}, 1, 0},
|
||||||
|
{0x01, (uint8_t[]){0x22}, 1, 0},
|
||||||
|
{0x03, (uint8_t[]){0x12}, 1, 0},
|
||||||
|
{0x04, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x05, (uint8_t[]){0x64}, 1, 0},
|
||||||
|
{0x0A, (uint8_t[]){0x08}, 1, 0},
|
||||||
|
{0x0B, (uint8_t[]){0x0A,0x1A,0x0B,0x0D,0x0D,0x11,0x10,0x06,0x08,0x1F,0x1D}, 11, 0},
|
||||||
|
{0x0C, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x0D, (uint8_t[]){0x16,0x1B,0x0B,0x0D,0x0D,0x11,0x10,0x07,0x09,0x1E,0x1C}, 11, 0},
|
||||||
|
{0x0E, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x0F, (uint8_t[]){0x16,0x1B,0x0D,0x0B,0x0D,0x11,0x10,0x1C,0x1E,0x09,0x07}, 11, 0},
|
||||||
|
{0x10, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x11, (uint8_t[]){0x0A,0x1A,0x0D,0x0B,0x0D,0x11,0x10,0x1D,0x1F,0x08,0x06}, 11, 0},
|
||||||
|
{0x12, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x14, (uint8_t[]){0x00,0x00,0x11,0x11}, 4, 0},
|
||||||
|
{0x18, (uint8_t[]){0x99}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x06}, 1, 0},
|
||||||
|
{0x12, (uint8_t[]){0x36,0x2C,0x2E,0x3C,0x38,0x35,0x35,0x32,0x2E,0x1D,0x2B,0x21,0x16,0x29}, 14, 0},
|
||||||
|
{0x13, (uint8_t[]){0x36,0x2C,0x2E,0x3C,0x38,0x35,0x35,0x32,0x2E,0x1D,0x2B,0x21,0x16,0x29}, 14, 0},
|
||||||
|
|
||||||
|
// {0x30, (uint8_t[]){0x08}, 1, 0},
|
||||||
|
// {0x05, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
// {0x0C, (uint8_t[]){0x1A}, 1, 0},
|
||||||
|
// {0x0D, (uint8_t[]){0x0E}, 1, 0},
|
||||||
|
|
||||||
|
// {0x30, (uint8_t[]){0x07}, 1, 0},
|
||||||
|
// {0x01, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
|
||||||
|
{0x30, (uint8_t[]){0x0A}, 1, 0},
|
||||||
|
{0x02, (uint8_t[]){0x4F}, 1, 0},
|
||||||
|
{0x0B, (uint8_t[]){0x40}, 1, 0},
|
||||||
|
{0x12, (uint8_t[]){0x3E}, 1, 0},
|
||||||
|
{0x13, (uint8_t[]){0x78}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x0D}, 1, 0},
|
||||||
|
{0x0D, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x10, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x11, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x12, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x13, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
|
||||||
|
// {0X3A, (uint8_t[]){0x55}, 1, 0},
|
||||||
|
{0x11, (uint8_t[]){0x00}, 1, 120},
|
||||||
|
{0x29, (uint8_t[]){0x00}, 1, 50},
|
||||||
|
};
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_del(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
|
||||||
|
if (jd9165->reset_gpio_num >= 0) {
|
||||||
|
gpio_reset_pin(jd9165->reset_gpio_num);
|
||||||
|
}
|
||||||
|
// Delete MIPI DPI panel
|
||||||
|
jd9165->del(panel);
|
||||||
|
ESP_LOGD(TAG, "del jd9165 panel @%p", jd9165);
|
||||||
|
free(jd9165);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_init(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
const jd9165_lcd_init_cmd_t *init_cmds = NULL;
|
||||||
|
uint16_t init_cmds_size = 0;
|
||||||
|
bool is_cmd_overwritten = false;
|
||||||
|
|
||||||
|
uint8_t ID[3];
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_rx_param(io, 0x04, ID, 3), TAG, "read ID failed");
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) {
|
||||||
|
jd9165->madctl_val,
|
||||||
|
}, 1), TAG, "send command failed");
|
||||||
|
|
||||||
|
// vendor specific initialization, it can be different between manufacturers
|
||||||
|
// should consult the LCD supplier for initialization sequence code
|
||||||
|
if (jd9165->init_cmds) {
|
||||||
|
init_cmds = jd9165->init_cmds;
|
||||||
|
init_cmds_size = jd9165->init_cmds_size;
|
||||||
|
} else {
|
||||||
|
init_cmds = vendor_specific_init_default;
|
||||||
|
init_cmds_size = sizeof(vendor_specific_init_default) / sizeof(jd9165_lcd_init_cmd_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < init_cmds_size; i++) {
|
||||||
|
// Check if the command has been used or conflicts with the internal
|
||||||
|
if (init_cmds[i].data_bytes > 0) {
|
||||||
|
switch (init_cmds[i].cmd) {
|
||||||
|
case LCD_CMD_MADCTL:
|
||||||
|
is_cmd_overwritten = true;
|
||||||
|
jd9165->madctl_val = ((uint8_t *)init_cmds[i].data)[0];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
is_cmd_overwritten = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_cmd_overwritten) {
|
||||||
|
is_cmd_overwritten = false;
|
||||||
|
ESP_LOGW(TAG, "The %02Xh command has been used and will be overwritten by external initialization sequence",
|
||||||
|
init_cmds[i].cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send command
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, init_cmds[i].cmd, init_cmds[i].data, init_cmds[i].data_bytes), TAG, "send command failed");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(init_cmds[i].delay_ms));
|
||||||
|
}
|
||||||
|
ESP_LOGD(TAG, "send init commands success");
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(jd9165->init(panel), TAG, "init MIPI DPI panel failed");
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_reset(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
|
||||||
|
// Perform hardware reset
|
||||||
|
if (jd9165->reset_gpio_num >= 0) {
|
||||||
|
gpio_set_level(jd9165->reset_gpio_num, !jd9165->flags.reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(5));
|
||||||
|
gpio_set_level(jd9165->reset_gpio_num, jd9165->flags.reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
gpio_set_level(jd9165->reset_gpio_num, !jd9165->flags.reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(120));
|
||||||
|
} else if (io) { // Perform software reset
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0), TAG, "send command failed");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(120));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_invert_color(esp_lcd_panel_t *panel, bool invert_color_data)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
uint8_t command = 0;
|
||||||
|
|
||||||
|
ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_STATE, TAG, "invalid panel IO");
|
||||||
|
|
||||||
|
if (invert_color_data) {
|
||||||
|
command = LCD_CMD_INVON;
|
||||||
|
} else {
|
||||||
|
command = LCD_CMD_INVOFF;
|
||||||
|
}
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
uint8_t madctl_val = jd9165->madctl_val;
|
||||||
|
|
||||||
|
ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_STATE, TAG, "invalid panel IO");
|
||||||
|
|
||||||
|
// Control mirror through LCD command
|
||||||
|
if (mirror_x) {
|
||||||
|
madctl_val |= JD9165_CMD_GS_BIT;
|
||||||
|
} else {
|
||||||
|
madctl_val &= ~JD9165_CMD_GS_BIT;
|
||||||
|
}
|
||||||
|
if (mirror_y) {
|
||||||
|
madctl_val |= JD9165_CMD_SS_BIT;
|
||||||
|
} else {
|
||||||
|
madctl_val &= ~JD9165_CMD_SS_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t []) {
|
||||||
|
madctl_val
|
||||||
|
}, 1), TAG, "send command failed");
|
||||||
|
jd9165->madctl_val = madctl_val;
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
int command = 0;
|
||||||
|
|
||||||
|
if (on_off) {
|
||||||
|
command = LCD_CMD_DISPON;
|
||||||
|
} else {
|
||||||
|
command = LCD_CMD_DISPOFF;
|
||||||
|
}
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
|
#if SOC_MIPI_DSI_SUPPORTED
|
||||||
|
#include "esp_lcd_panel_vendor.h"
|
||||||
|
#include "esp_lcd_mipi_dsi.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LCD panel initialization commands.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int cmd; /*<! The specific LCD command */
|
||||||
|
const void *data; /*<! Buffer that holds the command specific data */
|
||||||
|
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
|
||||||
|
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
|
||||||
|
} jd9165_lcd_init_cmd_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LCD panel vendor configuration.
|
||||||
|
*
|
||||||
|
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
const jd9165_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
|
||||||
|
* The array should be declared as `static const` and positioned outside the function.
|
||||||
|
* Please refer to `vendor_specific_init_default` in source file.
|
||||||
|
*/
|
||||||
|
uint16_t init_cmds_size; /*<! Number of commands in above array */
|
||||||
|
struct {
|
||||||
|
esp_lcd_dsi_bus_handle_t dsi_bus; /*!< MIPI-DSI bus configuration */
|
||||||
|
const esp_lcd_dpi_panel_config_t *dpi_config; /*!< MIPI-DPI panel configuration */
|
||||||
|
} mipi_config;
|
||||||
|
} jd9165_vendor_config_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create LCD panel for model JD9165
|
||||||
|
*
|
||||||
|
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
|
||||||
|
*
|
||||||
|
* @param[in] io LCD panel IO handle
|
||||||
|
* @param[in] panel_dev_config General panel device configuration
|
||||||
|
* @param[out] ret_panel Returned LCD panel handle
|
||||||
|
* @return
|
||||||
|
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||||
|
* - ESP_OK on success
|
||||||
|
* - Otherwise on fail
|
||||||
|
*/
|
||||||
|
esp_err_t esp_lcd_new_panel_jd9165(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||||
|
esp_lcd_panel_handle_t *ret_panel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MIPI-DSI bus configuration structure
|
||||||
|
*
|
||||||
|
* @param[in] lane_num Number of data lanes
|
||||||
|
* @param[in] lane_mbps Lane bit rate in Mbps
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define JD9165_PANEL_BUS_DSI_2CH_CONFIG() \
|
||||||
|
{ \
|
||||||
|
.bus_id = 0, \
|
||||||
|
.num_data_lanes = 2, \
|
||||||
|
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, \
|
||||||
|
.lane_bit_rate_mbps = 750, \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MIPI-DBI panel IO configuration structure
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define JD9165_PANEL_IO_DBI_CONFIG() \
|
||||||
|
{ \
|
||||||
|
.virtual_channel = 0, \
|
||||||
|
.lcd_cmd_bits = 8, \
|
||||||
|
.lcd_param_bits = 8, \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MIPI DPI configuration structure
|
||||||
|
*
|
||||||
|
* @note refresh_rate = (dpi_clock_freq_mhz * 1000000) / (h_res + hsync_pulse_width + hsync_back_porch + hsync_front_porch)
|
||||||
|
* / (v_res + vsync_pulse_width + vsync_back_porch + vsync_front_porch)
|
||||||
|
*
|
||||||
|
* @param[in] px_format Pixel format of the panel
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define JD9165_1024_600_PANEL_60HZ_DPI_CONFIG(px_format) \
|
||||||
|
{ \
|
||||||
|
.virtual_channel = 0, \
|
||||||
|
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, \
|
||||||
|
.dpi_clock_freq_mhz = 56, \
|
||||||
|
.pixel_format = px_format, \
|
||||||
|
.num_fbs = 1, \
|
||||||
|
.video_timing = { \
|
||||||
|
.h_size = 1024, \
|
||||||
|
.v_size = 600, \
|
||||||
|
.hsync_pulse_width = 40, \
|
||||||
|
.hsync_back_porch = 160, \
|
||||||
|
.hsync_front_porch = 160, \
|
||||||
|
.vsync_pulse_width = 10, \
|
||||||
|
.vsync_back_porch = 23, \
|
||||||
|
.vsync_front_porch = 12, \
|
||||||
|
}, \
|
||||||
|
.flags= { \
|
||||||
|
.use_dma2d = true, \
|
||||||
|
}, \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#include "esp_lcd_panel_ops.h"
|
||||||
|
#include "esp_lcd_mipi_dsi.h"
|
||||||
|
#include "esp_lcd_panel_io.h"
|
||||||
|
#include "esp_ldo_regulator.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
#include "esp_lcd_jd9165.h"
|
||||||
|
#include "jd9165_lcd.h"
|
||||||
|
|
||||||
|
#define LCD_H_RES 1024
|
||||||
|
#define LCD_V_RES 600
|
||||||
|
|
||||||
|
#define MIPI_DPI_PX_FORMAT (LCD_COLOR_PIXEL_FORMAT_RGB565)
|
||||||
|
#define LCD_BIT_PER_PIXEL (16)
|
||||||
|
|
||||||
|
// “VDD_MIPI_DPHY”应供电 2.5V,可从内部 LDO 稳压器或外部 LDO 芯片获取电源
|
||||||
|
#define EXAMPLE_MIPI_DSI_PHY_PWR_LDO_CHAN 3 // LDO_VO3 连接至 VDD_MIPI_DPHY
|
||||||
|
#define EXAMPLE_MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV 2500
|
||||||
|
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
|
||||||
|
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||||
|
#define EXAMPLE_PIN_NUM_BK_LIGHT GPIO_NUM_23
|
||||||
|
|
||||||
|
static const char *TAG = "example";
|
||||||
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||||
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||||
|
|
||||||
|
jd9165_lcd::jd9165_lcd(int8_t lcd_rst)
|
||||||
|
{
|
||||||
|
_lcd_rst = lcd_rst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::example_bsp_enable_dsi_phy_power()
|
||||||
|
{
|
||||||
|
// 打开 MIPI DSI PHY 的电源,使其从“无电”状态进入“关机”状态
|
||||||
|
esp_ldo_channel_handle_t ldo_mipi_phy = NULL;
|
||||||
|
#ifdef EXAMPLE_MIPI_DSI_PHY_PWR_LDO_CHAN
|
||||||
|
esp_ldo_channel_config_t ldo_mipi_phy_config = {
|
||||||
|
.chan_id = EXAMPLE_MIPI_DSI_PHY_PWR_LDO_CHAN,
|
||||||
|
.voltage_mv = EXAMPLE_MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldo_mipi_phy));
|
||||||
|
ESP_LOGI(TAG, "MIPI DSI PHY Powered on");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::example_bsp_init_lcd_backlight()
|
||||||
|
{
|
||||||
|
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
|
||||||
|
gpio_config_t bk_gpio_config = {
|
||||||
|
.pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT,
|
||||||
|
.mode = GPIO_MODE_OUTPUT
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&bk_gpio_config));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::example_bsp_set_lcd_backlight(uint32_t level)
|
||||||
|
{
|
||||||
|
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
|
||||||
|
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, level);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::begin()
|
||||||
|
{
|
||||||
|
example_bsp_enable_dsi_phy_power();
|
||||||
|
example_bsp_init_lcd_backlight();
|
||||||
|
example_bsp_set_lcd_backlight(EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL);
|
||||||
|
|
||||||
|
// 首先创建 MIPI DSI 总线,它还将初始化 DSI PHY
|
||||||
|
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
|
||||||
|
esp_lcd_dsi_bus_config_t bus_config = JD9165_PANEL_BUS_DSI_2CH_CONFIG();
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Install MIPI DSI LCD control panel");
|
||||||
|
// 我们使用DBI接口发送LCD命令和参数
|
||||||
|
esp_lcd_dbi_io_config_t dbi_config = JD9165_PANEL_IO_DBI_CONFIG();
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io_handle));
|
||||||
|
|
||||||
|
// 创建JD9165控制面板
|
||||||
|
esp_lcd_dpi_panel_config_t dpi_config = JD9165_1024_600_PANEL_60HZ_DPI_CONFIG(MIPI_DPI_PX_FORMAT);
|
||||||
|
|
||||||
|
jd9165_vendor_config_t vendor_config = {
|
||||||
|
.mipi_config = {
|
||||||
|
.dsi_bus = mipi_dsi_bus,
|
||||||
|
.dpi_config = &dpi_config,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const esp_lcd_panel_dev_config_t panel_config = {
|
||||||
|
.reset_gpio_num = _lcd_rst,
|
||||||
|
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
|
||||||
|
.bits_per_pixel = LCD_BIT_PER_PIXEL,
|
||||||
|
.vendor_config = &vendor_config,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_new_panel_jd9165(io_handle, &panel_config, &panel_handle));
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
|
||||||
|
|
||||||
|
// 打开背光
|
||||||
|
example_bsp_set_lcd_backlight(EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::lcd_draw_bitmap(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint16_t *color_data)
|
||||||
|
{
|
||||||
|
esp_lcd_panel_draw_bitmap(panel_handle, x_start, y_start, x_end, y_end, color_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::draw16bitbergbbitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *color_data)
|
||||||
|
{
|
||||||
|
uint16_t x_start = x;
|
||||||
|
uint16_t y_start = y;
|
||||||
|
uint16_t x_end = w + x;
|
||||||
|
uint16_t y_end = h + y;
|
||||||
|
|
||||||
|
esp_lcd_panel_draw_bitmap(panel_handle, x_start, y_start, x_end, y_end, color_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::fillScreen(uint16_t color)
|
||||||
|
{
|
||||||
|
uint16_t *color_data = (uint16_t *)heap_caps_malloc(480 * 272 * 2, MALLOC_CAP_INTERNAL);
|
||||||
|
memset(color_data, color, 480 * 272 * 2);
|
||||||
|
draw16bitbergbbitmap(0, 0, 480, 272, color_data);
|
||||||
|
free(color_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::te_on()
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io_handle, 0x35,new (uint8_t[]){0x00}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::te_off()
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io_handle, 0x34,new (uint8_t[]){0x00}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t jd9165_lcd::width()
|
||||||
|
{
|
||||||
|
return LCD_H_RES;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t jd9165_lcd::height()
|
||||||
|
{
|
||||||
|
return LCD_V_RES;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef _JD9165_LCD_H
|
||||||
|
#define _JD9165_LCD_H
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class jd9165_lcd
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
jd9165_lcd(int8_t lcd_rst);
|
||||||
|
|
||||||
|
void begin();
|
||||||
|
void example_bsp_enable_dsi_phy_power();
|
||||||
|
void example_bsp_init_lcd_backlight();
|
||||||
|
void example_bsp_set_lcd_backlight(uint32_t level);
|
||||||
|
void lcd_draw_bitmap(uint16_t x_start, uint16_t y_start,
|
||||||
|
uint16_t x_end, uint16_t y_end, uint16_t *color_data);
|
||||||
|
void draw16bitbergbbitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *color_data);
|
||||||
|
void fillScreen(uint16_t color);
|
||||||
|
void te_on();
|
||||||
|
void te_off();
|
||||||
|
uint16_t width();
|
||||||
|
uint16_t height();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int8_t _lcd_rst;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_check.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
#include "esp_lcd_panel_io.h"
|
||||||
|
#include "esp_lcd_touch.h"
|
||||||
|
|
||||||
|
static const char *TAG = "GT911";
|
||||||
|
|
||||||
|
/* GT911 registers */
|
||||||
|
#define ESP_LCD_TOUCH_GT911_READ_XY_REG (0x814E)
|
||||||
|
#define ESP_LCD_TOUCH_GT911_CONFIG_REG (0x8047)
|
||||||
|
#define ESP_LCD_TOUCH_GT911_PRODUCT_ID_REG (0x8140)
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function definitions
|
||||||
|
*******************************************************************************/
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp);
|
||||||
|
static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num);
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp);
|
||||||
|
|
||||||
|
/* I2C read/write */
|
||||||
|
static esp_err_t touch_gt911_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len);
|
||||||
|
static esp_err_t touch_gt911_i2c_write(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t data);
|
||||||
|
|
||||||
|
/* GT911 reset */
|
||||||
|
static esp_err_t touch_gt911_reset(esp_lcd_touch_handle_t tp);
|
||||||
|
/* Read status and config register */
|
||||||
|
static esp_err_t touch_gt911_read_cfg(esp_lcd_touch_handle_t tp);
|
||||||
|
static void touch_scale(uint16_t *x_coordinate,uint16_t *y_coordinate);
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Public API functions
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *out_touch)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
assert(io != NULL);
|
||||||
|
assert(config != NULL);
|
||||||
|
assert(out_touch != NULL);
|
||||||
|
|
||||||
|
/* Prepare main structure */
|
||||||
|
esp_lcd_touch_handle_t esp_lcd_touch_gt911 = heap_caps_calloc(1, sizeof(esp_lcd_touch_t), MALLOC_CAP_DEFAULT);
|
||||||
|
ESP_GOTO_ON_FALSE(esp_lcd_touch_gt911, ESP_ERR_NO_MEM, err, TAG, "no mem for GT911 controller");
|
||||||
|
|
||||||
|
/* Communication interface */
|
||||||
|
esp_lcd_touch_gt911->io = io;
|
||||||
|
|
||||||
|
/* Only supported callbacks are set */
|
||||||
|
esp_lcd_touch_gt911->read_data = esp_lcd_touch_gt911_read_data;
|
||||||
|
esp_lcd_touch_gt911->get_xy = esp_lcd_touch_gt911_get_xy;
|
||||||
|
esp_lcd_touch_gt911->del = esp_lcd_touch_gt911_del;
|
||||||
|
|
||||||
|
/* Mutex */
|
||||||
|
esp_lcd_touch_gt911->data.lock.owner = portMUX_FREE_VAL;
|
||||||
|
|
||||||
|
/* Save config */
|
||||||
|
memcpy(&esp_lcd_touch_gt911->config, config, sizeof(esp_lcd_touch_config_t));
|
||||||
|
|
||||||
|
/* Prepare pin for touch interrupt */
|
||||||
|
if (esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) {
|
||||||
|
const gpio_config_t int_gpio_config = {
|
||||||
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
.intr_type = GPIO_INTR_NEGEDGE,
|
||||||
|
.pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.int_gpio_num)
|
||||||
|
};
|
||||||
|
ret = gpio_config(&int_gpio_config);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed");
|
||||||
|
|
||||||
|
/* Register interrupt callback */
|
||||||
|
if (esp_lcd_touch_gt911->config.interrupt_callback) {
|
||||||
|
esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_gt911, esp_lcd_touch_gt911->config.interrupt_callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prepare pin for touch controller reset */
|
||||||
|
if (esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC) {
|
||||||
|
const gpio_config_t rst_gpio_config = {
|
||||||
|
.mode = GPIO_MODE_OUTPUT,
|
||||||
|
.pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.rst_gpio_num)
|
||||||
|
};
|
||||||
|
ret = gpio_config(&rst_gpio_config);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset controller */
|
||||||
|
ret = touch_gt911_reset(esp_lcd_touch_gt911);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 reset failed");
|
||||||
|
|
||||||
|
/* Read status and config info */
|
||||||
|
ret = touch_gt911_read_cfg(esp_lcd_touch_gt911);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 init failed");
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Error (0x%x)! Touch controller GT911 initialization failed!", ret);
|
||||||
|
if (esp_lcd_touch_gt911) {
|
||||||
|
esp_lcd_touch_gt911_del(esp_lcd_touch_gt911);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_touch = esp_lcd_touch_gt911;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
esp_err_t err;
|
||||||
|
uint8_t buf[41];
|
||||||
|
uint8_t touch_cnt = 0;
|
||||||
|
uint8_t clear = 0;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
err = touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, buf, 1);
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||||
|
|
||||||
|
/* Any touch data? */
|
||||||
|
if ((buf[0] & 0x80) == 0x00) {
|
||||||
|
touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
|
||||||
|
} else {
|
||||||
|
/* Count of touched points */
|
||||||
|
touch_cnt = buf[0] & 0x0f;
|
||||||
|
if (touch_cnt > 5 || touch_cnt == 0) {
|
||||||
|
touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read all points */
|
||||||
|
err = touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG + 1, &buf[1], touch_cnt * 8);
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||||
|
|
||||||
|
/* Clear all */
|
||||||
|
err = touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||||
|
|
||||||
|
portENTER_CRITICAL(&tp->data.lock);
|
||||||
|
|
||||||
|
/* Number of touched points */
|
||||||
|
touch_cnt = (touch_cnt > CONFIG_ESP_LCD_TOUCH_MAX_POINTS ? CONFIG_ESP_LCD_TOUCH_MAX_POINTS : touch_cnt);
|
||||||
|
tp->data.points = touch_cnt;
|
||||||
|
|
||||||
|
/* Fill all coordinates */
|
||||||
|
for (i = 0; i < touch_cnt; i++) {
|
||||||
|
tp->data.coords[i].x = ((uint16_t)buf[(i * 8) + 3] << 8) + buf[(i * 8) + 2];
|
||||||
|
tp->data.coords[i].y = (((uint16_t)buf[(i * 8) + 5] << 8) + buf[(i * 8) + 4]);
|
||||||
|
tp->data.coords[i].strength = (((uint16_t)buf[(i * 8) + 7] << 8) + buf[(i * 8) + 6]);
|
||||||
|
}
|
||||||
|
|
||||||
|
portEXIT_CRITICAL(&tp->data.lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
assert(x != NULL);
|
||||||
|
assert(y != NULL);
|
||||||
|
assert(point_num != NULL);
|
||||||
|
assert(max_point_num > 0);
|
||||||
|
|
||||||
|
portENTER_CRITICAL(&tp->data.lock);
|
||||||
|
|
||||||
|
/* Count of points */
|
||||||
|
*point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < *point_num; i++) {
|
||||||
|
x[i] = tp->data.coords[i].x;
|
||||||
|
y[i] = tp->data.coords[i].y;
|
||||||
|
touch_scale(&x[i],&y[i]);
|
||||||
|
if (strength) {
|
||||||
|
strength[i] = tp->data.coords[i].strength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invalidate */
|
||||||
|
tp->data.points = 0;
|
||||||
|
|
||||||
|
portEXIT_CRITICAL(&tp->data.lock);
|
||||||
|
|
||||||
|
return (*point_num > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
/* Reset GPIO pin settings */
|
||||||
|
if (tp->config.int_gpio_num != GPIO_NUM_NC) {
|
||||||
|
gpio_reset_pin(tp->config.int_gpio_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset GPIO pin settings */
|
||||||
|
if (tp->config.rst_gpio_num != GPIO_NUM_NC) {
|
||||||
|
gpio_reset_pin(tp->config.rst_gpio_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(tp);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Private API function
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* Reset controller */
|
||||||
|
static esp_err_t touch_gt911_reset(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
if (tp->config.rst_gpio_num != GPIO_NUM_NC) {
|
||||||
|
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level error!");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, !tp->config.levels.reset), TAG, "GPIO set level error!");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t touch_gt911_read_cfg(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
uint8_t buf[4];
|
||||||
|
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_PRODUCT_ID_REG, (uint8_t *)&buf[0], 3), TAG, "GT911 read error!");
|
||||||
|
ESP_RETURN_ON_ERROR(touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_CONFIG_REG, (uint8_t *)&buf[3], 1), TAG, "GT911 read error!");
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "TouchPad_ID:0x%02x,0x%02x,0x%02x", buf[0], buf[1], buf[2]);
|
||||||
|
ESP_LOGI(TAG, "TouchPad_Config_Version:%d", buf[3]);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t touch_gt911_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
|
/* Read data */
|
||||||
|
return esp_lcd_panel_io_rx_param(tp->io, reg, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t touch_gt911_i2c_write(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t data)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
// *INDENT-OFF*
|
||||||
|
/* Write data */
|
||||||
|
return esp_lcd_panel_io_tx_param(tp->io, reg, (uint8_t[]){data}, 1);
|
||||||
|
// *INDENT-ON*
|
||||||
|
}
|
||||||
|
|
||||||
|
static void touch_scale(uint16_t *x_coordinate,uint16_t *y_coordinate)
|
||||||
|
{
|
||||||
|
uint32_t temp_x;
|
||||||
|
uint32_t temp_y;
|
||||||
|
|
||||||
|
temp_x = (*x_coordinate) * 1024 *10 / 800 / 10;
|
||||||
|
temp_y = (*y_coordinate) * 600 * 10 / 480 / 10;
|
||||||
|
|
||||||
|
*x_coordinate = (uint16_t)temp_x;
|
||||||
|
*y_coordinate = (uint16_t)temp_y;
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
#include "esp_lcd_touch_gt911.h"
|
||||||
|
#include "gt911_touch.h"
|
||||||
|
|
||||||
|
#define CONFIG_LCD_HRES 600
|
||||||
|
#define CONFIG_LCD_VRES 1024
|
||||||
|
|
||||||
|
static const char *TAG = "example";
|
||||||
|
|
||||||
|
esp_lcd_touch_handle_t tp;
|
||||||
|
esp_lcd_panel_io_handle_t tp_io_handle;
|
||||||
|
|
||||||
|
uint16_t touch_strength[1];
|
||||||
|
uint8_t touch_cnt = 0;
|
||||||
|
|
||||||
|
gt911_touch::gt911_touch(int8_t sda_pin, int8_t scl_pin, int8_t rst_pin, int8_t int_pin)
|
||||||
|
{
|
||||||
|
_sda = sda_pin;
|
||||||
|
_scl = scl_pin;
|
||||||
|
_rst = rst_pin;
|
||||||
|
_int = int_pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gt911_touch::begin()
|
||||||
|
{
|
||||||
|
i2c_config_t i2c_conf = {
|
||||||
|
.mode = I2C_MODE_MASTER,
|
||||||
|
.sda_io_num = (gpio_num_t)_sda,
|
||||||
|
.scl_io_num = (gpio_num_t)_scl,
|
||||||
|
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
};
|
||||||
|
i2c_conf.master.clk_speed = 400000; // 400kHz
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &i2c_conf));
|
||||||
|
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, i2c_conf.mode, 0, 0, 0));
|
||||||
|
|
||||||
|
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
|
||||||
|
ESP_LOGI(TAG, "Initialize touch IO (I2C)");
|
||||||
|
esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)I2C_NUM_0, &tp_io_config, &tp_io_handle);
|
||||||
|
|
||||||
|
esp_lcd_touch_config_t tp_cfg = {
|
||||||
|
.x_max = CONFIG_LCD_HRES,
|
||||||
|
.y_max = CONFIG_LCD_VRES,
|
||||||
|
.rst_gpio_num = (gpio_num_t)_rst,
|
||||||
|
.int_gpio_num = (gpio_num_t)_int,
|
||||||
|
.levels = {
|
||||||
|
.reset = 0,
|
||||||
|
.interrupt = 0,
|
||||||
|
},
|
||||||
|
.flags = {
|
||||||
|
.swap_xy = 0,
|
||||||
|
.mirror_x = 0,
|
||||||
|
.mirror_y = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Initialize touch controller gt911");
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gt911_touch::getTouch(uint16_t *x, uint16_t *y)
|
||||||
|
{
|
||||||
|
esp_lcd_touch_read_data(tp);
|
||||||
|
bool touchpad_pressed = esp_lcd_touch_get_coordinates(tp, x, y, touch_strength, &touch_cnt, 1);
|
||||||
|
|
||||||
|
return touchpad_pressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gt911_touch::set_rotation(uint8_t r){
|
||||||
|
switch(r){
|
||||||
|
case 0:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, true);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, false);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, true);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,703 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_conf.h
|
||||||
|
* Configuration file for v8.3.0-dev
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy this file as `lv_conf.h`
|
||||||
|
* 1. simply next to the `lvgl` folder
|
||||||
|
* 2. or any other places and
|
||||||
|
* - define `LV_CONF_INCLUDE_SIMPLE`
|
||||||
|
* - add the path as include path
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
#if 1 /*Set it to "1" to enable content*/
|
||||||
|
|
||||||
|
#ifndef LV_CONF_H
|
||||||
|
#define LV_CONF_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/*====================
|
||||||
|
COLOR SETTINGS
|
||||||
|
*====================*/
|
||||||
|
|
||||||
|
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
|
||||||
|
#define LV_COLOR_DEPTH 16
|
||||||
|
|
||||||
|
/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
|
||||||
|
#define LV_COLOR_16_SWAP 0
|
||||||
|
|
||||||
|
/*Enable more complex drawing routines to manage screens transparency.
|
||||||
|
*Can be used if the UI is above another layer, e.g. an OSD menu or video player.
|
||||||
|
*Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/
|
||||||
|
#define LV_COLOR_SCREEN_TRANSP 0
|
||||||
|
|
||||||
|
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
|
||||||
|
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
|
||||||
|
#define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
|
||||||
|
|
||||||
|
/*Images pixels with this color will not be drawn if they are chroma keyed)*/
|
||||||
|
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/
|
||||||
|
|
||||||
|
/*=========================
|
||||||
|
MEMORY SETTINGS
|
||||||
|
*=========================*/
|
||||||
|
|
||||||
|
/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
|
||||||
|
#define LV_MEM_CUSTOM 1
|
||||||
|
#if LV_MEM_CUSTOM == 0
|
||||||
|
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
||||||
|
#define LV_MEM_SIZE (40U * 1024U) /*[bytes]*/
|
||||||
|
|
||||||
|
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||||
|
#define LV_MEM_ADR 0 /*0: unused*/
|
||||||
|
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
|
||||||
|
#if LV_MEM_ADR == 0
|
||||||
|
//#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/
|
||||||
|
//#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /*LV_MEM_CUSTOM*/
|
||||||
|
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
|
||||||
|
#define LV_MEM_CUSTOM_ALLOC malloc
|
||||||
|
#define LV_MEM_CUSTOM_FREE free
|
||||||
|
#define LV_MEM_CUSTOM_REALLOC realloc
|
||||||
|
#endif /*LV_MEM_CUSTOM*/
|
||||||
|
|
||||||
|
/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
|
||||||
|
*You will see an error log message if there wasn't enough buffers. */
|
||||||
|
#define LV_MEM_BUF_MAX_NUM 16
|
||||||
|
|
||||||
|
/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/
|
||||||
|
#define LV_MEMCPY_MEMSET_STD 1
|
||||||
|
|
||||||
|
/*====================
|
||||||
|
HAL SETTINGS
|
||||||
|
*====================*/
|
||||||
|
|
||||||
|
/*Default display refresh period. LVG will redraw changed areas with this period time*/
|
||||||
|
#define LV_DISP_DEF_REFR_PERIOD 10 /*[ms]*/
|
||||||
|
|
||||||
|
/*Input device read period in milliseconds*/
|
||||||
|
#define LV_INDEV_DEF_READ_PERIOD 10 /*[ms]*/
|
||||||
|
|
||||||
|
/*Use a custom tick source that tells the elapsed time in milliseconds.
|
||||||
|
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
|
||||||
|
#define LV_TICK_CUSTOM 1
|
||||||
|
#if LV_TICK_CUSTOM
|
||||||
|
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
|
||||||
|
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
|
||||||
|
#endif /*LV_TICK_CUSTOM*/
|
||||||
|
|
||||||
|
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
|
||||||
|
*(Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||||
|
#define LV_DPI_DEF 130 /*[px/inch]*/
|
||||||
|
|
||||||
|
/*=======================
|
||||||
|
* FEATURE CONFIGURATION
|
||||||
|
*=======================*/
|
||||||
|
|
||||||
|
/*-------------
|
||||||
|
* Drawing
|
||||||
|
*-----------*/
|
||||||
|
|
||||||
|
/*Enable complex draw engine.
|
||||||
|
*Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/
|
||||||
|
#define LV_DRAW_COMPLEX 1
|
||||||
|
#if LV_DRAW_COMPLEX != 0
|
||||||
|
|
||||||
|
/*Allow buffering some shadow calculation.
|
||||||
|
*LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
|
||||||
|
*Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/
|
||||||
|
#define LV_SHADOW_CACHE_SIZE 0
|
||||||
|
|
||||||
|
/* Set number of maximally cached circle data.
|
||||||
|
* The circumference of 1/4 circle are saved for anti-aliasing
|
||||||
|
* radius * 4 bytes are used per circle (the most often used radiuses are saved)
|
||||||
|
* 0: to disable caching */
|
||||||
|
#define LV_CIRCLE_CACHE_SIZE 4
|
||||||
|
#endif /*LV_DRAW_COMPLEX*/
|
||||||
|
|
||||||
|
/*Default image cache size. Image caching keeps the images opened.
|
||||||
|
*If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added)
|
||||||
|
*With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
|
||||||
|
*However the opened images might consume additional RAM.
|
||||||
|
*0: to disable caching*/
|
||||||
|
#define LV_IMG_CACHE_DEF_SIZE 0
|
||||||
|
|
||||||
|
/*Number of stops allowed per gradient. Increase this to allow more stops.
|
||||||
|
*This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/
|
||||||
|
#define LV_GRADIENT_MAX_STOPS 2
|
||||||
|
|
||||||
|
/*Default gradient buffer size.
|
||||||
|
*When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again.
|
||||||
|
*LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes.
|
||||||
|
*If the cache is too small the map will be allocated only while it's required for the drawing.
|
||||||
|
*0 mean no caching.*/
|
||||||
|
#define LV_GRAD_CACHE_DEF_SIZE 0
|
||||||
|
|
||||||
|
/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display)
|
||||||
|
*LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface
|
||||||
|
*The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */
|
||||||
|
#define LV_DITHER_GRADIENT 0
|
||||||
|
#if LV_DITHER_GRADIENT
|
||||||
|
/*Add support for error diffusion dithering.
|
||||||
|
*Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing.
|
||||||
|
*The increase in memory consumption is (24 bits * object's width)*/
|
||||||
|
#define LV_DITHER_ERROR_DIFFUSION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Maximum buffer size to allocate for rotation.
|
||||||
|
*Only used if software rotation is enabled in the display driver.*/
|
||||||
|
#define LV_DISP_ROT_MAX_BUF (10*1024)
|
||||||
|
|
||||||
|
/*-------------
|
||||||
|
* GPU
|
||||||
|
*-----------*/
|
||||||
|
|
||||||
|
/*Use STM32's DMA2D (aka Chrom Art) GPU*/
|
||||||
|
#define LV_USE_GPU_STM32_DMA2D 0
|
||||||
|
#if LV_USE_GPU_STM32_DMA2D
|
||||||
|
/*Must be defined to include path of CMSIS header of target processor
|
||||||
|
e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||||
|
#define LV_GPU_DMA2D_CMSIS_INCLUDE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Use NXP's PXP GPU iMX RTxxx platforms*/
|
||||||
|
#define LV_USE_GPU_NXP_PXP 0
|
||||||
|
#if LV_USE_GPU_NXP_PXP
|
||||||
|
/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c)
|
||||||
|
* and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS
|
||||||
|
* has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected.
|
||||||
|
*0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init()
|
||||||
|
*/
|
||||||
|
#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/
|
||||||
|
#define LV_USE_GPU_NXP_VG_LITE 0
|
||||||
|
|
||||||
|
/*Use SDL renderer API*/
|
||||||
|
#define LV_USE_GPU_SDL 0
|
||||||
|
#if LV_USE_GPU_SDL
|
||||||
|
#define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||||
|
/*Texture cache size, 8MB by default*/
|
||||||
|
#define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8)
|
||||||
|
/*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/
|
||||||
|
#define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------
|
||||||
|
* Logging
|
||||||
|
*-----------*/
|
||||||
|
|
||||||
|
/*Enable the log module*/
|
||||||
|
#define LV_USE_LOG 0
|
||||||
|
#if LV_USE_LOG
|
||||||
|
|
||||||
|
/*How important log should be added:
|
||||||
|
*LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
|
||||||
|
*LV_LOG_LEVEL_INFO Log important events
|
||||||
|
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
|
||||||
|
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||||
|
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||||
|
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||||
|
#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||||
|
|
||||||
|
/*1: Print the log with 'printf';
|
||||||
|
*0: User need to register a callback with `lv_log_register_print_cb()`*/
|
||||||
|
#define LV_LOG_PRINTF 0
|
||||||
|
|
||||||
|
/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
|
||||||
|
#define LV_LOG_TRACE_MEM 1
|
||||||
|
#define LV_LOG_TRACE_TIMER 1
|
||||||
|
#define LV_LOG_TRACE_INDEV 1
|
||||||
|
#define LV_LOG_TRACE_DISP_REFR 1
|
||||||
|
#define LV_LOG_TRACE_EVENT 1
|
||||||
|
#define LV_LOG_TRACE_OBJ_CREATE 1
|
||||||
|
#define LV_LOG_TRACE_LAYOUT 1
|
||||||
|
#define LV_LOG_TRACE_ANIM 1
|
||||||
|
|
||||||
|
#endif /*LV_USE_LOG*/
|
||||||
|
|
||||||
|
/*-------------
|
||||||
|
* Asserts
|
||||||
|
*-----------*/
|
||||||
|
|
||||||
|
/*Enable asserts if an operation is failed or an invalid data is found.
|
||||||
|
*If LV_USE_LOG is enabled an error message will be printed on failure*/
|
||||||
|
#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/
|
||||||
|
#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
|
||||||
|
#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/
|
||||||
|
#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/
|
||||||
|
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
|
||||||
|
|
||||||
|
/*Add a custom handler when assert happens e.g. to restart the MCU*/
|
||||||
|
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
|
||||||
|
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
|
||||||
|
|
||||||
|
/*-------------
|
||||||
|
* Others
|
||||||
|
*-----------*/
|
||||||
|
|
||||||
|
/*1: Show CPU usage and FPS count*/
|
||||||
|
#define LV_USE_PERF_MONITOR 1
|
||||||
|
#if LV_USE_PERF_MONITOR
|
||||||
|
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*1: Show the used memory and the memory fragmentation
|
||||||
|
* Requires LV_MEM_CUSTOM = 0*/
|
||||||
|
#define LV_USE_MEM_MONITOR 0
|
||||||
|
#if LV_USE_MEM_MONITOR
|
||||||
|
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*1: Draw random colored rectangles over the redrawn areas*/
|
||||||
|
#define LV_USE_REFR_DEBUG 0
|
||||||
|
|
||||||
|
/*Change the built in (v)snprintf functions*/
|
||||||
|
#define LV_SPRINTF_CUSTOM 0
|
||||||
|
#if LV_SPRINTF_CUSTOM
|
||||||
|
#define LV_SPRINTF_INCLUDE <stdio.h>
|
||||||
|
#define lv_snprintf snprintf
|
||||||
|
#define lv_vsnprintf vsnprintf
|
||||||
|
#else /*LV_SPRINTF_CUSTOM*/
|
||||||
|
#define LV_SPRINTF_USE_FLOAT 0
|
||||||
|
#endif /*LV_SPRINTF_CUSTOM*/
|
||||||
|
|
||||||
|
#define LV_USE_USER_DATA 1
|
||||||
|
|
||||||
|
/*Garbage Collector settings
|
||||||
|
*Used if lvgl is bound to higher level language and the memory is managed by that language*/
|
||||||
|
#define LV_ENABLE_GC 0
|
||||||
|
#if LV_ENABLE_GC != 0
|
||||||
|
#define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
|
||||||
|
#endif /*LV_ENABLE_GC*/
|
||||||
|
|
||||||
|
/*=====================
|
||||||
|
* COMPILER SETTINGS
|
||||||
|
*====================*/
|
||||||
|
|
||||||
|
/*For big endian systems set to 1*/
|
||||||
|
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||||
|
|
||||||
|
/*Define a custom attribute to `lv_tick_inc` function*/
|
||||||
|
#define LV_ATTRIBUTE_TICK_INC
|
||||||
|
|
||||||
|
/*Define a custom attribute to `lv_timer_handler` function*/
|
||||||
|
#define LV_ATTRIBUTE_TIMER_HANDLER
|
||||||
|
|
||||||
|
/*Define a custom attribute to `lv_disp_flush_ready` function*/
|
||||||
|
#define LV_ATTRIBUTE_FLUSH_READY
|
||||||
|
|
||||||
|
/*Required alignment size for buffers*/
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1
|
||||||
|
|
||||||
|
/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default).
|
||||||
|
* E.g. __attribute__((aligned(4)))*/
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
|
||||||
|
/*Attribute to mark large constant arrays for example font's bitmaps*/
|
||||||
|
#define LV_ATTRIBUTE_LARGE_CONST
|
||||||
|
|
||||||
|
/*Compiler prefix for a big array declaration in RAM*/
|
||||||
|
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY
|
||||||
|
|
||||||
|
/*Place performance critical functions into a faster memory (e.g RAM)*/
|
||||||
|
#define LV_ATTRIBUTE_FAST_MEM IRAM_ATTR
|
||||||
|
|
||||||
|
/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/
|
||||||
|
#define LV_ATTRIBUTE_DMA
|
||||||
|
|
||||||
|
/*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that
|
||||||
|
*should also appear on LVGL binding API such as Micropython.*/
|
||||||
|
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/
|
||||||
|
|
||||||
|
/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/
|
||||||
|
#define LV_USE_LARGE_COORD 0
|
||||||
|
|
||||||
|
/*==================
|
||||||
|
* FONT USAGE
|
||||||
|
*===================*/
|
||||||
|
|
||||||
|
/*Montserrat fonts with ASCII range and some symbols using bpp = 4
|
||||||
|
*https://fonts.google.com/specimen/Montserrat*/
|
||||||
|
#define LV_FONT_MONTSERRAT_8 0
|
||||||
|
#define LV_FONT_MONTSERRAT_10 0
|
||||||
|
#define LV_FONT_MONTSERRAT_12 1
|
||||||
|
#define LV_FONT_MONTSERRAT_14 1
|
||||||
|
#define LV_FONT_MONTSERRAT_16 1
|
||||||
|
#define LV_FONT_MONTSERRAT_18 1
|
||||||
|
#define LV_FONT_MONTSERRAT_20 0
|
||||||
|
#define LV_FONT_MONTSERRAT_22 0
|
||||||
|
#define LV_FONT_MONTSERRAT_24 0
|
||||||
|
#define LV_FONT_MONTSERRAT_26 0
|
||||||
|
#define LV_FONT_MONTSERRAT_28 0
|
||||||
|
#define LV_FONT_MONTSERRAT_30 0
|
||||||
|
#define LV_FONT_MONTSERRAT_32 0
|
||||||
|
#define LV_FONT_MONTSERRAT_34 0
|
||||||
|
#define LV_FONT_MONTSERRAT_36 0
|
||||||
|
#define LV_FONT_MONTSERRAT_38 0
|
||||||
|
#define LV_FONT_MONTSERRAT_40 0
|
||||||
|
#define LV_FONT_MONTSERRAT_42 0
|
||||||
|
#define LV_FONT_MONTSERRAT_44 0
|
||||||
|
#define LV_FONT_MONTSERRAT_46 0
|
||||||
|
#define LV_FONT_MONTSERRAT_48 0
|
||||||
|
|
||||||
|
/*Demonstrate special features*/
|
||||||
|
#define LV_FONT_MONTSERRAT_12_SUBPX 0
|
||||||
|
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/
|
||||||
|
#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/
|
||||||
|
#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
|
||||||
|
|
||||||
|
/*Pixel perfect monospace fonts*/
|
||||||
|
#define LV_FONT_UNSCII_8 0
|
||||||
|
#define LV_FONT_UNSCII_16 0
|
||||||
|
|
||||||
|
/*Optionally declare custom fonts here.
|
||||||
|
*You can use these fonts as default font too and they will be available globally.
|
||||||
|
*E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
|
||||||
|
#define LV_FONT_CUSTOM_DECLARE
|
||||||
|
|
||||||
|
/*Always set a default font*/
|
||||||
|
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||||
|
|
||||||
|
/*Enable handling large font and/or fonts with a lot of characters.
|
||||||
|
*The limit depends on the font size, font face and bpp.
|
||||||
|
*Compiler error will be triggered if a font needs it.*/
|
||||||
|
#define LV_FONT_FMT_TXT_LARGE 0
|
||||||
|
|
||||||
|
/*Enables/disables support for compressed fonts.*/
|
||||||
|
#define LV_USE_FONT_COMPRESSED 0
|
||||||
|
|
||||||
|
/*Enable subpixel rendering*/
|
||||||
|
#define LV_USE_FONT_SUBPX 0
|
||||||
|
#if LV_USE_FONT_SUBPX
|
||||||
|
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
|
||||||
|
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*=================
|
||||||
|
* TEXT SETTINGS
|
||||||
|
*=================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select a character encoding for strings.
|
||||||
|
* Your IDE or editor should have the same character encoding
|
||||||
|
* - LV_TXT_ENC_UTF8
|
||||||
|
* - LV_TXT_ENC_ASCII
|
||||||
|
*/
|
||||||
|
#define LV_TXT_ENC LV_TXT_ENC_UTF8
|
||||||
|
|
||||||
|
/*Can break (wrap) texts on these chars*/
|
||||||
|
#define LV_TXT_BREAK_CHARS " ,.;:-_"
|
||||||
|
|
||||||
|
/*If a word is at least this long, will break wherever "prettiest"
|
||||||
|
*To disable, set to a value <= 0*/
|
||||||
|
#define LV_TXT_LINE_BREAK_LONG_LEN 0
|
||||||
|
|
||||||
|
/*Minimum number of characters in a long word to put on a line before a break.
|
||||||
|
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||||
|
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3
|
||||||
|
|
||||||
|
/*Minimum number of characters in a long word to put on a line after a break.
|
||||||
|
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||||
|
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3
|
||||||
|
|
||||||
|
/*The control character to use for signalling text recoloring.*/
|
||||||
|
#define LV_TXT_COLOR_CMD "#"
|
||||||
|
|
||||||
|
/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts.
|
||||||
|
*The direction will be processed according to the Unicode Bidirectional Algorithm:
|
||||||
|
*https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
|
||||||
|
#define LV_USE_BIDI 0
|
||||||
|
#if LV_USE_BIDI
|
||||||
|
/*Set the default direction. Supported values:
|
||||||
|
*`LV_BASE_DIR_LTR` Left-to-Right
|
||||||
|
*`LV_BASE_DIR_RTL` Right-to-Left
|
||||||
|
*`LV_BASE_DIR_AUTO` detect texts base direction*/
|
||||||
|
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Enable Arabic/Persian processing
|
||||||
|
*In these languages characters should be replaced with an other form based on their position in the text*/
|
||||||
|
#define LV_USE_ARABIC_PERSIAN_CHARS 0
|
||||||
|
|
||||||
|
/*==================
|
||||||
|
* WIDGET USAGE
|
||||||
|
*================*/
|
||||||
|
|
||||||
|
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
|
||||||
|
|
||||||
|
#define LV_USE_ARC 1
|
||||||
|
|
||||||
|
#define LV_USE_ANIMIMG 1
|
||||||
|
|
||||||
|
#define LV_USE_BAR 1
|
||||||
|
|
||||||
|
#define LV_USE_BTN 1
|
||||||
|
|
||||||
|
#define LV_USE_BTNMATRIX 1
|
||||||
|
|
||||||
|
#define LV_USE_CANVAS 1
|
||||||
|
|
||||||
|
#define LV_USE_CHECKBOX 1
|
||||||
|
|
||||||
|
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||||
|
|
||||||
|
#define LV_USE_IMG 1 /*Requires: lv_label*/
|
||||||
|
|
||||||
|
#define LV_USE_LABEL 1
|
||||||
|
#if LV_USE_LABEL
|
||||||
|
#define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||||
|
#define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LV_USE_LINE 1
|
||||||
|
|
||||||
|
#define LV_USE_ROLLER 1 /*Requires: lv_label*/
|
||||||
|
#if LV_USE_ROLLER
|
||||||
|
#define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LV_USE_SLIDER 1 /*Requires: lv_bar*/
|
||||||
|
|
||||||
|
#define LV_USE_SWITCH 1
|
||||||
|
|
||||||
|
#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
|
||||||
|
#if LV_USE_TEXTAREA != 0
|
||||||
|
#define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LV_USE_TABLE 1
|
||||||
|
|
||||||
|
/*==================
|
||||||
|
* EXTRA COMPONENTS
|
||||||
|
*==================*/
|
||||||
|
|
||||||
|
/*-----------
|
||||||
|
* Widgets
|
||||||
|
*----------*/
|
||||||
|
#define LV_USE_CALENDAR 1
|
||||||
|
#if LV_USE_CALENDAR
|
||||||
|
#define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||||
|
#if LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||||
|
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}
|
||||||
|
#else
|
||||||
|
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
|
||||||
|
#define LV_USE_CALENDAR_HEADER_ARROW 1
|
||||||
|
#define LV_USE_CALENDAR_HEADER_DROPDOWN 1
|
||||||
|
#endif /*LV_USE_CALENDAR*/
|
||||||
|
|
||||||
|
#define LV_USE_CHART 1
|
||||||
|
|
||||||
|
#define LV_USE_COLORWHEEL 1
|
||||||
|
|
||||||
|
#define LV_USE_IMGBTN 1
|
||||||
|
|
||||||
|
#define LV_USE_KEYBOARD 1
|
||||||
|
|
||||||
|
#define LV_USE_LED 1
|
||||||
|
|
||||||
|
#define LV_USE_LIST 1
|
||||||
|
|
||||||
|
#define LV_USE_MENU 1
|
||||||
|
|
||||||
|
#define LV_USE_METER 1
|
||||||
|
|
||||||
|
#define LV_USE_MSGBOX 1
|
||||||
|
|
||||||
|
#define LV_USE_SPINBOX 1
|
||||||
|
|
||||||
|
#define LV_USE_SPINNER 1
|
||||||
|
|
||||||
|
#define LV_USE_TABVIEW 1
|
||||||
|
|
||||||
|
#define LV_USE_TILEVIEW 1
|
||||||
|
|
||||||
|
#define LV_USE_WIN 1
|
||||||
|
|
||||||
|
#define LV_USE_SPAN 1
|
||||||
|
#if LV_USE_SPAN
|
||||||
|
/*A line text can contain maximum num of span descriptor */
|
||||||
|
#define LV_SPAN_SNIPPET_STACK_SIZE 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-----------
|
||||||
|
* Themes
|
||||||
|
*----------*/
|
||||||
|
|
||||||
|
/*A simple, impressive and very complete theme*/
|
||||||
|
#define LV_USE_THEME_DEFAULT 1
|
||||||
|
#if LV_USE_THEME_DEFAULT
|
||||||
|
|
||||||
|
/*0: Light mode; 1: Dark mode*/
|
||||||
|
#define LV_THEME_DEFAULT_DARK 0
|
||||||
|
|
||||||
|
/*1: Enable grow on press*/
|
||||||
|
#define LV_THEME_DEFAULT_GROW 1
|
||||||
|
|
||||||
|
/*Default transition time in [ms]*/
|
||||||
|
#define LV_THEME_DEFAULT_TRANSITION_TIME 80
|
||||||
|
#endif /*LV_USE_THEME_DEFAULT*/
|
||||||
|
|
||||||
|
/*A very simple theme that is a good starting point for a custom theme*/
|
||||||
|
#define LV_USE_THEME_BASIC 1
|
||||||
|
|
||||||
|
/*A theme designed for monochrome displays*/
|
||||||
|
#define LV_USE_THEME_MONO 1
|
||||||
|
|
||||||
|
/*-----------
|
||||||
|
* Layouts
|
||||||
|
*----------*/
|
||||||
|
|
||||||
|
/*A layout similar to Flexbox in CSS.*/
|
||||||
|
#define LV_USE_FLEX 1
|
||||||
|
|
||||||
|
/*A layout similar to Grid in CSS.*/
|
||||||
|
#define LV_USE_GRID 1
|
||||||
|
|
||||||
|
/*---------------------
|
||||||
|
* 3rd party libraries
|
||||||
|
*--------------------*/
|
||||||
|
|
||||||
|
/*File system interfaces for common APIs */
|
||||||
|
|
||||||
|
/*API for fopen, fread, etc*/
|
||||||
|
#define LV_USE_FS_STDIO 0
|
||||||
|
#if LV_USE_FS_STDIO
|
||||||
|
#define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||||
|
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||||
|
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*API for open, read, etc*/
|
||||||
|
#define LV_USE_FS_POSIX 0
|
||||||
|
#if LV_USE_FS_POSIX
|
||||||
|
#define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||||
|
#define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||||
|
#define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*API for CreateFile, ReadFile, etc*/
|
||||||
|
#define LV_USE_FS_WIN32 0
|
||||||
|
#if LV_USE_FS_WIN32
|
||||||
|
#define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||||
|
#define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||||
|
#define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
|
||||||
|
#define LV_USE_FS_FATFS 0
|
||||||
|
#if LV_USE_FS_FATFS
|
||||||
|
#define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||||
|
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*PNG decoder library*/
|
||||||
|
#define LV_USE_PNG 0
|
||||||
|
|
||||||
|
/*BMP decoder library*/
|
||||||
|
#define LV_USE_BMP 0
|
||||||
|
|
||||||
|
/* JPG + split JPG decoder library.
|
||||||
|
* Split JPG is a custom format optimized for embedded systems. */
|
||||||
|
#define LV_USE_SJPG 0
|
||||||
|
|
||||||
|
/*GIF decoder library*/
|
||||||
|
#define LV_USE_GIF 0
|
||||||
|
|
||||||
|
/*QR code library*/
|
||||||
|
#define LV_USE_QRCODE 0
|
||||||
|
|
||||||
|
/*FreeType library*/
|
||||||
|
#define LV_USE_FREETYPE 0
|
||||||
|
#if LV_USE_FREETYPE
|
||||||
|
/*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/
|
||||||
|
#define LV_FREETYPE_CACHE_SIZE (16 * 1024)
|
||||||
|
#if LV_FREETYPE_CACHE_SIZE >= 0
|
||||||
|
/* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */
|
||||||
|
/* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */
|
||||||
|
/* if font size >= 256, must be configured as image cache */
|
||||||
|
#define LV_FREETYPE_SBIT_CACHE 0
|
||||||
|
/* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */
|
||||||
|
/* (0:use system defaults) */
|
||||||
|
#define LV_FREETYPE_CACHE_FT_FACES 0
|
||||||
|
#define LV_FREETYPE_CACHE_FT_SIZES 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Rlottie library*/
|
||||||
|
#define LV_USE_RLOTTIE 0
|
||||||
|
|
||||||
|
/*FFmpeg library for image decoding and playing videos
|
||||||
|
*Supports all major image formats so do not enable other image decoder with it*/
|
||||||
|
#define LV_USE_FFMPEG 0
|
||||||
|
#if LV_USE_FFMPEG
|
||||||
|
/*Dump input information to stderr*/
|
||||||
|
#define LV_FFMPEG_AV_DUMP_FORMAT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-----------
|
||||||
|
* Others
|
||||||
|
*----------*/
|
||||||
|
|
||||||
|
/*1: Enable API to take snapshot for object*/
|
||||||
|
#define LV_USE_SNAPSHOT 0
|
||||||
|
|
||||||
|
/*1: Enable Monkey test*/
|
||||||
|
#define LV_USE_MONKEY 0
|
||||||
|
|
||||||
|
/*1: Enable grid navigation*/
|
||||||
|
#define LV_USE_GRIDNAV 0
|
||||||
|
|
||||||
|
/*1: Enable lv_obj fragment*/
|
||||||
|
#define LV_USE_FRAGMENT 0
|
||||||
|
|
||||||
|
/*==================
|
||||||
|
* EXAMPLES
|
||||||
|
*==================*/
|
||||||
|
|
||||||
|
/*Enable the examples to be built with the library*/
|
||||||
|
#define LV_BUILD_EXAMPLES 1
|
||||||
|
|
||||||
|
/*===================
|
||||||
|
* DEMO USAGE
|
||||||
|
====================*/
|
||||||
|
|
||||||
|
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */
|
||||||
|
#define LV_USE_DEMO_WIDGETS 1
|
||||||
|
#if LV_USE_DEMO_WIDGETS
|
||||||
|
#define LV_DEMO_WIDGETS_SLIDESHOW 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Demonstrate the usage of encoder and keyboard*/
|
||||||
|
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1
|
||||||
|
|
||||||
|
/*Benchmark your system*/
|
||||||
|
#define LV_USE_DEMO_BENCHMARK 1
|
||||||
|
|
||||||
|
/*Stress test for LVGL*/
|
||||||
|
#define LV_USE_DEMO_STRESS 1
|
||||||
|
|
||||||
|
/*Music player demo*/
|
||||||
|
#define LV_USE_DEMO_MUSIC 1
|
||||||
|
#if LV_USE_DEMO_MUSIC
|
||||||
|
# define LV_DEMO_MUSIC_SQUARE 0
|
||||||
|
# define LV_DEMO_MUSIC_LANDSCAPE 0
|
||||||
|
# define LV_DEMO_MUSIC_ROUND 0
|
||||||
|
# define LV_DEMO_MUSIC_LARGE 0
|
||||||
|
# define LV_DEMO_MUSIC_AUTO_PLAY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*--END OF LV_CONF_H--*/
|
||||||
|
|
||||||
|
#endif /*LV_CONF_H*/
|
||||||
|
|
||||||
|
#endif /*End of "Content enable"*/
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ESP32 version V3.1.0 LVGL version V8.4
|
||||||
|
After Width: | Height: | Size: 55 KiB |
@@ -0,0 +1,17 @@
|
|||||||
|
# 请使用arduino_esp32_v3.1版本
|
||||||
|
|
||||||
|
# lv_conf.h文件必要设置(lvgl_v8)
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define LV_COLOR_DEPTH 16
|
||||||
|
|
||||||
|
#define LV_COLOR_16_SWAP 0
|
||||||
|
|
||||||
|
#define LV_MEM_CUSTOM 1
|
||||||
|
|
||||||
|
#define LV_TICK_CUSTOM 1
|
||||||
|
|
||||||
|
#define LV_MEMCPY_MEMSET_STD 1
|
||||||
|
|
||||||
|
#define LV_ATTRIBUTE_FAST_MEM IRAM_ATTR
|
||||||
|
```
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#pragma GCC push_options
|
||||||
|
#pragma GCC optimize("O3")
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "lvgl.h"
|
||||||
|
#include "demos/lv_demos.h"
|
||||||
|
#include "pins_config.h"
|
||||||
|
#include "src/lcd/jd9165_lcd.h"
|
||||||
|
#include "src/touch/gt911_touch.h"
|
||||||
|
|
||||||
|
jd9165_lcd lcd = jd9165_lcd(LCD_RST);
|
||||||
|
gt911_touch touch = gt911_touch(TP_I2C_SDA, TP_I2C_SCL, TP_RST, TP_INT);
|
||||||
|
|
||||||
|
// static lv_disp_draw_buf_t draw_buf;
|
||||||
|
lv_display_t * disp_drv;
|
||||||
|
static uint32_t *buf;
|
||||||
|
static uint32_t *buf1;
|
||||||
|
|
||||||
|
// 显示刷新
|
||||||
|
void my_disp_flush( lv_display_t *disp, const lv_area_t *area, uint8_t * color_map)
|
||||||
|
{
|
||||||
|
const int offsetx1 = area->x1;
|
||||||
|
const int offsetx2 = area->x2;
|
||||||
|
const int offsety1 = area->y1;
|
||||||
|
const int offsety2 = area->y2;
|
||||||
|
lcd.lcd_draw_bitmap(offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
|
||||||
|
lv_display_flush_ready(disp); // 告诉lvgl刷新完成
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data)
|
||||||
|
{
|
||||||
|
bool touched;
|
||||||
|
uint16_t touchX, touchY;
|
||||||
|
|
||||||
|
touched = touch.getTouch(&touchX, &touchY);
|
||||||
|
|
||||||
|
if (!touched)
|
||||||
|
{
|
||||||
|
data->state = LV_INDEV_STATE_REL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data->state = LV_INDEV_STATE_PR;
|
||||||
|
|
||||||
|
// 设置坐标
|
||||||
|
data->point.x = touchX;
|
||||||
|
data->point.y = touchY;
|
||||||
|
Serial.printf("x=%d,y=%d \r\n",touchX,touchY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.println("ESP32P4 MIPI DSI LVGL");
|
||||||
|
lcd.begin();
|
||||||
|
touch.begin();
|
||||||
|
|
||||||
|
lv_init();
|
||||||
|
uint32_t buffer_size = LCD_H_RES * LCD_V_RES;
|
||||||
|
|
||||||
|
buf = (uint32_t *)heap_caps_malloc(buffer_size, MALLOC_CAP_SPIRAM);
|
||||||
|
buf1 =(uint32_t *)heap_caps_malloc(buffer_size, MALLOC_CAP_SPIRAM);
|
||||||
|
assert(buf);
|
||||||
|
assert(buf1);
|
||||||
|
|
||||||
|
disp_drv = lv_display_create(LCD_H_RES, LCD_V_RES);
|
||||||
|
lv_display_set_flush_cb(disp_drv, my_disp_flush);
|
||||||
|
lv_display_set_buffers(disp_drv, buf, buf1, buffer_size * sizeof(uint32_t), LV_DISPLAY_RENDER_MODE_FULL);
|
||||||
|
/*Initialize the display*/
|
||||||
|
|
||||||
|
lv_indev_t * indev = lv_indev_create();
|
||||||
|
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
|
||||||
|
lv_indev_set_read_cb(indev, my_touchpad_read);
|
||||||
|
|
||||||
|
lv_demo_widgets(); /* 小部件示例 */
|
||||||
|
// lv_demo_music(); /* 类似智能手机的现代音乐播放器演示 */
|
||||||
|
// lv_demo_stress(); /* LVGL 压力测试 */
|
||||||
|
// lv_demo_benchmark(); /* 用于测量 LVGL 性能或比较不同设置的演示 */
|
||||||
|
Serial.println("setup ");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
lv_timer_handler();
|
||||||
|
delay(5);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define LCD_H_RES 1024
|
||||||
|
#define LCD_V_RES 600
|
||||||
|
|
||||||
|
#define LCD_RST 27
|
||||||
|
#define LCD_LED 23
|
||||||
|
|
||||||
|
#define TP_I2C_SDA 7
|
||||||
|
#define TP_I2C_SCL 8
|
||||||
|
#define TP_RST -1
|
||||||
|
#define TP_INT -1
|
||||||
@@ -0,0 +1,341 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
|
#if SOC_MIPI_DSI_SUPPORTED
|
||||||
|
#include "esp_check.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_lcd_panel_commands.h"
|
||||||
|
#include "esp_lcd_panel_interface.h"
|
||||||
|
#include "esp_lcd_panel_io.h"
|
||||||
|
#include "esp_lcd_mipi_dsi.h"
|
||||||
|
#include "esp_lcd_panel_vendor.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_lcd_jd9165.h"
|
||||||
|
|
||||||
|
#define JD9165_CMD_GS_BIT (1 << 0)
|
||||||
|
#define JD9165_CMD_SS_BIT (1 << 1)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
esp_lcd_panel_io_handle_t io;
|
||||||
|
int reset_gpio_num;
|
||||||
|
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
||||||
|
uint8_t colmod_val; // save surrent value of LCD_CMD_COLMOD register
|
||||||
|
const jd9165_lcd_init_cmd_t *init_cmds;
|
||||||
|
uint16_t init_cmds_size;
|
||||||
|
struct {
|
||||||
|
unsigned int reset_level: 1;
|
||||||
|
} flags;
|
||||||
|
// To save the original functions of MIPI DPI panel
|
||||||
|
esp_err_t (*del)(esp_lcd_panel_t *panel);
|
||||||
|
esp_err_t (*init)(esp_lcd_panel_t *panel);
|
||||||
|
} jd9165_panel_t;
|
||||||
|
|
||||||
|
static const char *TAG = "jd9165";
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_del(esp_lcd_panel_t *panel);
|
||||||
|
static esp_err_t panel_jd9165_init(esp_lcd_panel_t *panel);
|
||||||
|
static esp_err_t panel_jd9165_reset(esp_lcd_panel_t *panel);
|
||||||
|
static esp_err_t panel_jd9165_invert_color(esp_lcd_panel_t *panel, bool invert_color_data);
|
||||||
|
static esp_err_t panel_jd9165_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y);
|
||||||
|
static esp_err_t panel_jd9165_disp_on_off(esp_lcd_panel_t *panel, bool on_off);
|
||||||
|
|
||||||
|
esp_err_t esp_lcd_new_panel_jd9165(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||||
|
esp_lcd_panel_handle_t *ret_panel)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG,"jd9165:1.0.1");
|
||||||
|
ESP_RETURN_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, TAG, "invalid arguments");
|
||||||
|
jd9165_vendor_config_t *vendor_config = (jd9165_vendor_config_t *)panel_dev_config->vendor_config;
|
||||||
|
ESP_RETURN_ON_FALSE(vendor_config && vendor_config->mipi_config.dpi_config && vendor_config->mipi_config.dsi_bus, ESP_ERR_INVALID_ARG, TAG,
|
||||||
|
"invalid vendor config");
|
||||||
|
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)calloc(1, sizeof(jd9165_panel_t));
|
||||||
|
ESP_RETURN_ON_FALSE(jd9165, ESP_ERR_NO_MEM, TAG, "no mem for jd9165 panel");
|
||||||
|
|
||||||
|
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||||
|
gpio_config_t io_conf = {
|
||||||
|
.mode = GPIO_MODE_OUTPUT,
|
||||||
|
.pin_bit_mask = 1ULL << panel_dev_config->reset_gpio_num,
|
||||||
|
};
|
||||||
|
ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for RST line failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (panel_dev_config->color_space) {
|
||||||
|
case LCD_RGB_ELEMENT_ORDER_RGB:
|
||||||
|
jd9165->madctl_val = 0;
|
||||||
|
break;
|
||||||
|
case LCD_RGB_ELEMENT_ORDER_BGR:
|
||||||
|
jd9165->madctl_val |= LCD_CMD_BGR_BIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported color space");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
jd9165->io = io;
|
||||||
|
jd9165->init_cmds = vendor_config->init_cmds;
|
||||||
|
jd9165->init_cmds_size = vendor_config->init_cmds_size;
|
||||||
|
jd9165->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||||
|
jd9165->flags.reset_level = panel_dev_config->flags.reset_active_high;
|
||||||
|
|
||||||
|
// Create MIPI DPI panel
|
||||||
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||||
|
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(vendor_config->mipi_config.dsi_bus, vendor_config->mipi_config.dpi_config, &panel_handle), err, TAG,
|
||||||
|
"create MIPI DPI panel failed");
|
||||||
|
ESP_LOGD(TAG, "new MIPI DPI panel @%p", panel_handle);
|
||||||
|
|
||||||
|
// Save the original functions of MIPI DPI panel
|
||||||
|
jd9165->del = panel_handle->del;
|
||||||
|
jd9165->init = panel_handle->init;
|
||||||
|
// Overwrite the functions of MIPI DPI panel
|
||||||
|
panel_handle->del = panel_jd9165_del;
|
||||||
|
panel_handle->init = panel_jd9165_init;
|
||||||
|
panel_handle->reset = panel_jd9165_reset;
|
||||||
|
panel_handle->mirror = panel_jd9165_mirror;
|
||||||
|
panel_handle->invert_color = panel_jd9165_invert_color;
|
||||||
|
panel_handle->disp_on_off = panel_jd9165_disp_on_off;
|
||||||
|
panel_handle->user_data = jd9165;
|
||||||
|
*ret_panel = panel_handle;
|
||||||
|
ESP_LOGD(TAG, "new jd9165 panel @%p", jd9165);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (jd9165) {
|
||||||
|
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||||
|
gpio_reset_pin(panel_dev_config->reset_gpio_num);
|
||||||
|
}
|
||||||
|
free(jd9165);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const jd9165_lcd_init_cmd_t vendor_specific_init_default[] = {
|
||||||
|
// {cmd, { data }, data_size, delay_ms}
|
||||||
|
//{0x11, (uint8_t []){0x00}, 1, 120},
|
||||||
|
//{0x29, (uint8_t []){0x00}, 1, 20},
|
||||||
|
|
||||||
|
{0x30, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0xF7, (uint8_t[]){0x49,0x61,0x02,0x00}, 4, 0},
|
||||||
|
{0x30, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
{0x04, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x05, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x06, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x0B, (uint8_t[]){0x11}, 1, 0},
|
||||||
|
{0x17, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x20, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x1F, (uint8_t[]){0x05}, 1, 0},
|
||||||
|
{0x23, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x25, (uint8_t[]){0x19}, 1, 0},
|
||||||
|
{0x28, (uint8_t[]){0x18}, 1, 0},
|
||||||
|
{0x29, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x2A, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
{0x2B, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x2C, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x02}, 1, 0},
|
||||||
|
{0x01, (uint8_t[]){0x22}, 1, 0},
|
||||||
|
{0x03, (uint8_t[]){0x12}, 1, 0},
|
||||||
|
{0x04, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
{0x05, (uint8_t[]){0x64}, 1, 0},
|
||||||
|
{0x0A, (uint8_t[]){0x08}, 1, 0},
|
||||||
|
{0x0B, (uint8_t[]){0x0A,0x1A,0x0B,0x0D,0x0D,0x11,0x10,0x06,0x08,0x1F,0x1D}, 11, 0},
|
||||||
|
{0x0C, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x0D, (uint8_t[]){0x16,0x1B,0x0B,0x0D,0x0D,0x11,0x10,0x07,0x09,0x1E,0x1C}, 11, 0},
|
||||||
|
{0x0E, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x0F, (uint8_t[]){0x16,0x1B,0x0D,0x0B,0x0D,0x11,0x10,0x1C,0x1E,0x09,0x07}, 11, 0},
|
||||||
|
{0x10, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x11, (uint8_t[]){0x0A,0x1A,0x0D,0x0B,0x0D,0x11,0x10,0x1D,0x1F,0x08,0x06}, 11, 0},
|
||||||
|
{0x12, (uint8_t[]){0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}, 11, 0},
|
||||||
|
{0x14, (uint8_t[]){0x00,0x00,0x11,0x11}, 4, 0},
|
||||||
|
{0x18, (uint8_t[]){0x99}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x06}, 1, 0},
|
||||||
|
{0x12, (uint8_t[]){0x36,0x2C,0x2E,0x3C,0x38,0x35,0x35,0x32,0x2E,0x1D,0x2B,0x21,0x16,0x29}, 14, 0},
|
||||||
|
{0x13, (uint8_t[]){0x36,0x2C,0x2E,0x3C,0x38,0x35,0x35,0x32,0x2E,0x1D,0x2B,0x21,0x16,0x29}, 14, 0},
|
||||||
|
|
||||||
|
// {0x30, (uint8_t[]){0x08}, 1, 0},
|
||||||
|
// {0x05, (uint8_t[]){0x01}, 1, 0},
|
||||||
|
// {0x0C, (uint8_t[]){0x1A}, 1, 0},
|
||||||
|
// {0x0D, (uint8_t[]){0x0E}, 1, 0},
|
||||||
|
|
||||||
|
// {0x30, (uint8_t[]){0x07}, 1, 0},
|
||||||
|
// {0x01, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
|
||||||
|
{0x30, (uint8_t[]){0x0A}, 1, 0},
|
||||||
|
{0x02, (uint8_t[]){0x4F}, 1, 0},
|
||||||
|
{0x0B, (uint8_t[]){0x40}, 1, 0},
|
||||||
|
{0x12, (uint8_t[]){0x3E}, 1, 0},
|
||||||
|
{0x13, (uint8_t[]){0x78}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x0D}, 1, 0},
|
||||||
|
{0x0D, (uint8_t[]){0x04}, 1, 0},
|
||||||
|
{0x10, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x11, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x12, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x13, (uint8_t[]){0x0C}, 1, 0},
|
||||||
|
{0x30, (uint8_t[]){0x00}, 1, 0},
|
||||||
|
|
||||||
|
// {0X3A, (uint8_t[]){0x55}, 1, 0},
|
||||||
|
{0x11, (uint8_t[]){0x00}, 1, 120},
|
||||||
|
{0x29, (uint8_t[]){0x00}, 1, 50},
|
||||||
|
};
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_del(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
|
||||||
|
if (jd9165->reset_gpio_num >= 0) {
|
||||||
|
gpio_reset_pin(jd9165->reset_gpio_num);
|
||||||
|
}
|
||||||
|
// Delete MIPI DPI panel
|
||||||
|
jd9165->del(panel);
|
||||||
|
ESP_LOGD(TAG, "del jd9165 panel @%p", jd9165);
|
||||||
|
free(jd9165);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_init(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
const jd9165_lcd_init_cmd_t *init_cmds = NULL;
|
||||||
|
uint16_t init_cmds_size = 0;
|
||||||
|
bool is_cmd_overwritten = false;
|
||||||
|
|
||||||
|
uint8_t ID[3];
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_rx_param(io, 0x04, ID, 3), TAG, "read ID failed");
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) {
|
||||||
|
jd9165->madctl_val,
|
||||||
|
}, 1), TAG, "send command failed");
|
||||||
|
|
||||||
|
// vendor specific initialization, it can be different between manufacturers
|
||||||
|
// should consult the LCD supplier for initialization sequence code
|
||||||
|
if (jd9165->init_cmds) {
|
||||||
|
init_cmds = jd9165->init_cmds;
|
||||||
|
init_cmds_size = jd9165->init_cmds_size;
|
||||||
|
} else {
|
||||||
|
init_cmds = vendor_specific_init_default;
|
||||||
|
init_cmds_size = sizeof(vendor_specific_init_default) / sizeof(jd9165_lcd_init_cmd_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < init_cmds_size; i++) {
|
||||||
|
// Check if the command has been used or conflicts with the internal
|
||||||
|
if (init_cmds[i].data_bytes > 0) {
|
||||||
|
switch (init_cmds[i].cmd) {
|
||||||
|
case LCD_CMD_MADCTL:
|
||||||
|
is_cmd_overwritten = true;
|
||||||
|
jd9165->madctl_val = ((uint8_t *)init_cmds[i].data)[0];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
is_cmd_overwritten = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_cmd_overwritten) {
|
||||||
|
is_cmd_overwritten = false;
|
||||||
|
ESP_LOGW(TAG, "The %02Xh command has been used and will be overwritten by external initialization sequence",
|
||||||
|
init_cmds[i].cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send command
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, init_cmds[i].cmd, init_cmds[i].data, init_cmds[i].data_bytes), TAG, "send command failed");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(init_cmds[i].delay_ms));
|
||||||
|
}
|
||||||
|
ESP_LOGD(TAG, "send init commands success");
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(jd9165->init(panel), TAG, "init MIPI DPI panel failed");
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_reset(esp_lcd_panel_t *panel)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
|
||||||
|
// Perform hardware reset
|
||||||
|
if (jd9165->reset_gpio_num >= 0) {
|
||||||
|
gpio_set_level(jd9165->reset_gpio_num, !jd9165->flags.reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(5));
|
||||||
|
gpio_set_level(jd9165->reset_gpio_num, jd9165->flags.reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
gpio_set_level(jd9165->reset_gpio_num, !jd9165->flags.reset_level);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(120));
|
||||||
|
} else if (io) { // Perform software reset
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0), TAG, "send command failed");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(120));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_invert_color(esp_lcd_panel_t *panel, bool invert_color_data)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
uint8_t command = 0;
|
||||||
|
|
||||||
|
ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_STATE, TAG, "invalid panel IO");
|
||||||
|
|
||||||
|
if (invert_color_data) {
|
||||||
|
command = LCD_CMD_INVON;
|
||||||
|
} else {
|
||||||
|
command = LCD_CMD_INVOFF;
|
||||||
|
}
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
uint8_t madctl_val = jd9165->madctl_val;
|
||||||
|
|
||||||
|
ESP_RETURN_ON_FALSE(io, ESP_ERR_INVALID_STATE, TAG, "invalid panel IO");
|
||||||
|
|
||||||
|
// Control mirror through LCD command
|
||||||
|
if (mirror_x) {
|
||||||
|
madctl_val |= JD9165_CMD_GS_BIT;
|
||||||
|
} else {
|
||||||
|
madctl_val &= ~JD9165_CMD_GS_BIT;
|
||||||
|
}
|
||||||
|
if (mirror_y) {
|
||||||
|
madctl_val |= JD9165_CMD_SS_BIT;
|
||||||
|
} else {
|
||||||
|
madctl_val &= ~JD9165_CMD_SS_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t []) {
|
||||||
|
madctl_val
|
||||||
|
}, 1), TAG, "send command failed");
|
||||||
|
jd9165->madctl_val = madctl_val;
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t panel_jd9165_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
|
||||||
|
{
|
||||||
|
jd9165_panel_t *jd9165 = (jd9165_panel_t *)panel->user_data;
|
||||||
|
esp_lcd_panel_io_handle_t io = jd9165->io;
|
||||||
|
int command = 0;
|
||||||
|
|
||||||
|
if (on_off) {
|
||||||
|
command = LCD_CMD_DISPON;
|
||||||
|
} else {
|
||||||
|
command = LCD_CMD_DISPOFF;
|
||||||
|
}
|
||||||
|
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
|
#if SOC_MIPI_DSI_SUPPORTED
|
||||||
|
#include "esp_lcd_panel_vendor.h"
|
||||||
|
#include "esp_lcd_mipi_dsi.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LCD panel initialization commands.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int cmd; /*<! The specific LCD command */
|
||||||
|
const void *data; /*<! Buffer that holds the command specific data */
|
||||||
|
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
|
||||||
|
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
|
||||||
|
} jd9165_lcd_init_cmd_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LCD panel vendor configuration.
|
||||||
|
*
|
||||||
|
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
const jd9165_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
|
||||||
|
* The array should be declared as `static const` and positioned outside the function.
|
||||||
|
* Please refer to `vendor_specific_init_default` in source file.
|
||||||
|
*/
|
||||||
|
uint16_t init_cmds_size; /*<! Number of commands in above array */
|
||||||
|
struct {
|
||||||
|
esp_lcd_dsi_bus_handle_t dsi_bus; /*!< MIPI-DSI bus configuration */
|
||||||
|
const esp_lcd_dpi_panel_config_t *dpi_config; /*!< MIPI-DPI panel configuration */
|
||||||
|
} mipi_config;
|
||||||
|
} jd9165_vendor_config_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create LCD panel for model JD9165
|
||||||
|
*
|
||||||
|
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
|
||||||
|
*
|
||||||
|
* @param[in] io LCD panel IO handle
|
||||||
|
* @param[in] panel_dev_config General panel device configuration
|
||||||
|
* @param[out] ret_panel Returned LCD panel handle
|
||||||
|
* @return
|
||||||
|
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||||
|
* - ESP_OK on success
|
||||||
|
* - Otherwise on fail
|
||||||
|
*/
|
||||||
|
esp_err_t esp_lcd_new_panel_jd9165(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||||
|
esp_lcd_panel_handle_t *ret_panel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MIPI-DSI bus configuration structure
|
||||||
|
*
|
||||||
|
* @param[in] lane_num Number of data lanes
|
||||||
|
* @param[in] lane_mbps Lane bit rate in Mbps
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define JD9165_PANEL_BUS_DSI_2CH_CONFIG() \
|
||||||
|
{ \
|
||||||
|
.bus_id = 0, \
|
||||||
|
.num_data_lanes = 2, \
|
||||||
|
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, \
|
||||||
|
.lane_bit_rate_mbps = 550, \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MIPI-DBI panel IO configuration structure
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define JD9165_PANEL_IO_DBI_CONFIG() \
|
||||||
|
{ \
|
||||||
|
.virtual_channel = 0, \
|
||||||
|
.lcd_cmd_bits = 8, \
|
||||||
|
.lcd_param_bits = 8, \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MIPI DPI configuration structure
|
||||||
|
*
|
||||||
|
* @note refresh_rate = (dpi_clock_freq_mhz * 1000000) / (h_res + hsync_pulse_width + hsync_back_porch + hsync_front_porch)
|
||||||
|
* / (v_res + vsync_pulse_width + vsync_back_porch + vsync_front_porch)
|
||||||
|
*
|
||||||
|
* @param[in] px_format Pixel format of the panel
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define JD9165_1024_600_PANEL_60HZ_DPI_CONFIG(px_format) \
|
||||||
|
{ \
|
||||||
|
.virtual_channel = 0, \
|
||||||
|
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, \
|
||||||
|
.dpi_clock_freq_mhz = 56, \
|
||||||
|
.pixel_format = px_format, \
|
||||||
|
.num_fbs = 1, \
|
||||||
|
.video_timing = { \
|
||||||
|
.h_size = 1024, \
|
||||||
|
.v_size = 600, \
|
||||||
|
.hsync_pulse_width = 40, \
|
||||||
|
.hsync_back_porch = 160, \
|
||||||
|
.hsync_front_porch = 160, \
|
||||||
|
.vsync_pulse_width = 10, \
|
||||||
|
.vsync_back_porch = 23, \
|
||||||
|
.vsync_front_porch = 12, \
|
||||||
|
}, \
|
||||||
|
.flags= { \
|
||||||
|
.use_dma2d = true, \
|
||||||
|
}, \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#include "esp_lcd_panel_ops.h"
|
||||||
|
#include "esp_lcd_mipi_dsi.h"
|
||||||
|
#include "esp_lcd_panel_io.h"
|
||||||
|
#include "esp_ldo_regulator.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
#include "esp_lcd_jd9165.h"
|
||||||
|
#include "jd9165_lcd.h"
|
||||||
|
|
||||||
|
#define LCD_H_RES 1024
|
||||||
|
#define LCD_V_RES 600
|
||||||
|
|
||||||
|
#define MIPI_DPI_PX_FORMAT (LCD_COLOR_PIXEL_FORMAT_RGB565)
|
||||||
|
#define LCD_BIT_PER_PIXEL (16)
|
||||||
|
|
||||||
|
// “VDD_MIPI_DPHY”应供电 2.5V,可从内部 LDO 稳压器或外部 LDO 芯片获取电源
|
||||||
|
#define EXAMPLE_MIPI_DSI_PHY_PWR_LDO_CHAN 3 // LDO_VO3 连接至 VDD_MIPI_DPHY
|
||||||
|
#define EXAMPLE_MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV 2500
|
||||||
|
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
|
||||||
|
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||||
|
#define EXAMPLE_PIN_NUM_BK_LIGHT GPIO_NUM_23
|
||||||
|
|
||||||
|
static const char *TAG = "example";
|
||||||
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||||
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||||
|
|
||||||
|
jd9165_lcd::jd9165_lcd(int8_t lcd_rst)
|
||||||
|
{
|
||||||
|
_lcd_rst = lcd_rst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::example_bsp_enable_dsi_phy_power()
|
||||||
|
{
|
||||||
|
// 打开 MIPI DSI PHY 的电源,使其从“无电”状态进入“关机”状态
|
||||||
|
esp_ldo_channel_handle_t ldo_mipi_phy = NULL;
|
||||||
|
#ifdef EXAMPLE_MIPI_DSI_PHY_PWR_LDO_CHAN
|
||||||
|
esp_ldo_channel_config_t ldo_mipi_phy_config = {
|
||||||
|
.chan_id = EXAMPLE_MIPI_DSI_PHY_PWR_LDO_CHAN,
|
||||||
|
.voltage_mv = EXAMPLE_MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldo_mipi_phy));
|
||||||
|
ESP_LOGI(TAG, "MIPI DSI PHY Powered on");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::example_bsp_init_lcd_backlight()
|
||||||
|
{
|
||||||
|
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
|
||||||
|
gpio_config_t bk_gpio_config = {
|
||||||
|
.pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT,
|
||||||
|
.mode = GPIO_MODE_OUTPUT
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&bk_gpio_config));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::example_bsp_set_lcd_backlight(uint32_t level)
|
||||||
|
{
|
||||||
|
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
|
||||||
|
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, level);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::begin()
|
||||||
|
{
|
||||||
|
example_bsp_enable_dsi_phy_power();
|
||||||
|
example_bsp_init_lcd_backlight();
|
||||||
|
example_bsp_set_lcd_backlight(EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL);
|
||||||
|
|
||||||
|
// 首先创建 MIPI DSI 总线,它还将初始化 DSI PHY
|
||||||
|
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
|
||||||
|
esp_lcd_dsi_bus_config_t bus_config = JD9165_PANEL_BUS_DSI_2CH_CONFIG();
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Install MIPI DSI LCD control panel");
|
||||||
|
// 我们使用DBI接口发送LCD命令和参数
|
||||||
|
esp_lcd_dbi_io_config_t dbi_config = JD9165_PANEL_IO_DBI_CONFIG();
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io_handle));
|
||||||
|
|
||||||
|
// 创建JD9165控制面板
|
||||||
|
esp_lcd_dpi_panel_config_t dpi_config = JD9165_1024_600_PANEL_60HZ_DPI_CONFIG(MIPI_DPI_PX_FORMAT);
|
||||||
|
|
||||||
|
jd9165_vendor_config_t vendor_config = {
|
||||||
|
.mipi_config = {
|
||||||
|
.dsi_bus = mipi_dsi_bus,
|
||||||
|
.dpi_config = &dpi_config,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const esp_lcd_panel_dev_config_t panel_config = {
|
||||||
|
.reset_gpio_num = _lcd_rst,
|
||||||
|
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
|
||||||
|
.bits_per_pixel = LCD_BIT_PER_PIXEL,
|
||||||
|
.vendor_config = &vendor_config,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_new_panel_jd9165(io_handle, &panel_config, &panel_handle));
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
|
||||||
|
|
||||||
|
// 打开背光
|
||||||
|
example_bsp_set_lcd_backlight(EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::lcd_draw_bitmap(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint8_t *color_data)
|
||||||
|
{
|
||||||
|
esp_lcd_panel_draw_bitmap(panel_handle, x_start, y_start, x_end, y_end, color_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::draw16bitbergbbitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *color_data)
|
||||||
|
{
|
||||||
|
uint16_t x_start = x;
|
||||||
|
uint16_t y_start = y;
|
||||||
|
uint16_t x_end = w + x;
|
||||||
|
uint16_t y_end = h + y;
|
||||||
|
|
||||||
|
esp_lcd_panel_draw_bitmap(panel_handle, x_start, y_start, x_end, y_end, color_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::fillScreen(uint16_t color)
|
||||||
|
{
|
||||||
|
uint16_t *color_data = (uint16_t *)heap_caps_malloc(480 * 272 * 2, MALLOC_CAP_INTERNAL);
|
||||||
|
memset(color_data, color, 480 * 272 * 2);
|
||||||
|
draw16bitbergbbitmap(0, 0, 480, 272, color_data);
|
||||||
|
free(color_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::te_on()
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io_handle, 0x35,new (uint8_t[]){0x00}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jd9165_lcd::te_off()
|
||||||
|
{
|
||||||
|
esp_lcd_panel_io_tx_param(io_handle, 0x34,new (uint8_t[]){0x00}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t jd9165_lcd::width()
|
||||||
|
{
|
||||||
|
return LCD_H_RES;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t jd9165_lcd::height()
|
||||||
|
{
|
||||||
|
return LCD_V_RES;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef _JD9165_LCD_H
|
||||||
|
#define _JD9165_LCD_H
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class jd9165_lcd
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
jd9165_lcd(int8_t lcd_rst);
|
||||||
|
|
||||||
|
void begin();
|
||||||
|
void example_bsp_enable_dsi_phy_power();
|
||||||
|
void example_bsp_init_lcd_backlight();
|
||||||
|
void example_bsp_set_lcd_backlight(uint32_t level);
|
||||||
|
void lcd_draw_bitmap(uint16_t x_start, uint16_t y_start,
|
||||||
|
uint16_t x_end, uint16_t y_end, uint8_t *color_data);
|
||||||
|
void draw16bitbergbbitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *color_data);
|
||||||
|
void fillScreen(uint16_t color);
|
||||||
|
void te_on();
|
||||||
|
void te_off();
|
||||||
|
uint16_t width();
|
||||||
|
uint16_t height();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int8_t _lcd_rst;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_check.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
#include "esp_lcd_panel_io.h"
|
||||||
|
#include "esp_lcd_touch.h"
|
||||||
|
|
||||||
|
static const char *TAG = "GT911";
|
||||||
|
|
||||||
|
/* GT911 registers */
|
||||||
|
#define ESP_LCD_TOUCH_GT911_READ_XY_REG (0x814E)
|
||||||
|
#define ESP_LCD_TOUCH_GT911_CONFIG_REG (0x8047)
|
||||||
|
#define ESP_LCD_TOUCH_GT911_PRODUCT_ID_REG (0x8140)
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function definitions
|
||||||
|
*******************************************************************************/
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp);
|
||||||
|
static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num);
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp);
|
||||||
|
|
||||||
|
/* I2C read/write */
|
||||||
|
static esp_err_t touch_gt911_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len);
|
||||||
|
static esp_err_t touch_gt911_i2c_write(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t data);
|
||||||
|
|
||||||
|
/* GT911 reset */
|
||||||
|
static esp_err_t touch_gt911_reset(esp_lcd_touch_handle_t tp);
|
||||||
|
/* Read status and config register */
|
||||||
|
static esp_err_t touch_gt911_read_cfg(esp_lcd_touch_handle_t tp);
|
||||||
|
static void touch_scale(uint16_t *x_coordinate,uint16_t *y_coordinate);
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Public API functions
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *out_touch)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
assert(io != NULL);
|
||||||
|
assert(config != NULL);
|
||||||
|
assert(out_touch != NULL);
|
||||||
|
|
||||||
|
/* Prepare main structure */
|
||||||
|
esp_lcd_touch_handle_t esp_lcd_touch_gt911 = heap_caps_calloc(1, sizeof(esp_lcd_touch_t), MALLOC_CAP_DEFAULT);
|
||||||
|
ESP_GOTO_ON_FALSE(esp_lcd_touch_gt911, ESP_ERR_NO_MEM, err, TAG, "no mem for GT911 controller");
|
||||||
|
|
||||||
|
/* Communication interface */
|
||||||
|
esp_lcd_touch_gt911->io = io;
|
||||||
|
|
||||||
|
/* Only supported callbacks are set */
|
||||||
|
esp_lcd_touch_gt911->read_data = esp_lcd_touch_gt911_read_data;
|
||||||
|
esp_lcd_touch_gt911->get_xy = esp_lcd_touch_gt911_get_xy;
|
||||||
|
esp_lcd_touch_gt911->del = esp_lcd_touch_gt911_del;
|
||||||
|
|
||||||
|
/* Mutex */
|
||||||
|
esp_lcd_touch_gt911->data.lock.owner = portMUX_FREE_VAL;
|
||||||
|
|
||||||
|
/* Save config */
|
||||||
|
memcpy(&esp_lcd_touch_gt911->config, config, sizeof(esp_lcd_touch_config_t));
|
||||||
|
|
||||||
|
/* Prepare pin for touch interrupt */
|
||||||
|
if (esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) {
|
||||||
|
const gpio_config_t int_gpio_config = {
|
||||||
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
.intr_type = GPIO_INTR_NEGEDGE,
|
||||||
|
.pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.int_gpio_num)
|
||||||
|
};
|
||||||
|
ret = gpio_config(&int_gpio_config);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed");
|
||||||
|
|
||||||
|
/* Register interrupt callback */
|
||||||
|
if (esp_lcd_touch_gt911->config.interrupt_callback) {
|
||||||
|
esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_gt911, esp_lcd_touch_gt911->config.interrupt_callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prepare pin for touch controller reset */
|
||||||
|
if (esp_lcd_touch_gt911->config.rst_gpio_num != GPIO_NUM_NC) {
|
||||||
|
const gpio_config_t rst_gpio_config = {
|
||||||
|
.mode = GPIO_MODE_OUTPUT,
|
||||||
|
.pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.rst_gpio_num)
|
||||||
|
};
|
||||||
|
ret = gpio_config(&rst_gpio_config);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset controller */
|
||||||
|
ret = touch_gt911_reset(esp_lcd_touch_gt911);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 reset failed");
|
||||||
|
|
||||||
|
/* Read status and config info */
|
||||||
|
ret = touch_gt911_read_cfg(esp_lcd_touch_gt911);
|
||||||
|
ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 init failed");
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Error (0x%x)! Touch controller GT911 initialization failed!", ret);
|
||||||
|
if (esp_lcd_touch_gt911) {
|
||||||
|
esp_lcd_touch_gt911_del(esp_lcd_touch_gt911);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_touch = esp_lcd_touch_gt911;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
esp_err_t err;
|
||||||
|
uint8_t buf[41];
|
||||||
|
uint8_t touch_cnt = 0;
|
||||||
|
uint8_t clear = 0;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
err = touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, buf, 1);
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||||
|
|
||||||
|
/* Any touch data? */
|
||||||
|
if ((buf[0] & 0x80) == 0x00) {
|
||||||
|
touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
|
||||||
|
} else {
|
||||||
|
/* Count of touched points */
|
||||||
|
touch_cnt = buf[0] & 0x0f;
|
||||||
|
if (touch_cnt > 5 || touch_cnt == 0) {
|
||||||
|
touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read all points */
|
||||||
|
err = touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG + 1, &buf[1], touch_cnt * 8);
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||||
|
|
||||||
|
/* Clear all */
|
||||||
|
err = touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||||
|
|
||||||
|
portENTER_CRITICAL(&tp->data.lock);
|
||||||
|
|
||||||
|
/* Number of touched points */
|
||||||
|
touch_cnt = (touch_cnt > CONFIG_ESP_LCD_TOUCH_MAX_POINTS ? CONFIG_ESP_LCD_TOUCH_MAX_POINTS : touch_cnt);
|
||||||
|
tp->data.points = touch_cnt;
|
||||||
|
|
||||||
|
/* Fill all coordinates */
|
||||||
|
for (i = 0; i < touch_cnt; i++) {
|
||||||
|
tp->data.coords[i].x = ((uint16_t)buf[(i * 8) + 3] << 8) + buf[(i * 8) + 2];
|
||||||
|
tp->data.coords[i].y = (((uint16_t)buf[(i * 8) + 5] << 8) + buf[(i * 8) + 4]);
|
||||||
|
tp->data.coords[i].strength = (((uint16_t)buf[(i * 8) + 7] << 8) + buf[(i * 8) + 6]);
|
||||||
|
}
|
||||||
|
|
||||||
|
portEXIT_CRITICAL(&tp->data.lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
assert(x != NULL);
|
||||||
|
assert(y != NULL);
|
||||||
|
assert(point_num != NULL);
|
||||||
|
assert(max_point_num > 0);
|
||||||
|
|
||||||
|
portENTER_CRITICAL(&tp->data.lock);
|
||||||
|
|
||||||
|
/* Count of points */
|
||||||
|
*point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < *point_num; i++) {
|
||||||
|
x[i] = tp->data.coords[i].x;
|
||||||
|
y[i] = tp->data.coords[i].y;
|
||||||
|
touch_scale(&x[i],&y[i]);
|
||||||
|
if (strength) {
|
||||||
|
strength[i] = tp->data.coords[i].strength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invalidate */
|
||||||
|
tp->data.points = 0;
|
||||||
|
|
||||||
|
portEXIT_CRITICAL(&tp->data.lock);
|
||||||
|
|
||||||
|
return (*point_num > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
/* Reset GPIO pin settings */
|
||||||
|
if (tp->config.int_gpio_num != GPIO_NUM_NC) {
|
||||||
|
gpio_reset_pin(tp->config.int_gpio_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset GPIO pin settings */
|
||||||
|
if (tp->config.rst_gpio_num != GPIO_NUM_NC) {
|
||||||
|
gpio_reset_pin(tp->config.rst_gpio_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(tp);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Private API function
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* Reset controller */
|
||||||
|
static esp_err_t touch_gt911_reset(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
if (tp->config.rst_gpio_num != GPIO_NUM_NC) {
|
||||||
|
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level error!");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, !tp->config.levels.reset), TAG, "GPIO set level error!");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t touch_gt911_read_cfg(esp_lcd_touch_handle_t tp)
|
||||||
|
{
|
||||||
|
uint8_t buf[4];
|
||||||
|
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_PRODUCT_ID_REG, (uint8_t *)&buf[0], 3), TAG, "GT911 read error!");
|
||||||
|
ESP_RETURN_ON_ERROR(touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_CONFIG_REG, (uint8_t *)&buf[3], 1), TAG, "GT911 read error!");
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "TouchPad_ID:0x%02x,0x%02x,0x%02x", buf[0], buf[1], buf[2]);
|
||||||
|
ESP_LOGI(TAG, "TouchPad_Config_Version:%d", buf[3]);
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t touch_gt911_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
|
/* Read data */
|
||||||
|
return esp_lcd_panel_io_rx_param(tp->io, reg, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t touch_gt911_i2c_write(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t data)
|
||||||
|
{
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
// *INDENT-OFF*
|
||||||
|
/* Write data */
|
||||||
|
return esp_lcd_panel_io_tx_param(tp->io, reg, (uint8_t[]){data}, 1);
|
||||||
|
// *INDENT-ON*
|
||||||
|
}
|
||||||
|
|
||||||
|
static void touch_scale(uint16_t *x_coordinate,uint16_t *y_coordinate)
|
||||||
|
{
|
||||||
|
uint32_t temp_x;
|
||||||
|
uint32_t temp_y;
|
||||||
|
|
||||||
|
temp_x = (*x_coordinate) * 1024 *10 / 800 / 10;
|
||||||
|
temp_y = (*y_coordinate) * 600 * 10 / 480 / 10;
|
||||||
|
|
||||||
|
*x_coordinate = (uint16_t)temp_x;
|
||||||
|
*y_coordinate = (uint16_t)temp_y;
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "driver/i2c.h"
|
||||||
|
#include "esp_lcd_touch_gt911.h"
|
||||||
|
#include "gt911_touch.h"
|
||||||
|
|
||||||
|
#define CONFIG_LCD_HRES 600
|
||||||
|
#define CONFIG_LCD_VRES 1024
|
||||||
|
|
||||||
|
static const char *TAG = "example";
|
||||||
|
|
||||||
|
esp_lcd_touch_handle_t tp;
|
||||||
|
esp_lcd_panel_io_handle_t tp_io_handle;
|
||||||
|
|
||||||
|
uint16_t touch_strength[1];
|
||||||
|
uint8_t touch_cnt = 0;
|
||||||
|
|
||||||
|
gt911_touch::gt911_touch(int8_t sda_pin, int8_t scl_pin, int8_t rst_pin, int8_t int_pin)
|
||||||
|
{
|
||||||
|
_sda = sda_pin;
|
||||||
|
_scl = scl_pin;
|
||||||
|
_rst = rst_pin;
|
||||||
|
_int = int_pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gt911_touch::begin()
|
||||||
|
{
|
||||||
|
i2c_config_t i2c_conf = {
|
||||||
|
.mode = I2C_MODE_MASTER,
|
||||||
|
.sda_io_num = (gpio_num_t)_sda,
|
||||||
|
.scl_io_num = (gpio_num_t)_scl,
|
||||||
|
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
};
|
||||||
|
i2c_conf.master.clk_speed = 400000; // 400kHz
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &i2c_conf));
|
||||||
|
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, i2c_conf.mode, 0, 0, 0));
|
||||||
|
|
||||||
|
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
|
||||||
|
ESP_LOGI(TAG, "Initialize touch IO (I2C)");
|
||||||
|
esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)I2C_NUM_0, &tp_io_config, &tp_io_handle);
|
||||||
|
|
||||||
|
esp_lcd_touch_config_t tp_cfg = {
|
||||||
|
.x_max = CONFIG_LCD_HRES,
|
||||||
|
.y_max = CONFIG_LCD_VRES,
|
||||||
|
.rst_gpio_num = (gpio_num_t)_rst,
|
||||||
|
.int_gpio_num = (gpio_num_t)_int,
|
||||||
|
.levels = {
|
||||||
|
.reset = 0,
|
||||||
|
.interrupt = 0,
|
||||||
|
},
|
||||||
|
.flags = {
|
||||||
|
.swap_xy = 0,
|
||||||
|
.mirror_x = 0,
|
||||||
|
.mirror_y = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Initialize touch controller gt911");
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gt911_touch::getTouch(uint16_t *x, uint16_t *y)
|
||||||
|
{
|
||||||
|
esp_lcd_touch_read_data(tp);
|
||||||
|
bool touchpad_pressed = esp_lcd_touch_get_coordinates(tp, x, y, touch_strength, &touch_cnt, 1);
|
||||||
|
|
||||||
|
return touchpad_pressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gt911_touch::set_rotation(uint8_t r){
|
||||||
|
switch(r){
|
||||||
|
case 0:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, true);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, false);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
esp_lcd_touch_set_swap_xy(tp, false);
|
||||||
|
esp_lcd_touch_set_mirror_x(tp, true);
|
||||||
|
esp_lcd_touch_set_mirror_y(tp, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 290 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 132 KiB |
@@ -0,0 +1,78 @@
|
|||||||
|
JDEVB_RSOX(1024);
|
||||||
|
JDEVB_RSOY(600);
|
||||||
|
JDEVB_VS(2);
|
||||||
|
JDEVB_VBP(21);
|
||||||
|
JDEVB_VFP(12); //12->18(HKC),CKV_OFF(41->4B)_20230228
|
||||||
|
JDEVB_HS(24);
|
||||||
|
JDEVB_HBP(136);
|
||||||
|
JDEVB_HFP(160);
|
||||||
|
JDEVB_DOTCLK(51.2);
|
||||||
|
|
||||||
|
//------------------------------------------------//
|
||||||
|
//VCC=1.8V/3.3V, AVDD=11V, VGH=20V, VGL=-7, VCOM=3.6(~3.8)V
|
||||||
|
//1+2Dot inversion
|
||||||
|
//------------------------------------------------//
|
||||||
|
|
||||||
|
|
||||||
|
{0x30, 1,{0x00}},
|
||||||
|
{0xF7, 4,{0x49,0x61,0x02,0x00}},
|
||||||
|
{0x30, 1,{0x01}},
|
||||||
|
{0x04, 1,{0x0C}},
|
||||||
|
{0x05, 1,{0x00}}, //05=06(xhs)
|
||||||
|
{0x06, 1,{0x00}}, //06=80(xhs)
|
||||||
|
{0x0B, 1,{0x11}}, //0x13=4lanes,0x12=3lanes,0x11=2lanes,0x10=1 lanes
|
||||||
|
{0x17, 1,{0x00}},
|
||||||
|
{0x20, 1,{0x04}}, //add //r_lansel_sel_reg=1, software charge lane must open
|
||||||
|
{0x1F, 1,{0x05}}, //add hs_settle time
|
||||||
|
{0x23, 1,{0x00}}, //add //close gas
|
||||||
|
{0x25, 1,{0x19}},
|
||||||
|
{0x28, 1,{0x18}},
|
||||||
|
{0x29, 1,{0x04}}, //revcom
|
||||||
|
{0x2A, 1,{0x01}}, //revcom
|
||||||
|
{0x2B, 1,{0x04}}, //vcom
|
||||||
|
{0x2C, 1,{0x01}}, //vcom
|
||||||
|
{0x30, 1,{0x02}},
|
||||||
|
{0x01, 1,{0x22}},
|
||||||
|
{0x03, 1,{0x12}},
|
||||||
|
{0x04, 1,{0x00}},
|
||||||
|
{0x05, 1,{0x64}},
|
||||||
|
{0x0A, 1,{0x08}},
|
||||||
|
{0x0B, 11,{0x0A,0x1A,0x0B,0x0D,0x0D,0x11,0x10,0x06,0x08,0x1F,0x1D}},
|
||||||
|
{0x0C, 11,{0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}},
|
||||||
|
{0x0D, 11,{0x16,0x1B,0x0B,0x0D,0x0D,0x11,0x10,0x07,0x09,0x1E,0x1C}},
|
||||||
|
{0x0E, 11,{0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}},
|
||||||
|
{0x0F, 11,{0x16,0x1B,0x0D,0x0B,0x0D,0x11,0x10,0x1C,0x1E,0x09,0x07}},
|
||||||
|
{0x10, 11,{0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}},
|
||||||
|
{0x11, 11,{0x0A,0x1A,0x0D,0x0B,0x0D,0x11,0x10,0x1D,0x1F,0x08,0x06}},
|
||||||
|
{0x12, 11,{0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D}},
|
||||||
|
{0x14, 4,{0x00,0x00,0x11,0x11}}, //CKV_OFF
|
||||||
|
{0x18, 1,{0x99}},
|
||||||
|
{0x30, 1,{0x06}},
|
||||||
|
{0x12, 14,{0x36,0x2C,0x2E,0x3C,0x38,0x35,0x35,0x32,0x2E,0x1D,0x2B,0x21,0x16,0x29}},
|
||||||
|
{0x13, 14,{0x36,0x2C,0x2E,0x3C,0x38,0x35,0x35,0x32,0x2E,0x1D,0x2B,0x21,0x16,0x29}},
|
||||||
|
//{0x30, 1,{0x08}}, //RGB&LVDS add
|
||||||
|
//{0x05, 1,{0x01}}, //RGB&LVDS add
|
||||||
|
//{0x0C, 1,{0x1A}}, //RGB&LVDS add
|
||||||
|
//{0x0D, 1,{0x0E}}, //RGB&LVDS add
|
||||||
|
|
||||||
|
//{0x30, 1,{0x07}},
|
||||||
|
//{0x01, 1,{0x04}}, //P7_r01=0x04(0x06)_r_hster_delay
|
||||||
|
|
||||||
|
{0x30, 1,{0x0A}},
|
||||||
|
{0x02, 1,{0x4F}},
|
||||||
|
{0x0B, 1,{0x40}},
|
||||||
|
{0x12, 1,{0x3E}},
|
||||||
|
{0x13, 1,{0x78}},
|
||||||
|
{0x30, 1,{0x0D}},
|
||||||
|
{0x0D, 1,{0x04}}, //0x0C, 0x04
|
||||||
|
{0x10, 1,{0x0C}},
|
||||||
|
{0x11, 1,{0x0C}},
|
||||||
|
{0x12, 1,{0x0C}},
|
||||||
|
{0x13, 1,{0x0C}},
|
||||||
|
{0x30, 1,{0x00}},
|
||||||
|
{0x11,0,{}},
|
||||||
|
{REGFLAG_DELAY, 120, {}},
|
||||||
|
{0x29,0,{}},
|
||||||
|
{REGFLAG_DELAY, 20, {}},
|
||||||
|
{REGFLAG_END_OF_TABLE, 0x00, {}}
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 151 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
1、电脑需要安装CH340驱动程序:The computer needs to install the CH340 driver program
|
||||||
|
2、保证供电充足,开发板电流600ma以上:Ensure sufficient power supply, with a development board current of over 600mA
|
||||||
|
3、烧录选择USB1口:Choose USB1 port for burning
|
||||||
@@ -1,3 +1,166 @@
|
|||||||
|
Version 1.6.10:
|
||||||
|
- WS7_PARTIAL_REFRESH ist jetzt auch im Auslieferungsstand 1. Am Gerät geprüft: kein
|
||||||
|
Flackern, und der Gewinn ist der größte der drei Tempo-Maßnahmen - vor allem während
|
||||||
|
eines Bezugs, wo die Zeitanzeige zehnmal je Sekunde weiterläuft.
|
||||||
|
- Der Hintergrund der Seiten ist deckend statt durchsichtig. Sichtbar ändert sich nichts,
|
||||||
|
die Ebenen darunter haben dieselbe Farbe; LVGL muss sie beim Scrollen aber nicht mehr
|
||||||
|
mitzeichnen und durchmischen.
|
||||||
|
- Neuer Schalter WS7_PERF_MONITOR in pins_config.h: blendet unten rechts Bilder je Sekunde
|
||||||
|
und Prozessorlast ein. Damit lässt sich beantworten, ob weitere Mühe beim Zeichnen
|
||||||
|
überhaupt noch etwas bringt, statt ins Blaue zu optimieren.
|
||||||
|
|
||||||
|
Version 1.6.9:
|
||||||
|
- Fehlerbehebung: Ein Tipp auf einen Knopf löste oft mehrfach aus. Der GT9271 lässt
|
||||||
|
gelegentlich einen Messzyklus aus oder liefert ein unplausibles Paket; der
|
||||||
|
Hersteller-Treiber kann "gerade nichts Neues" nicht von "Finger weg" unterscheiden und
|
||||||
|
meldet beides als losgelassen. Seit die Oberfläche mit 1.6.8 doppelt so oft abtastet,
|
||||||
|
wurde daraus sichtbar Drücken-Loslassen-Drücken-Loslassen.
|
||||||
|
- Vor den Treiber ist deshalb ein Filter gesetzt: Er verwirft unplausible Rohwerte und hält
|
||||||
|
den letzten gültigen Berührpunkt noch WS7_TOUCH_HOLD_MS lang (Vorgabe 40 ms). Losgelassen
|
||||||
|
wird erst gemeldet, wenn wirklich nichts mehr kommt. Der Wert steht in pins_config.h;
|
||||||
|
0 schaltet die Überbrückung ab. Zu groß gewählt verzögert er das Loslassen und dämpft
|
||||||
|
den Schwung beim Wischen.
|
||||||
|
- Der Filter hängt sich zur Laufzeit in den Treiber ein, die Herstellerdateien bleiben
|
||||||
|
unverändert.
|
||||||
|
|
||||||
|
Version 1.6.8:
|
||||||
|
- Scrollen und Wischen laufen am Waveshare-Panel flüssiger: LVGL rechnet dort jetzt im
|
||||||
|
16-Millisekunden-Takt statt alle 33 ms. Dieser Wert steuert nicht nur die Bildrate,
|
||||||
|
sondern auch, wie oft der Touch abgetastet und wie fein eine Animation gerechnet wird -
|
||||||
|
mit 30 Schritten je Sekunde war vor allem das Ziehen mit dem Finger sichtbar ruckelig.
|
||||||
|
Das Panel läuft mit 60 Hz, mehr als 16 ms bringt also nichts.
|
||||||
|
- Kommt das Zeichnen einmal nicht hinterher, wird ein Bild später fertig; kaputt geht
|
||||||
|
dabei nichts. Die JC-Panels bleiben bei 33 ms.
|
||||||
|
|
||||||
|
Version 1.6.7:
|
||||||
|
- Der Menue-Knopf oben links fängt Tipps jetzt auch knapp daneben ab. Mit 48x36 Pixeln war
|
||||||
|
er auf dem 7-Zoll-Panel ein sehr kleines Ziel; gemessen wurde ein Fehlgriff von rund
|
||||||
|
10 Pixeln neben der Fläche, weshalb sich das Menü scheinbar nicht öffnen ließ. Optisch
|
||||||
|
bleibt der Knopf unverändert, die Trefferfläche wächst um 20 Pixel nach allen Seiten.
|
||||||
|
Sie wirkt nur innerhalb der Kopfleiste - dem Seiteninhalt darunter wird nichts genommen.
|
||||||
|
- Die Touch-Zuordnung selbst war korrekt: Eine Messung mit WS7_TOUCH_DEBUG hat gezeigt,
|
||||||
|
dass Achsen und Spiegelung stimmen.
|
||||||
|
|
||||||
|
Version 1.6.6:
|
||||||
|
- Neuer Schalter WS7_TOUCH_DEBUG in pins_config.h: Auf 1 gesetzt, gibt jeder Berührpunkt
|
||||||
|
seine Rohwerte und die daraus errechnete Bildposition auf der seriellen Konsole aus.
|
||||||
|
Gedacht zum Einmessen des Touch, wenn Bedienelemente nicht reagieren - insbesondere am
|
||||||
|
oberen Bildrand, wo die 44 Pixel hohe Kopfleiste sitzt.
|
||||||
|
|
||||||
|
Version 1.6.5:
|
||||||
|
- Zwei der drei Tempo-Maßnahmen aus 1.6.4 haben sich am Gerät als untauglich erwiesen und
|
||||||
|
stehen wieder auf ihrem alten Wert. Sie bleiben als Schalter erhalten, mit Notiz, woran
|
||||||
|
sie gescheitert sind.
|
||||||
|
* WS7_COLOR_BITS wieder 24: Die Bridge dieses Panels nimmt kein RGB565 an, mit 16 Bit
|
||||||
|
kommt kein brauchbares Bild.
|
||||||
|
* WS7_PARTIAL_REFRESH wieder 0: Der Menü-Vorhang ließ sich nicht mehr öffnen. Er ist
|
||||||
|
halbtransparent und wird deshalb in den gerade aktiven Bildpuffer eingemischt; die
|
||||||
|
nächste Zustandsmeldung der S3 zeichnet aber in den zweiten Puffer, der ihn nie
|
||||||
|
bekommen hat - der Vorhang war also sofort wieder weg. Nutzbar wäre der Modus erst,
|
||||||
|
wenn der LVGL-Port die geänderten Bereiche zwischen beiden Puffern abgleicht.
|
||||||
|
- WS7_PARALLEL_RENDER bleibt eingeschaltet: LVGL zeichnet weiterhin mit zwei Threads auf
|
||||||
|
beiden Prozessorkernen. Von den drei Maßnahmen trägt nur diese.
|
||||||
|
|
||||||
|
Version 1.6.4:
|
||||||
|
- Waveshare 7" (H): Drei Maßnahmen gegen die träge Bedienung am großen Panel. 1280x720
|
||||||
|
sind 2,4-mal so viele Pixel wie beim 4,3-Zöller, und bis 1.6.3 wurde bei jeder Änderung
|
||||||
|
das komplette Bild in 24 Bit neu gezeichnet.
|
||||||
|
* Farbtiefe RGB565 statt RGB888 (WS7_COLOR_BITS): halbiert die Datenmenge je Bild.
|
||||||
|
Feinere Farbabstufungen entfallen, sichtbar allenfalls in den dunklen Verläufen der
|
||||||
|
Rundanzeige - die JC-Panels laufen seit jeher so.
|
||||||
|
* Nur geänderte Bildbereiche neu zeichnen statt des ganzen Bildes
|
||||||
|
(WS7_PARTIAL_REFRESH, LVGL-Direct-Mode mit zwei Puffern). Eine sich ändernde
|
||||||
|
Temperaturanzeige kostet damit ein paar tausend statt 921.600 Pixel.
|
||||||
|
* LVGL zeichnet mit zwei Threads auf beiden Prozessorkernen (WS7_PARALLEL_RENDER).
|
||||||
|
- Jeder der drei Schalter steht in pins_config.h und lässt sich einzeln zurückstellen;
|
||||||
|
die README nennt zu jedem, woran man erkennt, dass er zurück muss. Die JC-Panels sind
|
||||||
|
von allen dreien nicht betroffen.
|
||||||
|
- Nebeneffekt: Der Framebuffer-Bedarf sinkt von rund 8,3 MB auf 3,7 MB PSRAM.
|
||||||
|
|
||||||
|
Version 1.6.3:
|
||||||
|
- Waveshare ESP32-P4-Pico: UART zur Hauptplatine liegt jetzt auf TX = GPIO20 und
|
||||||
|
RX = GPIO21 (vorher GPIO17/GPIO18). Die JC-Panels bleiben bei GPIO33/GPIO31.
|
||||||
|
- Das Bild steht in der tatsächlichen Einbaulage richtig herum, die 180-Grad-Drehung aus
|
||||||
|
1.6.1 ist deshalb wieder abgeschaltet (WS7_ROTATE_180 = 0). Sie bleibt als Schalter
|
||||||
|
erhalten, falls das Panel später anders montiert wird.
|
||||||
|
- Der Touch war dagegen oben/unten spiegelverkehrt: Der Digitizer sitzt gegenüber dem Bild
|
||||||
|
um die Hochachse gedreht. WS7_TOUCH_MIRROR_RAW_X steht dafür jetzt auf 1. Bild- und
|
||||||
|
Touch-Ausrichtung sind damit zwei getrennte Schalter, weil sie an diesem Panel eben
|
||||||
|
nicht zusammenfallen.
|
||||||
|
|
||||||
|
Version 1.6.2:
|
||||||
|
- Kommt das Panel nicht hoch, stürzt der P4 nicht mehr wortlos ab. Die Bringup-Schritte
|
||||||
|
melden ihren Fehler jetzt im Klartext auf der seriellen Konsole (auch bei abgeschaltetem
|
||||||
|
Core-Debug-Level), zusammen mit PSRAM-Größe, freiem PSRAM und dem tatsächlich benötigten
|
||||||
|
Framebuffer-Bedarf. Vorher endete ein fehlgeschlagener Panel-Aufbau in einem
|
||||||
|
Speicherauszug, aus dem die Ursache nicht hervorging.
|
||||||
|
- Schlägt der Panel-Aufbau fehl, läuft die Firmware ohne Anzeige weiter, statt ein zweites
|
||||||
|
Mal abzustürzen: UART-Verbindung und OTA bleiben offen, die S3 kann also neu flashen.
|
||||||
|
Alle Oberflächenfunktionen prüfen dafür, ob das Dashboard überhaupt aufgebaut wurde.
|
||||||
|
- Fehlerbehebung: Findet der Touch-Controller nicht statt, lieferte der Hersteller-Treiber
|
||||||
|
einen bereits freigegebenen Zeiger zurück, der ungeprüft weiterverwendet wurde. Das
|
||||||
|
Display läuft in diesem Fall jetzt einfach ohne Bedienung weiter.
|
||||||
|
|
||||||
|
Version 1.6.1:
|
||||||
|
- Waveshare 7" (H): Bild und Touch lassen sich um 180 Grad drehen, wenn das Panel auf dem
|
||||||
|
Kopf eingebaut ist. Schalter WS7_ROTATE_180 in pins_config.h, Vorgabe ist gedreht.
|
||||||
|
Die Drehung übernimmt der PPA-Grafikbeschleuniger des ESP32-P4 - die Software-Rotation
|
||||||
|
des LVGL-Ports rechnet nur in RGB565 und wäre für dieses Panel unbrauchbar.
|
||||||
|
- Der Touch dreht mit, sonst läge die Bedienung spiegelbildlich zum Bild.
|
||||||
|
|
||||||
|
Version 1.6.0:
|
||||||
|
- Neu: Dieselbe Firmware läuft jetzt auch auf einem Waveshare ESP32-P4-Pico mit dem
|
||||||
|
Waveshare 7inch DSI LCD (H) (1280x720). Umgeschaltet wird über „JC_PANEL_TYPE" in
|
||||||
|
config.h; WS_PANEL_7H ist ab dieser Version die Vorgabe, JC_PANEL_43 und JC_PANEL_70
|
||||||
|
bleiben unverändert verfügbar.
|
||||||
|
- Das Waveshare-Panel hängt hinter einer Bridge, die ausschließlich RGB888 annimmt. LVGL
|
||||||
|
rechnet für dieses Panel deshalb mit 24 statt 16 Bit Farbtiefe. lv_conf.h liest dazu
|
||||||
|
JC_PANEL_TYPE aus config.h, damit Sketch und LVGL-Bibliothek garantiert dieselbe
|
||||||
|
Farbtiefe benutzen; display_hal.cpp bricht den Build ab, falls sie auseinanderlaufen.
|
||||||
|
Der Panelwechsel muss aus diesem Grund in config.h erfolgen und nicht per Compiler-Flag.
|
||||||
|
- Bringup ohne Hersteller-Panel-Treiber: DSI-Bus, Kommandokanal und DPI-Panel werden direkt
|
||||||
|
angelegt. Entscheidend ist die Legacy-Referenztaktquelle PLL_F20M - mit der Standardquelle
|
||||||
|
bleibt der Bildschirm auf ESP32-P4 Rev. 1.3 / ECO2 schwarz. Die Zeitbasis (2 Lanes zu
|
||||||
|
1250 Mbit/s, 80 MHz DPI-Takt, Austastlücken 64/64/64, rund 60 Hz) steht als WS7_*-Werte
|
||||||
|
in pins_config.h und ist dort anpassbar, falls das Bild reißt.
|
||||||
|
- Panel-Freigabe und Helligkeit laufen beim Waveshare nicht über einen PWM-Pin, sondern über
|
||||||
|
Register der Bridge auf I2C-Adresse 0x45. Die Hintergrundbeleuchtung wird bewusst erst
|
||||||
|
eingeschaltet, wenn die DSI-Ausgabe steht - sonst blitzt beim Start Bildrauschen auf.
|
||||||
|
Standby-Abdunklung und „Uhrzeit im Standby" funktionieren wie bei den JC-Panels.
|
||||||
|
- Touch: Der GT9271 des Waveshare-Panels benutzt dieselbe Registerbelegung wie der GT911,
|
||||||
|
liegt aber auf I2C-Adresse 0x14 und meldet im Hochformat. X und Y werden deshalb getauscht
|
||||||
|
und auf die Bildfläche begrenzt; Ausreißer des Controllers landen nicht mehr als Klick am
|
||||||
|
Bildrand. Sollte die Bedienung spiegelverkehrt reagieren, lässt sich das mit
|
||||||
|
WS7_TOUCH_MIRROR_RAW_X / _Y in pins_config.h umdrehen.
|
||||||
|
- Der Framebuffer wächst auf 3 x 2,8 MB (rund 8,3 MB PSRAM). Auf dem P4-Pico mit 32 MB
|
||||||
|
PSRAM ist das unkritisch.
|
||||||
|
- Die UART-Pins zur Hauptplatine sind für das Waveshare-Board getrennt eingestellt, weil
|
||||||
|
dessen 40-poliger Header eine andere Belegung hat als die JC-Panels: TX = GPIO17,
|
||||||
|
RX = GPIO18 (JC-Panels unverändert TX = GPIO33, RX = GPIO31).
|
||||||
|
|
||||||
|
Version 1.5.0:
|
||||||
|
- Neu: Dieselbe Firmware unterstützt jetzt auch das 7-Zoll-Display Guition JC1060P470C-I-W
|
||||||
|
(JD9165, 1024x600) zusätzlich zum bisherigen 4,3-Zöller JC4880P443C-I-W (ST7701, 480x800).
|
||||||
|
Umgeschaltet wird über „JC_PANEL_TYPE" in config.h (JC_PANEL_43 / JC_PANEL_70) oder per
|
||||||
|
Compiler-Flag -DJC_PANEL_TYPE=70. Vorgabe bleibt das 4,3-Zoll-Panel, dessen Verhalten sich
|
||||||
|
nicht ändert.
|
||||||
|
- Panel-Treiber esp_lcd_jd9165.c/.h aus dem Hersteller-Paket übernommen; board_bringup.c legt
|
||||||
|
je nach Panel den passenden DSI-Bus, die DPI-Zeitbasis und den Herstellertreiber an.
|
||||||
|
- pins_config.h liefert Auflösung, LCD-Reset-Pin (4,3": GPIO5, 7,0": GPIO27) und Ausrichtung
|
||||||
|
panelabhängig. Das 7-Zoll-Panel ist nativ Querformat, deshalb entfällt dort die 270-Grad-
|
||||||
|
Rotation samt PPA-Beschleunigung.
|
||||||
|
- Der GT911 des 7-Zöllers meldet Rohkoordinaten im Raster 800x480 statt 1024x600. Die
|
||||||
|
Umrechnung hängt am process_coordinates-Hook von esp_lcd_touch, damit die Herstellerdatei
|
||||||
|
esp_lcd_touch_gt911.c unverändert bleibt. Ohne sie wäre nur der linke obere Bildteil
|
||||||
|
bedienbar.
|
||||||
|
- Die Oberfläche rechnet nicht mehr mit fest verdrahteten 480 Pixeln Höhe, sondern mit
|
||||||
|
DISP_VER_RES. Layout und Schriften bleiben sonst unverändert: Das Dashboard arbeitet fast
|
||||||
|
durchgehend mit Prozentmaßen, und die feineren Pixelabstände des 7-Zöllers (170 statt 213 dpi)
|
||||||
|
lassen dieselben Schriftgrößen physisch größer erscheinen.
|
||||||
|
- Die UART-Verkabelung ist bei beiden Panels gleich (P4 GPIO33 = TX, GPIO31 = RX). Beim
|
||||||
|
7-Zöller liegen diese Pins allerdings auf der FPC-Buchse FPC4 (1,0 mm, 16-polig) statt auf
|
||||||
|
einer Stiftleiste - dort wird ein Adapterkabel gebraucht.
|
||||||
|
|
||||||
Version 1.4.2:
|
Version 1.4.2:
|
||||||
- Bug-Fix: Beim Aufwecken über Antippen erschien die Auswahl „Espresso oder Cold Extraction"
|
- Bug-Fix: Beim Aufwecken über Antippen erschien die Auswahl „Espresso oder Cold Extraction"
|
||||||
manchmal nicht. Der Dialog entschied nach einer anderen Bedingung, ob er die Auswahl ANZEIGT
|
manchmal nicht. Der Dialog entschied nach einer anderen Bedingung, ob er die Auswahl ANZEIGT
|
||||||
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |