forked from xiaozhi/xiaozhi-esp32
增加LilyGo T-CameraPlus-S3的摄像头红外过滤功能 (#766)
* 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
This commit is contained in:
@@ -51,4 +51,6 @@
|
||||
#define DISPLAY_BACKLIGHT_PIN DISPLAY_BL
|
||||
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
|
||||
|
||||
#define AP1511B_GPIO static_cast<gpio_num_t>(AP1511B_FBC)
|
||||
|
||||
#endif // _BOARD_CONFIG_H_
|
||||
|
||||
44
main/boards/lilygo-t-cameraplus-s3/ir_filter_controller.h
Normal file
44
main/boards/lilygo-t-cameraplus-s3/ir_filter_controller.h
Normal file
@@ -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__
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "sy6970.h"
|
||||
#include "pin_config.h"
|
||||
#include "esp32_camera.h"
|
||||
#include "ir_filter_controller.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <esp_lcd_panel_vendor.h>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user