diff --git a/main/boards/lilygo-t-cameraplus-s3/config.h b/main/boards/lilygo-t-cameraplus-s3/config.h index c8a586e6dd..f87888a4a6 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 0000000000..3ae619adb1 --- /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 971af798f6..b2c1ddcf8f 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 @@ class LilygoTCameraPlusS3Board : public WifiBoard { 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 d624dc8a7f..c88bbaef74 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 @@ class LilygoTCircleS3Board : public WifiBoard { }); } - // 物联网初始化,添加对 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 @@ class LilygoTCircleS3Board : public WifiBoard { 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 b79c35c413..9ea8bff3e6 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 @@ class LilygoTDisplays3ProMVSRLoraBoard : public WifiBoard { }); } - // 物联网初始化,添加对 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 @@ class LilygoTDisplays3ProMVSRLoraBoard : public WifiBoard { 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(); }