forked from xiaozhi/xiaozhi-esp32
add 神奇按钮Magiclick_2.4
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#define BUILTIN_LED_NUM 2
|
#define BUILTIN_LED_NUM 2
|
||||||
#define BUILTIN_LED_GPIO GPIO_NUM_38
|
#define BUILTIN_LED_GPIO GPIO_NUM_38
|
||||||
|
|
||||||
#define BOOT_BUTTON_GPIO GPIO_NUM_21
|
#define BOOT_BUTTON_GPIO GPIO_NUM_21
|
||||||
|
|
||||||
// display
|
// display
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
#define DISPLAY_WIDTH 128
|
#define DISPLAY_WIDTH 128
|
||||||
#define DISPLAY_HEIGHT 128
|
#define DISPLAY_HEIGHT 128
|
||||||
#define DISPLAY_MIRROR_X false
|
#define DISPLAY_MIRROR_X false
|
||||||
#define DISPLAY_MIRROR_Y false
|
#define DISPLAY_MIRROR_Y true
|
||||||
#define DISPLAY_SWAP_XY false
|
#define DISPLAY_SWAP_XY false
|
||||||
|
|
||||||
#define DISPLAY_OFFSET_X 0
|
#define DISPLAY_OFFSET_X 0
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include <driver/i2c_master.h>
|
#include <driver/i2c_master.h>
|
||||||
#include <driver/spi_common.h>
|
#include <driver/spi_common.h>
|
||||||
|
#include "esp_lcd_nv3023.h"
|
||||||
#define TAG "magiclick_2p4"
|
#define TAG "magiclick_2p4"
|
||||||
|
|
||||||
class magiclick_2p4 : public WifiBoard {
|
class magiclick_2p4 : public WifiBoard {
|
||||||
@@ -55,7 +55,7 @@ private:
|
|||||||
// 设置GPIO模式
|
// 设置GPIO模式
|
||||||
gpio_reset_pin(BUILTIN_LED_POWER);
|
gpio_reset_pin(BUILTIN_LED_POWER);
|
||||||
gpio_set_direction(BUILTIN_LED_POWER, GPIO_MODE_OUTPUT);
|
gpio_set_direction(BUILTIN_LED_POWER, GPIO_MODE_OUTPUT);
|
||||||
gpio_set_level(BUILTIN_LED_POWER, BUILTIN_LED_POWER_OUTPUT_INVERT?0:1);
|
gpio_set_level(BUILTIN_LED_POWER, BUILTIN_LED_POWER_OUTPUT_INVERT ? 0 : 1);
|
||||||
}
|
}
|
||||||
void InitializeSpi() {
|
void InitializeSpi() {
|
||||||
spi_bus_config_t buscfg = {};
|
spi_bus_config_t buscfg = {};
|
||||||
@@ -68,9 +68,7 @@ private:
|
|||||||
ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO));
|
ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeSt7789Display(){
|
||||||
|
|
||||||
void InitializeSt7789Display() {
|
|
||||||
esp_lcd_panel_io_handle_t panel_io = nullptr;
|
esp_lcd_panel_io_handle_t panel_io = nullptr;
|
||||||
esp_lcd_panel_handle_t panel = nullptr;
|
esp_lcd_panel_handle_t panel = nullptr;
|
||||||
// 液晶屏控制IO初始化
|
// 液晶屏控制IO初始化
|
||||||
@@ -78,7 +76,7 @@ private:
|
|||||||
esp_lcd_panel_io_spi_config_t io_config = {};
|
esp_lcd_panel_io_spi_config_t io_config = {};
|
||||||
io_config.cs_gpio_num = DISPLAY_CS_PIN;
|
io_config.cs_gpio_num = DISPLAY_CS_PIN;
|
||||||
io_config.dc_gpio_num = DISPLAY_DC_PIN;
|
io_config.dc_gpio_num = DISPLAY_DC_PIN;
|
||||||
io_config.spi_mode = 2;
|
io_config.spi_mode = 0;
|
||||||
io_config.pclk_hz = 20 * 1000 * 1000;
|
io_config.pclk_hz = 20 * 1000 * 1000;
|
||||||
io_config.trans_queue_depth = 10;
|
io_config.trans_queue_depth = 10;
|
||||||
io_config.lcd_cmd_bits = 8;
|
io_config.lcd_cmd_bits = 8;
|
||||||
@@ -90,31 +88,29 @@ private:
|
|||||||
esp_lcd_panel_dev_config_t panel_config = {};
|
esp_lcd_panel_dev_config_t panel_config = {};
|
||||||
panel_config.reset_gpio_num = DISPLAY_RST_PIN;
|
panel_config.reset_gpio_num = DISPLAY_RST_PIN;
|
||||||
panel_config.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB;
|
panel_config.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB;
|
||||||
|
panel_config.rgb_endian = LCD_RGB_ENDIAN_RGB;
|
||||||
panel_config.bits_per_pixel = 16;
|
panel_config.bits_per_pixel = 16;
|
||||||
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(panel_io, &panel_config, &panel));
|
ESP_ERROR_CHECK(esp_lcd_new_panel_nv3023(panel_io, &panel_config, &panel));
|
||||||
|
|
||||||
esp_lcd_panel_reset(panel);
|
esp_lcd_panel_reset(panel);
|
||||||
|
|
||||||
|
|
||||||
esp_lcd_panel_init(panel);
|
esp_lcd_panel_init(panel);
|
||||||
esp_lcd_panel_invert_color(panel, true);
|
esp_lcd_panel_invert_color(panel, true);
|
||||||
esp_lcd_panel_swap_xy(panel, DISPLAY_SWAP_XY);
|
esp_lcd_panel_swap_xy(panel, DISPLAY_SWAP_XY);
|
||||||
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
|
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
|
||||||
|
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel, true));
|
||||||
display_ = new St7789Display(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
|
display_ = new St7789Display(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
|
||||||
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
|
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
magiclick_2p4() :
|
magiclick_2p4() :
|
||||||
boot_button_(BOOT_BUTTON_GPIO) {
|
boot_button_(BOOT_BUTTON_GPIO) {
|
||||||
|
|
||||||
|
|
||||||
InitializeCodecI2c();
|
InitializeCodecI2c();
|
||||||
InitializeButtons();
|
InitializeButtons();
|
||||||
InitializeLedPower();
|
InitializeLedPower();
|
||||||
InitializeSpi();
|
InitializeSpi();
|
||||||
InitializeSt7789Display();
|
InitializeSt7789Display();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Led* GetBuiltinLed() override {
|
virtual Led* GetBuiltinLed() override {
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ dependencies:
|
|||||||
espressif/button: "^3.3.1"
|
espressif/button: "^3.3.1"
|
||||||
lvgl/lvgl: "~8.4.0"
|
lvgl/lvgl: "~8.4.0"
|
||||||
esp_lvgl_port: "~2.4.1"
|
esp_lvgl_port: "~2.4.1"
|
||||||
|
MakerM0/esp_lcd_nv3023:
|
||||||
|
git: https://github.com/MakerM0/esp_lcd_nv3023.git
|
||||||
## Required IDF version
|
## Required IDF version
|
||||||
idf:
|
idf:
|
||||||
version: ">=5.3"
|
version: ">=5.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user