54 lines
2.1 KiB
C
54 lines
2.1 KiB
C
// camera_mgr.h — OV2640 lifecycle.
|
|
//
|
|
// Unlike the battery design in SPEC §4.3, the camera stays initialised for the
|
|
// life of the boot. That removes the 300-600 ms sensor init and auto-exposure
|
|
// settle from the trigger path entirely (SPEC C4) and is what makes the
|
|
// pre-trigger ring possible.
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <esp_camera.h>
|
|
|
|
bool cameraBegin();
|
|
void cameraEnd();
|
|
bool cameraRestart(); // after a frame_size change
|
|
|
|
// Push the current g_cfg (quality, flip, mirror) plus the active tuning
|
|
// profile onto a running sensor. Frame size is deliberately excluded — see
|
|
// configNeedsCameraRestart().
|
|
void cameraApplyConfig();
|
|
|
|
// Apply the day or night tuning profile. Called on dusk/dawn transitions and
|
|
// whenever the endpoint pushes new tuning.
|
|
void cameraApplyTuning(bool night);
|
|
|
|
// Which profile is currently loaded.
|
|
bool cameraNightProfileActive();
|
|
|
|
// --- frame sizes ------------------------------------------------------------
|
|
// Resolutions are configured BY NAME ("SVGA", "UXGA"), not by the numeric
|
|
// framesize_t index, and these two functions are the only place the mapping
|
|
// lives. The reason is not cosmetic: esp32-camera has inserted entries into
|
|
// framesize_t between releases — FRAMESIZE_128X128 and FRAMESIZE_320X320 were
|
|
// added mid-enum — so a hardcoded index silently means a different resolution
|
|
// after a driver update. The tables below are built from the enum symbols, so
|
|
// they stay correct by construction.
|
|
//
|
|
// Numeric values are still accepted from the endpoint for compatibility, but
|
|
// names are what the settings UI should send.
|
|
uint8_t framesizeFromName(const char* name, uint8_t fallback);
|
|
const char* framesizeName(uint8_t fs);
|
|
void framesizeDims(uint8_t fs, uint16_t* w, uint16_t* h);
|
|
|
|
// Temporarily switch resolution for a streaming session, then put it back.
|
|
bool cameraSetFrameSize(uint8_t framesize);
|
|
|
|
// Grab one JPEG. Returns nullptr on failure. Caller must esp_camera_fb_return().
|
|
camera_fb_t* cameraGrab();
|
|
|
|
// Throw away the first frames after init so auto-exposure has settled before
|
|
// anything is uploaded (SPEC C4).
|
|
void cameraDiscardFrames(uint8_t n);
|
|
|
|
bool cameraReady();
|