diff --git a/main/boards/movecall-moji-esp32s3/config.h b/main/boards/movecall-moji-esp32s3/config.h index 943abb71..2744a25b 100644 --- a/main/boards/movecall-moji-esp32s3/config.h +++ b/main/boards/movecall-moji-esp32s3/config.h @@ -34,5 +34,12 @@ #define DISPLAY_BACKLIGHT_PIN GPIO_NUM_3 #define DISPLAY_BACKLIGHT_OUTPUT_INVERT false +#define DISPLAY_SPI_SCLK_PIN GPIO_NUM_16 +#define DISPLAY_SPI_MOSI_PIN GPIO_NUM_17 +#define DISPLAY_SPI_CS_PIN GPIO_NUM_15 +#define DISPLAY_SPI_DC_PIN GPIO_NUM_7 +#define DISPLAY_SPI_RESET_PIN GPIO_NUM_18 + +#define DISPLAY_SPI_SCLK_HZ (40 * 1000 * 1000) #endif // _BOARD_CONFIG_H_ diff --git a/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc b/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc index 47936d5f..19837e7f 100644 --- a/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc +++ b/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc @@ -25,59 +25,6 @@ LV_FONT_DECLARE(font_puhui_20_4); LV_FONT_DECLARE(font_awesome_20_4); -static const gc9a01_lcd_init_cmd_t gc9107_lcd_init_cmds[] = { - // {cmd, { data }, data_size, delay_ms} - {0xef, (uint8_t[]){0x00}, 0, 0}, - {0xeb, (uint8_t[]){0x14}, 0, 0}, - {0xfe, (uint8_t[]){0x00}, 0, 0}, - {0xef, (uint8_t[]){0x00}, 0, 0}, - {0xEB, (uint8_t[]){0x14}, 1, 0}, - {0x84, (uint8_t[]){0x40}, 1, 0}, - {0x85, (uint8_t[]){0xFF}, 1, 0}, - {0x86, (uint8_t[]){0xFF}, 1, 0}, - {0x87, (uint8_t[]){0xFF}, 1, 0}, - {0x88, (uint8_t[]){0x0A}, 1, 0}, - {0x89, (uint8_t[]){0x21}, 1, 0}, - {0x8A, (uint8_t[]){0x00}, 1, 0}, - {0x8B, (uint8_t[]){0x80}, 1, 0}, - {0x8C, (uint8_t[]){0x01}, 1, 0}, - {0x8D, (uint8_t[]){0x01}, 1, 0}, - {0x8E, (uint8_t[]){0xFF}, 1, 0}, - {0x8F, (uint8_t[]){0xFF}, 1, 0}, - {0xB6, (uint8_t[]){0x00, 0x20,}, 2, 0}, - {0x3A, (uint8_t[]){0x05}, 1, 0}, - {0x90, (uint8_t[]){0x08, 0x08, 0x08, 0x08}, 4, 0}, - {0xBD, (uint8_t[]){0x06}, 1, 0}, - {0xBC, (uint8_t[]){0x00}, 1, 0}, - {0xFF, (uint8_t[]){0x60, 0x01, 0x04}, 3, 0}, - {0xC3, (uint8_t[]){0x13}, 1, 0}, - {0xC4, (uint8_t[]){0x13}, 1, 0}, - {0xC9, (uint8_t[]){0x22}, 1, 0}, - {0xBE, (uint8_t[]){0x11}, 1, 0}, - {0xE1, (uint8_t[]){0x10, 0x0E}, 2, 0}, - {0xDF, (uint8_t[]){0x21, 0x0c, 0x02}, 3, 0}, - {0xF0, (uint8_t[]){0x45, 0x09, 0x08, 0x08, 0x26, 0x2A}, 6, 0}, - {0xF1, (uint8_t[]){0x43, 0x70, 0x72, 0x36, 0x37, 0x6F}, 6, 0}, - {0xF2, (uint8_t[]){0x45, 0x09, 0x08, 0x08, 0x26, 0x2A}, 6, 0}, - {0xF3, (uint8_t[]){0x43, 0x70, 0x72, 0x36, 0x37, 0x6F}, 6, 0}, - {0xED, (uint8_t[]){0x1B, 0x0B}, 2, 0}, - {0xAE, (uint8_t[]){0x77}, 1, 0}, - {0xCD, (uint8_t[]){0x63}, 1, 0}, - {0x70, (uint8_t[]){0x07, 0x07, 0x04, 0x0E, 0x0F, 0x09, 0x07, 0x08, 0x03}, 9, 0}, - {0xE8, (uint8_t[]){0x34}, 1, 0}, - {0x62, (uint8_t[]){0x18, 0x0D, 0x71, 0xED, 0x70, 0x70, 0x18, 0x0F, 0x71, 0xEF, 0x70, 0x70}, 12, 0}, - {0x63, (uint8_t[]){0x18, 0x11, 0x71, 0xF1, 0x70, 0x70, 0x18, 0x13, 0x71, 0xF3, 0x70, 0x70}, 12, 0}, - {0x64, (uint8_t[]){0x28, 0x29, 0xF1, 0x01, 0xF1, 0x00, 0x07}, 7, 0}, - {0x66, (uint8_t[]){0x3C, 0x00, 0xCD, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00}, 10, 0}, - {0x67, (uint8_t[]){0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98}, 10, 0}, - {0x74, (uint8_t[]){0x10, 0x85, 0x80, 0x00, 0x00, 0x4E, 0x00}, 7, 0}, - {0x98, (uint8_t[]){0x3e, 0x07}, 2, 0}, - {0x35, (uint8_t[]){0x00}, 0, 0}, - {0x11, (uint8_t[]){0x00}, 0, 120}, - {0x29, (uint8_t[]){0x00}, 0, 20}, - // GC9A01_INVON - {0x21, (uint8_t[]){0x00}, 0, 20}, -}; class CustomLcdDisplay : public LcdDisplay { public: @@ -133,47 +80,33 @@ private: // SPI初始化 void InitializeSpi() { ESP_LOGI(TAG, "Initialize SPI bus"); - spi_bus_config_t buscfg = {}; - buscfg.mosi_io_num = GPIO_NUM_17; - buscfg.miso_io_num = GPIO_NUM_NC; - buscfg.sclk_io_num = GPIO_NUM_16; - buscfg.quadwp_io_num = GPIO_NUM_NC; - buscfg.quadhd_io_num = GPIO_NUM_NC; - buscfg.max_transfer_sz = DISPLAY_WIDTH * DISPLAY_HEIGHT * sizeof(uint16_t); + spi_bus_config_t buscfg = GC9A01_PANEL_BUS_SPI_CONFIG(DISPLAY_SPI_SCLK_PIN, DISPLAY_SPI_MOSI_PIN, + DISPLAY_WIDTH * DISPLAY_HEIGHT * sizeof(uint16_t)); ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO)); } - // GC9107初始化 - void InitializeGc9107Display() { - ESP_LOGI(TAG, "Init GC9107 display"); + // GC9A01初始化 + void InitializeGc9a01Display() { + ESP_LOGI(TAG, "Init GC9A01 display"); ESP_LOGI(TAG, "Install panel IO"); esp_lcd_panel_io_handle_t io_handle = NULL; - esp_lcd_panel_io_spi_config_t io_config = {}; - io_config.cs_gpio_num = GPIO_NUM_15; - io_config.dc_gpio_num = GPIO_NUM_7; - io_config.spi_mode = 0; - io_config.pclk_hz = 40 * 1000 * 1000; - io_config.trans_queue_depth = 10; - io_config.lcd_cmd_bits = 8; - io_config.lcd_param_bits = 8; + esp_lcd_panel_io_spi_config_t io_config = GC9A01_PANEL_IO_SPI_CONFIG(DISPLAY_SPI_CS_PIN, DISPLAY_SPI_DC_PIN, NULL, NULL); + io_config.pclk_hz = DISPLAY_SPI_SCLK_HZ; ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi(SPI3_HOST, &io_config, &io_handle)); ESP_LOGI(TAG, "Install GC9A01 panel driver"); esp_lcd_panel_handle_t panel_handle = NULL; - gc9a01_vendor_config_t gc9107_vendor_config = { - .init_cmds = gc9107_lcd_init_cmds, - .init_cmds_size = sizeof(gc9107_lcd_init_cmds) / sizeof(gc9a01_lcd_init_cmd_t), - }; esp_lcd_panel_dev_config_t panel_config = {}; - panel_config.reset_gpio_num = GPIO_NUM_18; // Set to -1 if not use - panel_config.rgb_endian = LCD_RGB_ELEMENT_ORDER_BGR;//LCD_RGB_ENDIAN_RGB; - panel_config.bits_per_pixel = 16; // Implemented by LCD command `3Ah` (16/18) - panel_config.vendor_config = &gc9107_vendor_config; + panel_config.reset_gpio_num = DISPLAY_SPI_RESET_PIN; // Set to -1 if not use + panel_config.rgb_endian = LCD_RGB_ENDIAN_BGR; //LCD_RGB_ENDIAN_RGB; + panel_config.bits_per_pixel = 16; // Implemented by LCD command `3Ah` (16/18) ESP_ERROR_CHECK(esp_lcd_new_panel_gc9a01(io_handle, &panel_config, &panel_handle)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); + ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, true)); + ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, true, false)); ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); display_ = new LcdDisplay(io_handle, panel_handle, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, @@ -204,7 +137,7 @@ private: // 物联网初始化,添加对 AI 可见设备 void InitializeIot() { auto& thing_manager = iot::ThingManager::GetInstance(); - thing_manager.AddThing(iot::CreateThing("Speaker")); + thing_manager.AddThing(iot::CreateThing("Speaker")); } public: @@ -212,7 +145,7 @@ public: InitializeCodecI2c(); InitializeSpi(); - InitializeGc9107Display(); + InitializeGc9a01Display(); InitializeButtons(); InitializeIot(); }