Skip to content

Commit b892ccf

Browse files
authored
GC9A01 Display driver support (#165)
* feat: Initial attempt of GC9A01 display driver * fix: Fixed missing mirror/swap functionality * refactor: Added send_command overload * refactor: Clang format * docs: Removed inapplicable comments * fix: Fixed issue with wrong default mirror/swap settings * feat: Added Smartknob-HA example using the GC9A01
1 parent 5ef4de0 commit b892ccf

File tree

5 files changed

+411
-11
lines changed

5 files changed

+411
-11
lines changed

Diff for: components/display_drivers/example/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This example can be configured to run on the following dev boards:
1212
* ESP32-WROVER-Kit
1313
* TTGO T-Display
1414
* ESP32-S3-BOX
15+
* Smartknob-HA
1516

1617
### Configure the project
1718

@@ -20,7 +21,7 @@ idf.py menuconfig
2021
```
2122

2223
When configuring the project, select the `Display Drivers Example Configuration`
23-
value that matches the board you've selected (must be one of the 3 boards
24+
value that matches the board you've selected (must be one of the 4 boards
2425
mentioned above.)
2526

2627
### Build and Flash

Diff for: components/display_drivers/example/main/Kconfig.projbuild

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ menu "Display Drivers Example Configuration"
1111
bool "TTGO T-DISPLAY"
1212
config HARDWARE_BOX
1313
bool "ESP BOX"
14+
config SMARTKNOB_HA
15+
bool "SMARTKNOB-HA"
1416
endchoice
1517

1618
endmenu

Diff for: components/display_drivers/example/main/display_drivers_example.cpp

+38-10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ static constexpr int DC_PIN_NUM = 16;
1616
#elif CONFIG_HARDWARE_BOX
1717
#include "st7789.hpp"
1818
static constexpr int DC_PIN_NUM = 4;
19+
#elif CONFIG_SMARTKNOB_HA
20+
#include "gc9a01.hpp"
21+
static constexpr int DC_PIN_NUM = 16;
1922
#else
2023
#error "Misconfigured hardware!"
2124
#endif
@@ -118,29 +121,32 @@ void IRAM_ATTR lcd_send_lines(int xs, int ys, int xe, int ye, const uint8_t *dat
118121
size_t length = (xe - xs + 1) * (ye - ys + 1) * 2;
119122
#if CONFIG_HARDWARE_WROVER_KIT
120123
trans[0].tx_data[0] = (uint8_t)espp::Ili9341::Command::caset;
121-
#endif
122-
#if CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX
124+
#elif CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX
123125
trans[0].tx_data[0] = (uint8_t)espp::St7789::Command::caset;
126+
#elif CONFIG_SMARTKNOB_HA
127+
trans[0].tx_data[0] = (uint8_t)espp::Gc9a01::Command::caset;
124128
#endif
125129
trans[1].tx_data[0] = (xs) >> 8;
126130
trans[1].tx_data[1] = (xs)&0xff;
127131
trans[1].tx_data[2] = (xe) >> 8;
128132
trans[1].tx_data[3] = (xe)&0xff;
129133
#if CONFIG_HARDWARE_WROVER_KIT
130134
trans[2].tx_data[0] = (uint8_t)espp::Ili9341::Command::raset;
131-
#endif
132-
#if CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX
135+
#elif CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX
133136
trans[2].tx_data[0] = (uint8_t)espp::St7789::Command::raset;
137+
#elif CONFIG_SMARTKNOB_HA
138+
trans[2].tx_data[0] = (uint8_t)espp::Gc9a01::Command::raset;
134139
#endif
135140
trans[3].tx_data[0] = (ys) >> 8;
136141
trans[3].tx_data[1] = (ys)&0xff;
137142
trans[3].tx_data[2] = (ye) >> 8;
138143
trans[3].tx_data[3] = (ye)&0xff;
139144
#if CONFIG_HARDWARE_WROVER_KIT
140145
trans[4].tx_data[0] = (uint8_t)espp::Ili9341::Command::ramwr;
141-
#endif
142-
#if CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX
146+
#elif CONFIG_HARDWARE_TTGO || CONFIG_HARDWARE_BOX
143147
trans[4].tx_data[0] = (uint8_t)espp::St7789::Command::ramwr;
148+
#elif CONFIG_SMARTKNOB_HA
149+
trans[4].tx_data[0] = (uint8_t)espp::Gc9a01::Command::ramwr;
144150
#endif
145151
trans[5].tx_buffer = data;
146152
trans[5].length = length * 8;
@@ -199,8 +205,7 @@ extern "C" void app_main(void) {
199205
using DisplayDriver = espp::Ili9341;
200206
auto rotation = espp::Display::Rotation::LANDSCAPE;
201207
//! [wrover_kit_config example]
202-
#endif
203-
#if CONFIG_HARDWARE_TTGO
208+
#elif CONFIG_HARDWARE_TTGO
204209
//! [ttgo_config example]
205210
static constexpr std::string_view dev_kit = "TTGO T-Display";
206211
int clock_speed = 60 * 1000 * 1000;
@@ -224,8 +229,7 @@ extern "C" void app_main(void) {
224229
using DisplayDriver = espp::St7789;
225230
auto rotation = espp::Display::Rotation::PORTRAIT;
226231
//! [ttgo_config example]
227-
#endif
228-
#if CONFIG_HARDWARE_BOX
232+
#elif CONFIG_HARDWARE_BOX
229233
//! [box_config example]
230234
static constexpr std::string_view dev_kit = "ESP32-S3-BOX";
231235
int clock_speed = 60 * 1000 * 1000;
@@ -249,6 +253,30 @@ extern "C" void app_main(void) {
249253
using DisplayDriver = espp::St7789;
250254
auto rotation = espp::Display::Rotation::LANDSCAPE;
251255
//! [box_config example]
256+
#elif CONFIG_SMARTKNOB_HA
257+
//! [smartknob_config example]
258+
static constexpr std::string_view dev_kit = "Smartknob-HA";
259+
int clock_speed = 80 * 1000 * 1000;
260+
auto spi_num = SPI2_HOST;
261+
gpio_num_t mosi = GPIO_NUM_6;
262+
gpio_num_t sclk = GPIO_NUM_5;
263+
gpio_num_t spics = GPIO_NUM_15;
264+
gpio_num_t reset = GPIO_NUM_4;
265+
gpio_num_t dc_pin = (gpio_num_t)DC_PIN_NUM;
266+
gpio_num_t backlight = GPIO_NUM_7;
267+
size_t width = 240;
268+
size_t height = 240;
269+
size_t pixel_buffer_size = width * 50;
270+
bool backlight_on_value = true;
271+
bool reset_value = false;
272+
bool invert_colors = true;
273+
int offset_x = 0;
274+
int offset_y = 0;
275+
bool mirror_x = true;
276+
bool mirror_y = true;
277+
using DisplayDriver = espp::Gc9a01;
278+
auto rotation = espp::Display::Rotation::LANDSCAPE;
279+
//! [smartknob_config example]
252280
#endif
253281

254282
fmt::print("Starting display_drivers example for {}\n", dev_kit);

0 commit comments

Comments
 (0)