Skip to content

Commit 3de4d2a

Browse files
Y1hsiaochunnnLzw655
authored andcommitted
feat(lcd): add LCD controller JD9365 @Y1hsiaochunnn (#123)
1 parent 307f552 commit 3de4d2a

File tree

5 files changed

+832
-0
lines changed

5 files changed

+832
-0
lines changed

src/ESP_Panel_Library.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
/* LCD */
2727
#include "lcd/ESP_PanelLcd.h"
2828
#include "lcd/EK79007.h"
29+
#include "lcd/JD9365.h"
2930
#include "lcd/EK9716B.h"
3031
#include "lcd/GC9503.h"
3132
#include "lcd/GC9A01.h"

src/lcd/JD9365.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "soc/soc_caps.h"
8+
9+
#if SOC_MIPI_DSI_SUPPORTED
10+
#include "ESP_PanelLog.h"
11+
#include "JD9365.h"
12+
13+
static const char *TAG = "JD9365_CPP";
14+
15+
ESP_PanelLcd_JD9365::ESP_PanelLcd_JD9365(ESP_PanelBus *bus, uint8_t color_bits, int rst_io):
16+
ESP_PanelLcd(bus, color_bits, rst_io)
17+
{
18+
disabled_functions.set_gap = 1;
19+
disabled_functions.swap_xy = 1;
20+
}
21+
22+
ESP_PanelLcd_JD9365::ESP_PanelLcd_JD9365(ESP_PanelBus *bus, const esp_lcd_panel_dev_config_t &panel_config):
23+
ESP_PanelLcd(bus, panel_config)
24+
{
25+
disabled_functions.set_gap = 1;
26+
disabled_functions.swap_xy = 1;
27+
}
28+
29+
ESP_PanelLcd_JD9365::~ESP_PanelLcd_JD9365()
30+
{
31+
ESP_PANEL_ENABLE_TAG_DEBUG_LOG();
32+
33+
if (handle == NULL) {
34+
goto end;
35+
}
36+
37+
if (!del()) {
38+
ESP_LOGE(TAG, "Delete device failed");
39+
}
40+
41+
end:
42+
ESP_LOGD(TAG, "Destroyed");
43+
}
44+
45+
bool ESP_PanelLcd_JD9365::init(void)
46+
{
47+
ESP_PANEL_CHECK_NULL_RET(bus, false, "Invalid bus");
48+
49+
/* Load MIPI-DSI configurations from bus to vendor configurations */
50+
ESP_PANEL_CHECK_FALSE_RET(loadVendorConfigFromBus(), false, "Load vendor config from bus failed");
51+
52+
/* Create panel handle */
53+
ESP_PANEL_CHECK_ERR_RET(
54+
esp_lcd_new_panel_jd9365(bus->getPanelIO_Handle(), &panel_config, &handle), false, "Create panel failed"
55+
);
56+
57+
return true;
58+
}
59+
60+
#endif

src/lcd/JD9365.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
8+
#include "soc/soc_caps.h"
9+
10+
#if SOC_MIPI_DSI_SUPPORTED
11+
#include "ESP_PanelLcd.h"
12+
#include "base/esp_lcd_vendor_types.h"
13+
#include "base/esp_lcd_jd9365.h"
14+
15+
/**
16+
* @brief JD9365 LCD device object class
17+
*
18+
* @note This class is a derived class of `ESP_PanelLcd`, user can use it directly
19+
*/
20+
class ESP_PanelLcd_JD9365: public ESP_PanelLcd {
21+
public:
22+
/**
23+
* @brief Construct a new LCD device in a simple way, the `init()` function should be called after this function
24+
*
25+
* @note This function uses some default values to config the LCD device, please use `config*()` functions to
26+
* change them
27+
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier
28+
* for initialization sequence code, and use `configVendorCommands()` to configure
29+
*
30+
* @param bus Pointer of panel bus
31+
* @param color_bits Bits per pixel (16/18/24)
32+
* @param rst_io Reset pin, set to -1 if no use
33+
*/
34+
ESP_PanelLcd_JD9365(ESP_PanelBus *bus, uint8_t color_bits, int rst_io = -1);
35+
36+
/**
37+
* @brief Construct a new LCD in a complex way, the `init()` function should be called after this function
38+
*
39+
* @param bus Pointer of panel bus
40+
* @param panel_config LCD device configuration
41+
*/
42+
ESP_PanelLcd_JD9365(ESP_PanelBus *bus, const esp_lcd_panel_dev_config_t &panel_config);
43+
44+
/**
45+
* @brief Destroy the LCD device
46+
*
47+
*/
48+
~ESP_PanelLcd_JD9365() override;
49+
50+
/**
51+
* @brief Initialize the LCD device, the `begin()` function should be called after this function
52+
*
53+
* @note This function typically calls `esp_lcd_new_panel_*()` to create the LCD panel handle
54+
*
55+
* @return true if success, otherwise false
56+
*/
57+
bool init(void) override;
58+
};
59+
#endif

0 commit comments

Comments
 (0)