From b18dda3f2f8d8bcb4a2796712fc62455d52d5c04 Mon Sep 17 00:00:00 2001 From: yusuhua <57382265+yusuhua@users.noreply.github.com> Date: Fri, 6 Jun 2025 11:18:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0LilyGo=20T-CameraPlus-S3?= =?UTF-8?q?=E7=9A=84=E6=91=84=E5=83=8F=E5=A4=B4=E7=BA=A2=E5=A4=96=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=8A=9F=E8=83=BD=20(#766)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * set camera HMirror to true * change key1 to camera button * change key1 to camera button * change key1 to camera button * add ir filter controller * add ir filter controller * add ir filter controller --- main/boards/lilygo-t-cameraplus-s3/config.h | 2 + .../ir_filter_controller.h | 44 +++++++++++++++++++ .../lilygo-t-cameraplus-s3.cc | 3 ++ .../lilygo-t-circle-s3/lilygo-t-circle-s3.cc | 13 +++--- .../lilygo-t-display-s3-pro-mvsrlora.cc | 13 +++--- 5 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 main/boards/lilygo-t-cameraplus-s3/ir_filter_controller.h diff --git a/main/boards/lilygo-t-cameraplus-s3/config.h b/main/boards/lilygo-t-cameraplus-s3/config.h index c8a586e6..f87888a4 100644 --- a/main/boards/lilygo-t-cameraplus-s3/config.h +++ b/main/boards/lilygo-t-cameraplus-s3/config.h @@ -51,4 +51,6 @@ #define DISPLAY_BACKLIGHT_PIN DISPLAY_BL #define DISPLAY_BACKLIGHT_OUTPUT_INVERT false +#define AP1511B_GPIO static_cast(AP1511B_FBC) + #endif // _BOARD_CONFIG_H_ diff --git a/main/boards/lilygo-t-cameraplus-s3/ir_filter_controller.h b/main/boards/lilygo-t-cameraplus-s3/ir_filter_controller.h new file mode 100644 index 00000000..3ae619ad --- /dev/null +++ b/main/boards/lilygo-t-cameraplus-s3/ir_filter_controller.h @@ -0,0 +1,44 @@ +#ifndef __IR_FILTER_CONTROLLER_H__ +#define __IR_FILTER_CONTROLLER_H__ + +#include "mcp_server.h" + + +class IrFilterController { +private: + bool enable_ = false; + gpio_num_t gpio_num_; + +public: + IrFilterController(gpio_num_t gpio_num) : gpio_num_(gpio_num) { + gpio_config_t config = { + .pin_bit_mask = (1ULL << gpio_num_), + .mode = GPIO_MODE_OUTPUT, + .pull_up_en = GPIO_PULLUP_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE, + }; + ESP_ERROR_CHECK(gpio_config(&config)); + gpio_set_level(gpio_num_, 0); + + auto& mcp_server = McpServer::GetInstance(); + mcp_server.AddTool("self.camera.get_ir_filter_state", "Get the state of the camera's infrared filter", PropertyList(), [this](const PropertyList& properties) -> ReturnValue { + return enable_ ? "{\"enable\": true}" : "{\"enable\": false}"; + }); + + mcp_server.AddTool("self.camera.enable_ir_filter", "Enable the camera's infrared filter", PropertyList(), [this](const PropertyList& properties) -> ReturnValue { + enable_ = true; + gpio_set_level(gpio_num_, 1); + return true; + }); + + mcp_server.AddTool("self.camera.disable_ir_filter", "Disable the camera's infrared filter", PropertyList(), [this](const PropertyList& properties) -> ReturnValue { + enable_ = false; + gpio_set_level(gpio_num_, 0); + return true; + }); + } +}; + + +#endif // __IR_FILTER_CONTROLLER_H__ diff --git a/main/boards/lilygo-t-cameraplus-s3/lilygo-t-cameraplus-s3.cc b/main/boards/lilygo-t-cameraplus-s3/lilygo-t-cameraplus-s3.cc index 971af798..b2c1ddcf 100644 --- a/main/boards/lilygo-t-cameraplus-s3/lilygo-t-cameraplus-s3.cc +++ b/main/boards/lilygo-t-cameraplus-s3/lilygo-t-cameraplus-s3.cc @@ -10,6 +10,7 @@ #include "sy6970.h" #include "pin_config.h" #include "esp32_camera.h" +#include "ir_filter_controller.h" #include #include @@ -292,6 +293,8 @@ public: thing_manager.AddThing(iot::CreateThing("Speaker")); thing_manager.AddThing(iot::CreateThing("Screen")); thing_manager.AddThing(iot::CreateThing("Battery")); +#elif CONFIG_IOT_PROTOCOL_MCP + static IrFilterController irFilter(AP1511B_GPIO); #endif GetBacklight()->RestoreBrightness(); } diff --git a/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc b/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc index d624dc8a..c88bbaef 100644 --- a/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc +++ b/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc @@ -222,13 +222,6 @@ private: }); } - // 物联网初始化,添加对 AI 可见设备 - void InitializeIot() { - auto &thing_manager = iot::ThingManager::GetInstance(); - thing_manager.AddThing(iot::CreateThing("Speaker")); - thing_manager.AddThing(iot::CreateThing("Screen")); - } - public: LilygoTCircleS3Board() : boot_button_(BOOT_BUTTON_GPIO) { InitializePowerSaveTimer(); @@ -238,7 +231,11 @@ public: InitSpi(); InitGc9d01nDisplay(); InitializeButtons(); - InitializeIot(); +#if CONFIG_IOT_PROTOCOL_XIAOZHI + auto &thing_manager = iot::ThingManager::GetInstance(); + thing_manager.AddThing(iot::CreateThing("Speaker")); + thing_manager.AddThing(iot::CreateThing("Screen")); +#endif GetBacklight()->RestoreBrightness(); } diff --git a/main/boards/lilygo-t-display-s3-pro-mvsrlora/lilygo-t-display-s3-pro-mvsrlora.cc b/main/boards/lilygo-t-display-s3-pro-mvsrlora/lilygo-t-display-s3-pro-mvsrlora.cc index b79c35c4..9ea8bff3 100644 --- a/main/boards/lilygo-t-display-s3-pro-mvsrlora/lilygo-t-display-s3-pro-mvsrlora.cc +++ b/main/boards/lilygo-t-display-s3-pro-mvsrlora/lilygo-t-display-s3-pro-mvsrlora.cc @@ -246,13 +246,6 @@ private: }); } - // 物联网初始化,添加对 AI 可见设备 - void InitializeIot() { - auto &thing_manager = iot::ThingManager::GetInstance(); - thing_manager.AddThing(iot::CreateThing("Speaker")); - thing_manager.AddThing(iot::CreateThing("Screen")); - } - public: LilygoTDisplays3ProMVSRLoraBoard() : boot_button_(BOOT_BUTTON_GPIO) { InitializePowerSaveTimer(); @@ -263,7 +256,11 @@ public: InitSpi(); InitSt7796Display(); InitializeButtons(); - InitializeIot(); +#if CONFIG_IOT_PROTOCOL_XIAOZHI + auto &thing_manager = iot::ThingManager::GetInstance(); + thing_manager.AddThing(iot::CreateThing("Speaker")); + thing_manager.AddThing(iot::CreateThing("Screen")); +#endif GetBacklight()->RestoreBrightness(); }