- Added camera config

- Removed some not working framesizes
- Restart handling
This commit is contained in:
Rene Zeldenthuis
2022-07-05 13:21:17 +02:00
parent d9462f3a2f
commit 6a27f0f635
4 changed files with 103 additions and 66 deletions

28
include/camera_config.h Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include <string.h>
#include <sensor.h>
typedef char camera_config_name_t[18];
typedef struct camera_config_entry
{
const camera_config_name_t name;
const camera_config_t config;
} camera_config_entry_t;
constexpr const camera_config_entry_t camera_configs[] = {
{"ESP32CAM", {.pin_pwdn = -1, .pin_reset = 15, .pin_xclk = 27, .pin_sscb_sda = 25, .pin_sscb_scl = 23, .pin_d7 = 19, .pin_d6 = 36, .pin_d5 = 18, .pin_d4 = 39, .pin_d3 = 5, .pin_d2 = 34, .pin_d1 = 35, .pin_d0 = 17, .pin_vsync = 22, .pin_href = 26, .pin_pclk = 21, .xclk_freq_hz = 20000000, .ledc_timer = LEDC_TIMER_0, .ledc_channel = LEDC_CHANNEL_0, .pixel_format = PIXFORMAT_JPEG, .frame_size = FRAMESIZE_SVGA, .jpeg_quality = 12, .fb_count = 2}},
{"AI THINKER", {.pin_pwdn = 32, .pin_reset = -1, .pin_xclk = 0, .pin_sscb_sda = 26, .pin_sscb_scl = 27, .pin_d7 = 35, .pin_d6 = 34, .pin_d5 = 39, .pin_d4 = 36, .pin_d3 = 21, .pin_d2 = 19, .pin_d1 = 18, .pin_d0 = 5, .pin_vsync = 25, .pin_href = 23, .pin_pclk = 22, .xclk_freq_hz = 20000000, .ledc_timer = LEDC_TIMER_1, .ledc_channel = LEDC_CHANNEL_1, .pixel_format = PIXFORMAT_JPEG, .frame_size = FRAMESIZE_SVGA, .jpeg_quality = 12, .fb_count = 2}},
{"TTGO T-CAM", {.pin_pwdn = 26, .pin_reset = -1, .pin_xclk = 32, .pin_sscb_sda = 13, .pin_sscb_scl = 12, .pin_d7 = 39, .pin_d6 = 36, .pin_d5 = 23, .pin_d4 = 18, .pin_d3 = 15, .pin_d2 = 4, .pin_d1 = 14, .pin_d0 = 5, .pin_vsync = 27, .pin_href = 25, .pin_pclk = 19, .xclk_freq_hz = 20000000, .ledc_timer = LEDC_TIMER_0, .ledc_channel = LEDC_CHANNEL_0, .pixel_format = PIXFORMAT_JPEG, .frame_size = FRAMESIZE_SVGA, .jpeg_quality = 12, .fb_count = 2}}};
const camera_config_t lookup_camera_config(const char *pin)
{
// Lookup table for the frame name to framesize_t
for (const auto &entry : camera_configs)
if (strncmp(entry.name, pin, sizeof(camera_config_name_t)) == 0)
return entry.config;
return camera_config_t{};
}

View File

@@ -7,13 +7,11 @@ typedef char frame_size_name_t[18];
typedef struct frame_size_entry
{
frame_size_name_t name;
framesize_t frame_size;
const frame_size_name_t name;
const framesize_t frame_size;
} frame_size_entry_t;
constexpr const frame_size_entry_t frame_sizes[] = {
{"96x96", FRAMESIZE_96X96},
{"QQVGA (160x120)", FRAMESIZE_QQVGA},
{"QCIF (176x144)", FRAMESIZE_QCIF},
{"HQVGA (240x176)", FRAMESIZE_HQVGA},
@@ -26,28 +24,14 @@ constexpr const frame_size_entry_t frame_sizes[] = {
{"XGA (1024x768)", FRAMESIZE_XGA},
{"HD (1280x720)", FRAMESIZE_HD},
{"SXGA (1280x1024)", FRAMESIZE_SXGA},
{"UXGA (1600x1200)", FRAMESIZE_UXGA},
{"FHD (1920x1080)", FRAMESIZE_FHD},
{"P HD (2560x1440)", FRAMESIZE_P_HD},
{"P 3MP (2560x1600)", FRAMESIZE_P_3MP},
{"QXGA (2560x1920)", FRAMESIZE_QXGA},
{"QHD (2560x1440)", FRAMESIZE_QHD},
{"WQXGA (2560x1600)", FRAMESIZE_WQXGA},
{"P FHD (1080x1920)", FRAMESIZE_P_FHD},
{"QSXGA (2560x1920)", FRAMESIZE_QSXGA},
{"", FRAMESIZE_INVALID}};
{"UXGA (1600x1200)", FRAMESIZE_UXGA}};
framesize_t lookup_frame_size(const char *pin)
const framesize_t lookup_frame_size(const char *pin)
{
// Lookup table for the frame name to framesize_t
auto entry = &frame_sizes[0];
while (*entry->name)
{
if (strncmp(entry->name, pin, sizeof(frame_size_name_t)) == 0)
return entry->frame_size;
entry++;
}
for (const auto &entry : frame_sizes)
if (strncmp(entry.name, pin, sizeof(frame_size_name_t)) == 0)
return entry.frame_size;
return FRAMESIZE_INVALID;
}

View File

@@ -5,8 +5,10 @@
#define WIFI_SSID "ESP32CAM-RTSP"
#define WIFI_PASSWORD nullptr
#define CONFIG_VERSION "1.1"
#define CONFIG_VERSION "1.0"
#define RTSP_PORT 554
#define DEFAULT_CAMERA_CONFIG "AI THINKER"
#define DEFAULT_FRAMERATE "20"
#define DEFAULT_FRAMESIZE "SVGA (800x600)"
#define DEFAULT_FRAMESIZE "SVGA (800x600)"
#define DEFAULT_JPEG_QUALITY "12"