mirror of
https://github.com/esphome/esphome.git
synced 2025-07-27 21:56:34 +00:00
esp32cam: add fb location config option (#9630)
This commit is contained in:
parent
cb8d9dca2a
commit
08407706aa
@ -119,6 +119,12 @@ ENUM_SPECIAL_EFFECT = {
|
||||
"SEPIA": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_SEPIA,
|
||||
}
|
||||
|
||||
camera_fb_location_t = cg.global_ns.enum("camera_fb_location_t")
|
||||
ENUM_FB_LOCATION = {
|
||||
"PSRAM": cg.global_ns.CAMERA_FB_IN_PSRAM,
|
||||
"DRAM": cg.global_ns.CAMERA_FB_IN_DRAM,
|
||||
}
|
||||
|
||||
# pin assignment
|
||||
CONF_HREF_PIN = "href_pin"
|
||||
CONF_PIXEL_CLOCK_PIN = "pixel_clock_pin"
|
||||
@ -149,6 +155,7 @@ CONF_MAX_FRAMERATE = "max_framerate"
|
||||
CONF_IDLE_FRAMERATE = "idle_framerate"
|
||||
# frame buffer
|
||||
CONF_FRAME_BUFFER_COUNT = "frame_buffer_count"
|
||||
CONF_FRAME_BUFFER_LOCATION = "frame_buffer_location"
|
||||
|
||||
# stream trigger
|
||||
CONF_ON_STREAM_START = "on_stream_start"
|
||||
@ -230,6 +237,9 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.framerate, cv.Range(min=0, max=1)
|
||||
),
|
||||
cv.Optional(CONF_FRAME_BUFFER_COUNT, default=1): cv.int_range(min=1, max=2),
|
||||
cv.Optional(CONF_FRAME_BUFFER_LOCATION, default="PSRAM"): cv.enum(
|
||||
ENUM_FB_LOCATION, upper=True
|
||||
),
|
||||
cv.Optional(CONF_ON_STREAM_START): automation.validate_automation(
|
||||
{
|
||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
||||
@ -301,6 +311,7 @@ SETTERS = {
|
||||
CONF_WB_MODE: "set_wb_mode",
|
||||
# test pattern
|
||||
CONF_TEST_PATTERN: "set_test_pattern",
|
||||
CONF_FRAME_BUFFER_LOCATION: "set_frame_buffer_location",
|
||||
}
|
||||
|
||||
|
||||
@ -328,6 +339,7 @@ async def to_code(config):
|
||||
else:
|
||||
cg.add(var.set_idle_update_interval(1000 / config[CONF_IDLE_FRAMERATE]))
|
||||
cg.add(var.set_frame_buffer_count(config[CONF_FRAME_BUFFER_COUNT]))
|
||||
cg.add(var.set_frame_buffer_location(config[CONF_FRAME_BUFFER_LOCATION]))
|
||||
cg.add(var.set_frame_size(config[CONF_RESOLUTION]))
|
||||
|
||||
cg.add_define("USE_CAMERA")
|
||||
|
@ -133,6 +133,7 @@ void ESP32Camera::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" JPEG Quality: %u\n"
|
||||
" Framebuffer Count: %u\n"
|
||||
" Framebuffer Location: %s\n"
|
||||
" Contrast: %d\n"
|
||||
" Brightness: %d\n"
|
||||
" Saturation: %d\n"
|
||||
@ -140,8 +141,9 @@ void ESP32Camera::dump_config() {
|
||||
" Horizontal Mirror: %s\n"
|
||||
" Special Effect: %u\n"
|
||||
" White Balance Mode: %u",
|
||||
st.quality, conf.fb_count, st.contrast, st.brightness, st.saturation, ONOFF(st.vflip),
|
||||
ONOFF(st.hmirror), st.special_effect, st.wb_mode);
|
||||
st.quality, conf.fb_count, this->config_.fb_location == CAMERA_FB_IN_PSRAM ? "PSRAM" : "DRAM",
|
||||
st.contrast, st.brightness, st.saturation, ONOFF(st.vflip), ONOFF(st.hmirror), st.special_effect,
|
||||
st.wb_mode);
|
||||
// ESP_LOGCONFIG(TAG, " Auto White Balance: %u", st.awb);
|
||||
// ESP_LOGCONFIG(TAG, " Auto White Balance Gain: %u", st.awb_gain);
|
||||
ESP_LOGCONFIG(TAG,
|
||||
@ -350,6 +352,9 @@ void ESP32Camera::set_frame_buffer_count(uint8_t fb_count) {
|
||||
this->config_.fb_count = fb_count;
|
||||
this->set_frame_buffer_mode(fb_count > 1 ? CAMERA_GRAB_LATEST : CAMERA_GRAB_WHEN_EMPTY);
|
||||
}
|
||||
void ESP32Camera::set_frame_buffer_location(camera_fb_location_t fb_location) {
|
||||
this->config_.fb_location = fb_location;
|
||||
}
|
||||
|
||||
/* ---------------- public API (specific) ---------------- */
|
||||
void ESP32Camera::add_image_callback(std::function<void(std::shared_ptr<camera::CameraImage>)> &&callback) {
|
||||
|
@ -152,6 +152,7 @@ class ESP32Camera : public camera::Camera {
|
||||
/* -- frame buffer */
|
||||
void set_frame_buffer_mode(camera_grab_mode_t mode);
|
||||
void set_frame_buffer_count(uint8_t fb_count);
|
||||
void set_frame_buffer_location(camera_fb_location_t fb_location);
|
||||
|
||||
/* public API (derivated) */
|
||||
void setup() override;
|
||||
|
@ -22,6 +22,7 @@ esp32_camera:
|
||||
power_down_pin: 1
|
||||
resolution: 640x480
|
||||
jpeg_quality: 10
|
||||
frame_buffer_location: PSRAM
|
||||
on_image:
|
||||
then:
|
||||
- lambda: |-
|
||||
|
Loading…
x
Reference in New Issue
Block a user