feat(P4): 7-Zoll-Display JC1060P470C-I-W unterstützen (1.5.0)
Dieselbe Display-Firmware bedient jetzt wahlweise das bisherige 4,3-Zoll-Panel JC4880P443C-I-W (ST7701, 480x800) oder das neue 7-Zoll-Panel JC1060P470C-I-W (JD9165, 1024x600). 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 ändert sich nicht. - src/lcd/esp_lcd_jd9165.c/.h aus dem Hersteller-Paket übernommen; board_bringup.c legt je nach Panel DSI-Bus, DPI-Zeitbasis und Herstellertreiber an. - pins_config.h liefert Auflösung, LCD-Reset (4,3": GPIO5, 7,0": GPIO27) und Ausrichtung panelabhängig. Das 7-Zoll-Panel ist nativ Querformat, deshalb entfallen dort die 270-Grad-Rotation und die PPA-Beschleunigung. - lvgl_port_v9.h bezieht LVGL_PORT_H/V_RES aus pins_config.h statt fest 480/800. - 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. - ui.cpp rechnet nicht mehr mit fest verdrahteten 480 Pixeln Höhe, sondern mit DISP_VER_RES. Layout und Schriften bleiben sonst unverändert. - Hersteller-Paket des 7-Zöllers unter JC_Display_Firmware_7zoll/ abgelegt; Werkzeuge, Archive und mitgelieferte Fremdbibliotheken per .gitignore ausgeschlossen (587 MB im Original, 21 MB im Repo). Kompiliertest ESP32-P4, beide Varianten: 4,3": 1.173.768 B Flash (37 %), 322.880 B RAM (98 %) 7,0": 1.138.752 B Flash (36 %), 322.600 B RAM (98 %) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
544c6ae3b8
commit
92c1446824
@@ -1,3 +1,26 @@
|
||||
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:
|
||||
- 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
|
||||
|
||||
@@ -268,7 +268,11 @@ static void enterUpdateMode() {
|
||||
void setup() {
|
||||
DBG_SERIAL.begin(DBG_BAUD);
|
||||
delay(50);
|
||||
DBG_SERIAL.println(F("\nJC4880P443C-I-W Display-Firmware startet..."));
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
DBG_SERIAL.println(F("\nJC1060P470C-I-W (7,0 Zoll) Display-Firmware startet..."));
|
||||
#else
|
||||
DBG_SERIAL.println(F("\nJC4880P443C-I-W (4,3 Zoll) Display-Firmware startet..."));
|
||||
#endif
|
||||
|
||||
// --- Boot-Loop-Schutz: Fruehstart-Zaehler in NVS erhoehen; Schwelle -> Update-Modus ---
|
||||
{
|
||||
|
||||
@@ -1,27 +1,54 @@
|
||||
# JC4880P443C-I-W — Touch-Display-Firmware (ESP32-P4)
|
||||
# JC-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.
|
||||
Client-Firmware für die Guition-Smart-Displays **JC4880P443C-I-W (4,3")** und
|
||||
**JC1060P470C-I-W (7,0")**, die als UART-Touch-Bedienung für die
|
||||
Dual-PID-Siebträgersteuerung dienen. Beide Panels teilen sich denselben Sketch; das
|
||||
Zielpanel wird über **`JC_PANEL_TYPE`** in [`config.h`](config.h) gewählt.
|
||||
|
||||
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/`)
|
||||
## Panel-Auswahl
|
||||
|
||||
| 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 |
|
||||
In [`config.h`](config.h):
|
||||
|
||||
```c
|
||||
#define JC_PANEL_TYPE JC_PANEL_43 // 4,3" JC4880P443C-I-W (Vorgabe)
|
||||
#define JC_PANEL_TYPE JC_PANEL_70 // 7,0" JC1060P470C-I-W
|
||||
```
|
||||
|
||||
Alternativ ohne Quelltextänderung per Compiler-Flag `-DJC_PANEL_TYPE=70`. Der Schalter
|
||||
steuert Panel-Treiber, Auflösung, Rotation, LCD-Reset-Pin und die Touch-Skalierung; UI,
|
||||
Protokoll und Pinbelegung des UART bleiben identisch.
|
||||
|
||||
## Hardware
|
||||
|
||||
Vendor-Pakete: 4,3" im Ordner `JC4880P443C_I_W/`, 7,0" im Repo-Ordner
|
||||
`../JC_Display_Firmware_7zoll/`.
|
||||
|
||||
| Komponente | 4,3" JC4880P443C-I-W | 7,0" JC1060P470C-I-W |
|
||||
|---|---|---|
|
||||
| Haupt-MCU (UI) | ESP32-P4 | ESP32-P4 |
|
||||
| WLAN/BT (hier ungenutzt) | ESP32-C6 | ESP32-C6 |
|
||||
| Display | ST7701, 480×800 IPS, MIPI-DSI | JD9165, 1024×600 IPS, MIPI-DSI |
|
||||
| LVGL-Ausrichtung | Rotation **270°** (PPA) → 800×480 | **keine** Rotation, nativ 1024×600 |
|
||||
| Touch | GT911, I²C SDA=GPIO7 / SCL=GPIO8 | GT911, I²C SDA=GPIO7 / SCL=GPIO8 |
|
||||
| Touch-Rohkoordinaten | 480×800 (= Panelraster) | **800×480** → wird auf 1024×600 skaliert |
|
||||
| LCD-Reset | GPIO5 | **GPIO27** |
|
||||
| Backlight | GPIO23 (LEDC-PWM) | GPIO23 (LEDC-PWM) |
|
||||
| Framebuffer (3×, RGB565) | 3 × 750 KB ≈ 2,3 MB PSRAM | 3 × 1,2 MB ≈ 3,6 MB PSRAM |
|
||||
| Freie Expansion-IO | Stiftleiste **JP1**: GPIO 52/51/50/49/35/34/33/32/31/30/29/28 | FPC 1,0 mm 16-pol. **FPC4**: GPIO 34/33/32/31/30/29/28 · **FPC3**: 48/47/46/45/5/4/3/2 |
|
||||
|
||||
> Beim 7-Zöller ist die Expansion-IO **kein Stiftleisten-Header**, sondern eine
|
||||
> FPC-Buchse (1,0 mm Raster, 16-polig) — für die UART-Verdrahtung wird ein
|
||||
> FPC-Breakout/Adapterkabel gebraucht. Schaltplan: `../JC_Display_Firmware_7zoll/5-Schematic/4_CONN.png`.
|
||||
|
||||
## Verkabelung zur Hauptplatine (UART, gekreuzt)
|
||||
|
||||
Pins aus dem Expand-IO-Header **JP1** (Schaltplan `JC4880P443C_I_W/5-Schematic/4_USB&IO.png`):
|
||||
Für **beide** Panels dieselben P4-Pins (4,3": Header JP1, Schaltplan
|
||||
`JC4880P443C_I_W/5-Schematic/4_USB&IO.png` · 7,0": FPC-Buchse FPC4):
|
||||
|
||||
```
|
||||
S3 GPIO43 (TX) ----> P4 GPIO31 (RX) (DISPLAY_UART_RX_PIN)
|
||||
@@ -68,13 +95,23 @@ 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/lcd/ (esp_lcd_st7701*.c/.h + st7701_lcd.* sowie esp_lcd_jd9165.c/.h)
|
||||
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.
|
||||
Diese Dateien liegen bereits im Sketch. `esp_lcd_jd9165.*` stammt aus dem
|
||||
7-Zoll-Vendor-Paket
|
||||
(`../JC_Display_Firmware_7zoll/1-Demo/Demo_Arduino/1_2_Lvgl_V9/.../src/lcd/`); je nach
|
||||
`JC_PANEL_TYPE` wird nur einer der beiden Panel-Treiber eingebunden.
|
||||
|
||||
Der Init-Ablauf (MIPI-DSI-PHY-LDO, ST7701 bzw. JD9165, 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.
|
||||
|
||||
Die Touch-Skalierung des 7-Zöllers hängt in `board_bringup.c` am
|
||||
`process_coordinates`-Hook von `esp_lcd_touch`, damit die Vendor-Datei
|
||||
`esp_lcd_touch_gt911.c` unverändert bleibt (im Vendor-Demo ist die Umrechnung direkt in
|
||||
den Treiber gepatcht).
|
||||
|
||||
**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
|
||||
@@ -82,10 +119,16 @@ der Arduino-`loop()` (z. B. `ui_update` bei jedem state-Push) sind daher in
|
||||
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).
|
||||
Das Dashboard ist **Querformat**. Beim 4,3-Zöller (physisch 480×800) wird das per
|
||||
LVGL-Rotation **270°** mit PPA-Beschleunigung erreicht → 800×480. Der 7-Zöller ist nativ
|
||||
1024×600, dort steht die Rotation auf **0** und PPA ist abgeschaltet. Beides setzt
|
||||
`pins_config.h` automatisch anhand von `JC_PANEL_TYPE`.
|
||||
|
||||
Das Layout arbeitet fast durchgehend mit `LV_PCT`/`LV_SIZE_CONTENT` und skaliert
|
||||
deshalb mit. Feste Pixelmaße (Rundinstrumente, Thermometer, Buttons) bleiben gleich groß
|
||||
— auf dem 7-Zöller entsteht dadurch mehr Luft. Die Schriftgrößen bleiben ebenfalls
|
||||
unverändert: 4,3" ≈ 213 dpi, 7,0" ≈ 170 dpi, gleiche Pixelhöhe wirkt dort physisch
|
||||
größer.
|
||||
|
||||
## Status
|
||||
|
||||
@@ -96,8 +139,9 @@ Querformat anpassen).
|
||||
(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.
|
||||
**Board-Bringup:** auf die konkreten JC-Pins/Treiber gesetzt (ST7701 bzw. JD9165, 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.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// =====================================================================================
|
||||
// board_bringup.c - ESP32-P4 / ST7701 / GT911 Hardware-Bringup (JC4880P443C-I-W)
|
||||
// board_bringup.c - ESP32-P4 / GT911 Hardware-Bringup
|
||||
// JC_PANEL_43 = JC4880P443C-I-W (ST7701, 480x800)
|
||||
// JC_PANEL_70 = JC1060P470C-I-W (JD9165, 1024x600)
|
||||
// =====================================================================================
|
||||
// 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)
|
||||
@@ -28,20 +30,25 @@
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_mipi_dsi.h"
|
||||
#include "src/touch/esp_lcd_touch_gt911.h"
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
#include "src/lcd/esp_lcd_jd9165.h"
|
||||
#else
|
||||
#include "src/lcd/esp_lcd_st7701.h"
|
||||
#endif
|
||||
#include "pins_config.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_LCD_H_RES (LCD_H_RES) // native Panel-Aufloesung
|
||||
#define BSP_LCD_V_RES (LCD_V_RES)
|
||||
#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 BSP_LCD_RST ((gpio_num_t)LCD_RST)
|
||||
#define BSP_LCD_BACKLIGHT ((gpio_num_t)LCD_LED)
|
||||
#define LCD_LEDC_CH LEDC_CHANNEL_0
|
||||
|
||||
static i2c_master_bus_handle_t s_i2c_handle = NULL;
|
||||
@@ -83,6 +90,26 @@ IRAM_ATTR static bool on_vsync(esp_lcd_panel_handle_t panel,
|
||||
return lvgl_port_notify_lcd_vsync();
|
||||
}
|
||||
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
// Der GT911 des 7,0"-Panels liefert Rohkoordinaten im Raster 800x480 (nicht 1024x600).
|
||||
// Ohne Umrechnung waere nur das linke obere Rechteck erreichbar. Das Hersteller-Beispiel
|
||||
// skaliert dafuer im Touch-Treiber; hier ueber den vorgesehenen process_coordinates-Hook,
|
||||
// damit die Vendor-Datei esp_lcd_touch_gt911.c unveraendert bleibt.
|
||||
#define JC_TOUCH_RAW_H_RES (800)
|
||||
#define JC_TOUCH_RAW_V_RES (480)
|
||||
|
||||
static void jc_touch_scale(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y,
|
||||
uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)
|
||||
{
|
||||
(void)tp; (void)strength; (void)max_point_num;
|
||||
if (point_num == NULL) return;
|
||||
for (uint8_t i = 0; i < *point_num; i++) {
|
||||
x[i] = (uint16_t)(((uint32_t)x[i] * LCD_H_RES) / JC_TOUCH_RAW_H_RES);
|
||||
y[i] = (uint16_t)(((uint32_t)y[i] * LCD_V_RES) / JC_TOUCH_RAW_V_RES);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Bringt Panel + Touch + LVGL-Port hoch (LVGL laeuft danach in eigenem Task).
|
||||
void jc_board_bringup(void)
|
||||
{
|
||||
@@ -104,14 +131,41 @@ void jc_board_bringup(void)
|
||||
esp_ldo_acquire_channel(&ldo_cfg, &phy_pwr_chan);
|
||||
|
||||
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
|
||||
esp_lcd_panel_io_handle_t io = NULL;
|
||||
esp_lcd_panel_handle_t disp_panel = NULL;
|
||||
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
// ---------------- 7,0" JD9165 (1024x600) ----------------
|
||||
esp_lcd_dsi_bus_config_t bus_config = JD9165_PANEL_BUS_DSI_2CH_CONFIG();
|
||||
esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus);
|
||||
|
||||
esp_lcd_dbi_io_config_t dbi_config = JD9165_PANEL_IO_DBI_CONFIG();
|
||||
esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io);
|
||||
|
||||
esp_lcd_dpi_panel_config_t dpi_config = JD9165_1024_600_PANEL_60HZ_DPI_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565);
|
||||
dpi_config.num_fbs = LVGL_PORT_LCD_BUFFER_NUMS;
|
||||
|
||||
jd9165_vendor_config_t vendor_config = {
|
||||
.mipi_config = {
|
||||
.dsi_bus = mipi_dsi_bus,
|
||||
.dpi_config = &dpi_config,
|
||||
},
|
||||
};
|
||||
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_jd9165(io, &lcd_dev_config, &disp_panel);
|
||||
#else
|
||||
// ---------------- 4,3" ST7701 (480x800) ----------------
|
||||
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;
|
||||
|
||||
@@ -131,6 +185,7 @@ void jc_board_bringup(void)
|
||||
.vendor_config = &vendor_config,
|
||||
};
|
||||
esp_lcd_new_panel_st7701(io, &lcd_dev_config, &disp_panel);
|
||||
#endif
|
||||
esp_lcd_panel_reset(disp_panel);
|
||||
esp_lcd_panel_init(disp_panel);
|
||||
|
||||
@@ -185,6 +240,9 @@ void jc_board_bringup(void)
|
||||
.mirror_x = 0,
|
||||
.mirror_y = 0,
|
||||
},
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
.process_coordinates = jc_touch_scale,
|
||||
#endif
|
||||
};
|
||||
esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp_handle);
|
||||
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
// =====================================================================================
|
||||
// JC4880P443C-I-W - Touch-Display-Firmware fuer die Dual-PID-Siebtraegersteuerung
|
||||
// config.h - zentrale Konfiguration (Pins, UART, Protokoll)
|
||||
// JC-Touch-Display-Firmware fuer die Dual-PID-Siebtraegersteuerung
|
||||
// config.h - zentrale Konfiguration (Panel-Typ, 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)
|
||||
// Zwei unterstuetzte Panels (Auswahl ueber JC_PANEL_TYPE weiter unten):
|
||||
//
|
||||
// JC_PANEL_43 - Guition JC4880P443C-I-W (4,3")
|
||||
// - MCU: ESP32-P4 (UI / LVGL)
|
||||
// - Display: ST7701 (480 x 800 IPS, MIPI-DSI) -> per Rotation 270 = 800 x 480
|
||||
// - Touch: GT911 (kapazitiv, I2C SDA=7 / SCL=8)
|
||||
// - LCD-Reset GPIO5, Backlight GPIO23 (LEDC-PWM)
|
||||
//
|
||||
// JC_PANEL_70 - Guition JC1060P470C-I-W (7,0")
|
||||
// - MCU: ESP32-P4 (UI / LVGL)
|
||||
// - Display: JD9165 (1024 x 600 IPS, MIPI-DSI) -> nativ Querformat, keine Rotation
|
||||
// - Touch: GT911 (kapazitiv, I2C SDA=7 / SCL=8); meldet Rohkoordinaten in
|
||||
// 800x480 und wird in board_bringup.c auf 1024x600 hochskaliert
|
||||
// - LCD-Reset GPIO27, Backlight GPIO23 (LEDC-PWM)
|
||||
//
|
||||
// Gemeinsam: ESP32-C6 (hier NICHT genutzt - WLAN/Webinterface laufen auf der
|
||||
// Hauptplatine), 16 MB Flash, PSRAM aktiviert, 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.
|
||||
@@ -25,6 +36,23 @@
|
||||
#define JC_USE_REAL_PANEL 1
|
||||
#endif
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Panel-Typ (C-sicher hier definiert, da auch board_bringup.c und pins_config.h ihn lesen)
|
||||
// JC_PANEL_43 = Guition JC4880P443C-I-W : 4,3", ST7701, 480x800 (per Rotation 800x480)
|
||||
// JC_PANEL_70 = Guition JC1060P470C-I-W : 7,0", JD9165, 1024x600 (nativ Querformat)
|
||||
// Umschalten entweder hier oder per Compiler-Flag -DJC_PANEL_TYPE=JC_PANEL_70.
|
||||
// -------------------------------------------------------------------------------------
|
||||
#define JC_PANEL_43 43
|
||||
#define JC_PANEL_70 70
|
||||
|
||||
#ifndef JC_PANEL_TYPE
|
||||
#define JC_PANEL_TYPE JC_PANEL_43
|
||||
#endif
|
||||
|
||||
#if (JC_PANEL_TYPE != JC_PANEL_43) && (JC_PANEL_TYPE != JC_PANEL_70)
|
||||
#error "JC_PANEL_TYPE muss JC_PANEL_43 oder JC_PANEL_70 sein"
|
||||
#endif
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// DIAGNOSE: interner UART-Loopback-Selbsttest
|
||||
// 1 = TX wird chip-intern auf RX gelegt (kein Draht, keine Pin-Unsicherheit).
|
||||
@@ -50,13 +78,18 @@
|
||||
// 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).
|
||||
// 4,3" (JC_PANEL_43): Expand-IO-Header JP1, Schaltplan "4_USB&IO.png". Frei
|
||||
// herausgefuehrte P4-GPIOs: 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
|
||||
//
|
||||
// 7,0" (JC_PANEL_70): Expand-IO liegt auf den FPC-Buchsen FPC3/FPC4 (1,0 mm, 16-polig),
|
||||
// Schaltplan "5-Schematic/4_CONN.png" - kein Stiftleisten-Header, Adapterkabel noetig.
|
||||
// FPC4 fuehrt GPIO 34/33/32/31/30/29/28 heraus, FPC3 zusaetzlich 48/47/46/45/5/4/3/2.
|
||||
//
|
||||
// Beide Panels: gleiche Pinwahl P4-TX = GPIO33, P4-RX = GPIO31.
|
||||
// GPIO33 (P4 TX) ----> S3 GPIO44 (RX)
|
||||
// GPIO31 (P4 RX) <---- S3 GPIO43 (TX)
|
||||
// GND ---- S3 GND
|
||||
#define DISPLAY_UART_PORT Serial1
|
||||
#define DISPLAY_UART_BAUDRATE 230400
|
||||
#define DISPLAY_UART_TX_PIN 33
|
||||
@@ -65,7 +98,7 @@
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Firmware
|
||||
// -------------------------------------------------------------------------------------
|
||||
#define DISPLAY_FW_VERSION "1.4.2" // Firmware-Stand der P4-Display-Steuerung (Info-Seite)
|
||||
#define DISPLAY_FW_VERSION "1.5.0" // Firmware-Stand der P4-Display-Steuerung (Info-Seite)
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Protokoll
|
||||
@@ -82,9 +115,15 @@
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Display / LVGL
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Querformat: Panel ist physisch 480x800, per Rotation 90 (pins_config.h) -> 800x480.
|
||||
// Querformat. 4,3": Panel ist physisch 480x800, per Rotation 270 (pins_config.h) -> 800x480.
|
||||
// 7,0": Panel ist nativ 1024x600, keine Rotation noetig.
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
#define DISP_HOR_RES 1024
|
||||
#define DISP_VER_RES 600
|
||||
#else
|
||||
#define DISP_HOR_RES 800
|
||||
#define DISP_VER_RES 480
|
||||
#endif
|
||||
#define LVGL_TICK_MS 5
|
||||
|
||||
// Debug-Ausgaben ueber USB-CDC (nicht ueber den Display-UART!)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// =====================================================================================
|
||||
// display_hal.h - Board-/Panel-/Touch-Anbindung (ST7701 + GT911) + LVGL-Glue
|
||||
// display_hal.h - Board-/Panel-/Touch-Anbindung (ST7701 bzw. JD9165 + GT911) + LVGL-Glue
|
||||
// =====================================================================================
|
||||
// Einziger board-spezifischer Teil. Baut auf der HERSTELLER-LVGL-PORTIERUNG des
|
||||
// JC4880P443C-I-W auf (1-Demo/arduino_examples/lvgl_v9_sw_rotation):
|
||||
// - MIPI-DSI ST7701 (480x800), GT911-Touch (I2C SDA=7/SCL=8), Backlight GPIO23
|
||||
// - MIPI-DSI ST7701 (480x800) bzw. JD9165 (1024x600) - Auswahl ueber JC_PANEL_TYPE
|
||||
// - GT911-Touch (I2C SDA=7/SCL=8), Backlight GPIO23
|
||||
// - LVGL laeuft in einem EIGENEN FreeRTOS-Task -> UI-Zugriffe von aussen muessen
|
||||
// mit hal_lock()/hal_unlock() (= lvgl_port_lock/unlock) geschuetzt werden.
|
||||
//
|
||||
|
||||
@@ -33,8 +33,10 @@ typedef enum {
|
||||
* LVGL related parameters, can be adjusted by users
|
||||
*
|
||||
*/
|
||||
#define LVGL_PORT_H_RES (480)
|
||||
#define LVGL_PORT_V_RES (800)
|
||||
/* Native Panel-Aufloesung - kommt aus pins_config.h, damit beide Panel-Typen
|
||||
* (JC_PANEL_43: 480x800 / JC_PANEL_70: 1024x600) denselben Port nutzen koennen. */
|
||||
#define LVGL_PORT_H_RES (LCD_H_RES)
|
||||
#define LVGL_PORT_V_RES (LCD_V_RES)
|
||||
#define LVGL_PORT_TICK_PERIOD_MS (EXAMPLE_LVGL_PORT_TICK)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h" // liefert JC_PANEL_TYPE (C-sicher, keine Rueckabhaengigkeit)
|
||||
|
||||
#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
|
||||
@@ -16,18 +18,36 @@
|
||||
// Bei Rotation 90 nutzen beide Modi ohnehin 3 Framebuffer -> kein Mehrverbrauch.
|
||||
#define EXAMPLE_LVGL_PORT_AVOID_TEAR_MODE 2 //range 1 to 3
|
||||
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
// 7,0" JD9165: Panel ist nativ 1024x600 Querformat -> keine Rotation, kein PPA noetig.
|
||||
#define EXAMPLE_LVGL_PORT_ROTATION_DEGREE_ 0 // 0,90,180,270
|
||||
#define EXAMPLE_LVGL_PORT_PPA_ROTATION_ENABLE 0
|
||||
#else
|
||||
// 4,3" ST7701: Panel ist physisch 480x800 Hochformat.
|
||||
#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
|
||||
#endif
|
||||
|
||||
|
||||
// LCD_H_RES/LCD_V_RES = NATIVE Panel-Aufloesung (vor der LVGL-Rotation).
|
||||
#if JC_PANEL_TYPE == JC_PANEL_70
|
||||
|
||||
#define LCD_H_RES 1024
|
||||
#define LCD_V_RES 600
|
||||
|
||||
#define LCD_RST 27
|
||||
#define LCD_LED 23
|
||||
|
||||
#else
|
||||
|
||||
#define LCD_H_RES 480
|
||||
#define LCD_V_RES 800
|
||||
|
||||
#define LCD_RST -1
|
||||
#define LCD_LED -1
|
||||
#define LCD_RST 5
|
||||
#define LCD_LED 23
|
||||
|
||||
#endif
|
||||
|
||||
#define TP_I2C_SDA 7
|
||||
#define TP_I2C_SCL 8
|
||||
|
||||
@@ -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
|
||||
@@ -1,5 +1,6 @@
|
||||
// =====================================================================================
|
||||
// ui.cpp - LVGL-Oberflaeche (Querformat 800x480), Design an die Web-UI angelehnt
|
||||
// ui.cpp - LVGL-Oberflaeche (Querformat, 800x480 bzw. 1024x600 je nach Panel),
|
||||
// Design an die Web-UI angelehnt
|
||||
// =====================================================================================
|
||||
// Navigation ueber ein Hamburger-Menue (Icon oben links -> Schublade von links).
|
||||
// Seiten:
|
||||
@@ -522,7 +523,7 @@ static void err_icon_cb(lv_event_t*) { show_page(PG_DASH); } // Tipp auf Fehl
|
||||
|
||||
// --- Dezente Ein-/Ausblendungen (Opazitaets-Fade) -------------------------------------
|
||||
// Bewusst ueber das 'opa'-Style (faellt via opa_recursive auf die Kinder durch) und NICHT
|
||||
// ueber 'opa_layered' - Letzteres wuerde einen Vollbild-Zwischenpuffer (800x480) allozieren
|
||||
// ueber 'opa_layered' - Letzteres wuerde einen Vollbild-Zwischenpuffer allozieren
|
||||
// und koennte den LVGL-Speicherpool sprengen. So bleibt das Fade speicher-neutral.
|
||||
static const uint32_t UI_FADE_MS = 450; // ruhige, unaufdringliche Dauer
|
||||
|
||||
@@ -3231,7 +3232,7 @@ void ui_init(ProtocolClient* client) {
|
||||
|
||||
// --- Content-Bereich (Seiten gestapelt) ---
|
||||
g_content = lv_obj_create(scr);
|
||||
lv_obj_set_size(g_content, LV_PCT(100), 480 - 44);
|
||||
lv_obj_set_size(g_content, LV_PCT(100), DISP_VER_RES - 44);
|
||||
lv_obj_set_pos(g_content, 0, 44);
|
||||
lv_obj_set_style_bg_opa(g_content, LV_OPA_TRANSP, 0);
|
||||
lv_obj_set_style_border_width(g_content, 0, 0);
|
||||
@@ -3252,7 +3253,7 @@ void ui_init(ProtocolClient* client) {
|
||||
|
||||
// --- Schublade (Scrim + Menue-Panel) ---
|
||||
g_drawer = lv_obj_create(scr);
|
||||
lv_obj_set_size(g_drawer, LV_PCT(100), 480 - 44);
|
||||
lv_obj_set_size(g_drawer, LV_PCT(100), DISP_VER_RES - 44);
|
||||
lv_obj_set_pos(g_drawer, 0, 44);
|
||||
lv_obj_set_style_bg_color(g_drawer, lv_color_hex(0x000000), 0);
|
||||
lv_obj_set_style_bg_opa(g_drawer, LV_OPA_50, 0);
|
||||
|
||||
Reference in New Issue
Block a user