From 5e406b481cf371b835d6a770cae01369951ab4ce Mon Sep 17 00:00:00 2001 From: ooxxU <71391474@qq.com> Date: Wed, 12 Feb 2025 02:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20ESP32=20=E7=B3=BB=E5=88=97?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=9D=BF=20=E5=AF=B9=20OLED-0.96=20SSD1306?= =?UTF-8?q?=20=E5=B1=8F=E5=B9=95=E6=98=BE=E7=A4=BA=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20(#143)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 支持 ESP32 系列开发板: DevKitC / NodeMcu-32S / GoouuuESP32 / ESP32 DoIt / ESP-32S 2. 注意: 非ESP32-C3 / 非ESP32-S3 --- main/boards/bread-compact-esp32/config.h | 6 ++++ .../bread-compact-esp32/esp32_bread_board.cc | 29 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/main/boards/bread-compact-esp32/config.h b/main/boards/bread-compact-esp32/config.h index 4b131527..aef02003 100644 --- a/main/boards/bread-compact-esp32/config.h +++ b/main/boards/bread-compact-esp32/config.h @@ -32,5 +32,11 @@ #define TOUCH_BUTTON_GPIO GPIO_NUM_5 #define BUILTIN_LED_GPIO GPIO_NUM_2 +#define DISPLAY_SDA_PIN GPIO_NUM_4 +#define DISPLAY_SCL_PIN GPIO_NUM_15 +#define DISPLAY_WIDTH 128 +#define DISPLAY_HEIGHT 64 +#define DISPLAY_MIRROR_X true +#define DISPLAY_MIRROR_Y true #endif // _BOARD_CONFIG_H_ diff --git a/main/boards/bread-compact-esp32/esp32_bread_board.cc b/main/boards/bread-compact-esp32/esp32_bread_board.cc index 6bbb2511..34dc95f1 100644 --- a/main/boards/bread-compact-esp32/esp32_bread_board.cc +++ b/main/boards/bread-compact-esp32/esp32_bread_board.cc @@ -6,18 +6,38 @@ #include "config.h" #include "iot/thing_manager.h" #include "led/single_led.h" - +#include "display/ssd1306_display.h" #include #include #include #define TAG "ESP32-MarsbearSupport" +LV_FONT_DECLARE(font_puhui_14_1); +LV_FONT_DECLARE(font_awesome_14_1); + class CompactWifiBoard : public WifiBoard { private: Button boot_button_; Button touch_button_; + i2c_master_bus_handle_t display_i2c_bus_; + + void InitializeDisplayI2c() { + i2c_master_bus_config_t bus_config = { + .i2c_port = (i2c_port_t)0, + .sda_io_num = DISPLAY_SDA_PIN, + .scl_io_num = DISPLAY_SCL_PIN, + .clk_source = I2C_CLK_SRC_DEFAULT, + .glitch_ignore_cnt = 7, + .intr_priority = 0, + .trans_queue_depth = 0, + .flags = { + .enable_internal_pullup = 1, + }, + }; + ESP_ERROR_CHECK(i2c_new_master_bus(&bus_config, &display_i2c_bus_)); + } void InitializeButtons() { @@ -59,6 +79,7 @@ private: public: CompactWifiBoard() : boot_button_(BOOT_BUTTON_GPIO), touch_button_(TOUCH_BUTTON_GPIO) { + InitializeDisplayI2c(); InitializeButtons(); InitializeIot(); } @@ -75,6 +96,12 @@ public: return &audio_codec; } + virtual Display* GetDisplay() override { + static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, + &font_puhui_14_1, &font_awesome_14_1); + return &display; + } + }; DECLARE_BOARD(CompactWifiBoard);