Compare commits
17 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2758089a06 | |||
| 2cd2a6d69f | |||
| 2710e44802 | |||
|
|
4ff7f348d0 | ||
|
|
d117548c22 | ||
|
|
7e51ff74b9 | ||
|
|
80b5754456 | ||
|
|
54c3f61c86 | ||
|
|
7613e49686 | ||
|
|
28804391c0 | ||
|
|
524ba7e0d2 | ||
|
|
86627584ef | ||
|
|
a12beb9bdb | ||
|
|
476bdc8ec6 | ||
|
|
2c75c07b44 | ||
|
|
0018898510 | ||
|
|
6c31a4dccd |
9 changed files with 73 additions and 23 deletions
|
|
@ -406,6 +406,9 @@ esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint
|
|||
#if CONFIG_CAMERA_CORE0
|
||||
xTaskCreatePinnedToCore(cam_task, "cam_task", CAM_TASK_STACK, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 0);
|
||||
#elif CONFIG_CAMERA_CORE1
|
||||
#if CONFIG_FREERTOS_UNICORE
|
||||
#error "Cannot pin to core 1 on unicore"
|
||||
#endif
|
||||
xTaskCreatePinnedToCore(cam_task, "cam_task", CAM_TASK_STACK, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 1);
|
||||
#else
|
||||
xTaskCreate(cam_task, "cam_task", CAM_TASK_STACK, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle);
|
||||
|
|
@ -507,3 +510,10 @@ void cam_give(camera_fb_t *dma_buffer)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool cam_avail(void)
|
||||
{
|
||||
camera_fb_t *dma_buffer = NULL;
|
||||
BaseType_t result = xQueuePeek(cam_obj->frame_buffer_queue, (void *)&dma_buffer, 0);
|
||||
return result != pdFALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out
|
|||
|
||||
ESP_LOGD(TAG, "Doing SW reset of sensor");
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
|
||||
|
||||
return s_state->sensor.reset(&s_state->sensor);
|
||||
err :
|
||||
CAMERA_DISABLE_OUT_CLOCK();
|
||||
|
|
@ -350,14 +350,25 @@ esp_err_t esp_camera_deinit()
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define FB_GET_TIMEOUT (4000 / portTICK_PERIOD_MS)
|
||||
#define FB_GET_TIMEOUT (4000)
|
||||
|
||||
camera_fb_t *esp_camera_fb_get()
|
||||
bool esp_camera_fb_available() {
|
||||
if (s_state == NULL) {
|
||||
return false;
|
||||
}
|
||||
return cam_avail();
|
||||
}
|
||||
|
||||
camera_fb_t *esp_camera_fb_get(void)
|
||||
{
|
||||
return esp_camera_fb_get_timeout(FB_GET_TIMEOUT);
|
||||
}
|
||||
|
||||
camera_fb_t *esp_camera_fb_get_timeout(int timeout) {
|
||||
if (s_state == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
camera_fb_t *fb = cam_take(FB_GET_TIMEOUT);
|
||||
camera_fb_t *fb = cam_take(timeout / portTICK_PERIOD_MS);
|
||||
//set the frame properties
|
||||
if (fb) {
|
||||
fb->width = resolution[s_state->sensor.status.framesize].width;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ typedef enum {
|
|||
} camera_grab_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Camera frame buffer location
|
||||
* @brief Camera frame buffer location
|
||||
*/
|
||||
typedef enum {
|
||||
CAMERA_FB_IN_PSRAM, /*!< Frame buffer is placed in external PSRAM */
|
||||
|
|
@ -99,7 +99,7 @@ typedef enum {
|
|||
typedef enum {
|
||||
CONV_DISABLE,
|
||||
RGB565_TO_YUV422,
|
||||
|
||||
|
||||
YUV422_TO_RGB565,
|
||||
YUV422_TO_YUV420
|
||||
} camera_conv_mode_t;
|
||||
|
|
@ -194,14 +194,28 @@ esp_err_t esp_camera_init(const camera_config_t* config);
|
|||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet
|
||||
*/
|
||||
esp_err_t esp_camera_deinit();
|
||||
esp_err_t esp_camera_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Obtain pointer to a frame buffer, with timeout.
|
||||
*
|
||||
* @return pointer to the frame buffer, or NULL if no frame was obtained within the timeout
|
||||
*/
|
||||
camera_fb_t* esp_camera_fb_get_timeout(int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Obtain pointer to a frame buffer.
|
||||
*
|
||||
* @return pointer to the frame buffer
|
||||
*/
|
||||
camera_fb_t* esp_camera_fb_get();
|
||||
camera_fb_t* esp_camera_fb_get(void);
|
||||
|
||||
/**
|
||||
* @brief Check whether a framebuffer is avaiable without blocking
|
||||
*
|
||||
* @return true if available, false otherwise
|
||||
*/
|
||||
bool esp_camera_fb_available(void);
|
||||
|
||||
/**
|
||||
* @brief Return the frame buffer to be reused again.
|
||||
|
|
@ -215,19 +229,19 @@ void esp_camera_fb_return(camera_fb_t * fb);
|
|||
*
|
||||
* @return pointer to the sensor
|
||||
*/
|
||||
sensor_t * esp_camera_sensor_get();
|
||||
sensor_t * esp_camera_sensor_get(void);
|
||||
|
||||
/**
|
||||
* @brief Save camera settings to non-volatile-storage (NVS)
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*/
|
||||
esp_err_t esp_camera_save_to_nvs(const char *key);
|
||||
|
||||
/**
|
||||
* @brief Load camera settings from non-volatile-storage (NVS)
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*/
|
||||
esp_err_t esp_camera_load_from_nvs(const char *key);
|
||||
|
||||
|
|
@ -236,4 +250,3 @@ esp_err_t esp_camera_load_from_nvs(const char *key);
|
|||
#endif
|
||||
|
||||
#include "img_converters.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ void cam_stop(void);
|
|||
|
||||
void cam_start(void);
|
||||
|
||||
bool cam_avail(void);
|
||||
|
||||
camera_fb_t *cam_take(TickType_t timeout);
|
||||
|
||||
void cam_give(camera_fb_t *dma_buffer);
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
||||
#include "esp32-hal-log.h"
|
||||
#else
|
||||
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
||||
#include "esp_log.h"
|
||||
static const char* TAG = "sccb";
|
||||
#endif
|
||||
#include "esp_check.h"
|
||||
|
||||
#define LITTLETOBIG(x) ((x<<8)|(x>>8))
|
||||
|
||||
|
|
@ -48,7 +50,7 @@ static bool sccb_owns_i2c_port;
|
|||
|
||||
int SCCB_Init(int pin_sda, int pin_scl)
|
||||
{
|
||||
ESP_LOGI(TAG, "pin_sda %d pin_scl %d", pin_sda, pin_scl);
|
||||
ESP_LOGI(TAG, "yolo pin_sda %d pin_scl %d", pin_sda, pin_scl);
|
||||
i2c_config_t conf;
|
||||
esp_err_t ret;
|
||||
|
||||
|
|
@ -105,7 +107,7 @@ uint8_t SCCB_Probe(void)
|
|||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, ( slave_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS);
|
||||
esp_err_t ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 50 / portTICK_RATE_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if( ret == ESP_OK) {
|
||||
return slave_addr;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
/**
|
||||
* 2. Kconfig setup
|
||||
*
|
||||
*
|
||||
* If you have a Kconfig file, copy the content from
|
||||
* https://github.com/espressif/esp32-camera/blob/master/Kconfig into it.
|
||||
* In case you haven't, copy and paste this Kconfig file inside the src directory.
|
||||
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
/**
|
||||
* 3. Enable PSRAM on sdkconfig:
|
||||
*
|
||||
*
|
||||
* CONFIG_ESP32_SPIRAM_SUPPORT=y
|
||||
*
|
||||
*
|
||||
* More info on
|
||||
* https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-esp32-spiram-support
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
static const char *TAG = "ov5640";
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
//#define REG_DEBUG_ON
|
||||
|
||||
static int read_reg(uint8_t slv_addr, const uint16_t reg){
|
||||
|
|
@ -790,7 +792,7 @@ static int set_awb_gain_dsp(sensor_t *sensor, int enable)
|
|||
static int set_special_effect(sensor_t *sensor, int effect)
|
||||
{
|
||||
int ret=0;
|
||||
if (effect < 0 || effect > 6) {
|
||||
if (effect < 0 || effect >= ARRAY_SIZE(sensor_special_effects)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ static const DRAM_ATTR uint8_t sensor_saturation_levels[9][11] = {
|
|||
{0x1d, 0x60, 0x03, 0x11, 0xa8, 0xb9, 0xaf, 0x96, 0x19, 0x01, 0x98},//+4
|
||||
};
|
||||
|
||||
static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = {
|
||||
static const DRAM_ATTR uint8_t sensor_special_effects[][4] = {
|
||||
{0x06, 0x40, 0x2c, 0x08},//Normal
|
||||
{0x46, 0x40, 0x28, 0x08},//Negative
|
||||
{0x1e, 0x80, 0x80, 0x08},//Grayscale
|
||||
|
|
@ -256,6 +256,7 @@ static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = {
|
|||
{0x1e, 0x60, 0x60, 0x08},//Green Tint
|
||||
{0x1e, 0xa0, 0x40, 0x08},//Blue Tint
|
||||
{0x1e, 0x40, 0xa0, 0x08},//Sepia
|
||||
{0x06, 0x40, 0x2c, 0x09},//Solarize
|
||||
};
|
||||
|
||||
static const DRAM_ATTR uint16_t sensor_regs_gamma0[][2] = {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
static const char* TAG = "camera_xclk";
|
||||
#endif
|
||||
|
||||
static ledc_channel_t g_ledc_channel = 0;
|
||||
#define NO_CAMERA_LEDC_CHANNEL 0xFF
|
||||
static ledc_channel_t g_ledc_channel = NO_CAMERA_LEDC_CHANNEL;
|
||||
|
||||
esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz)
|
||||
{
|
||||
|
|
@ -35,6 +36,11 @@ esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz)
|
|||
|
||||
esp_err_t camera_enable_out_clock(camera_config_t* config)
|
||||
{
|
||||
if (config->ledc_channel == NO_CAMERA_LEDC_CHANNEL) {
|
||||
g_ledc_channel = NO_CAMERA_LEDC_CHANNEL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t err = xclk_timer_conf(config->ledc_timer, config->xclk_freq_hz);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "ledc_timer_config failed, rc=%x", err);
|
||||
|
|
@ -60,5 +66,8 @@ esp_err_t camera_enable_out_clock(camera_config_t* config)
|
|||
|
||||
void camera_disable_out_clock()
|
||||
{
|
||||
ledc_stop(LEDC_LOW_SPEED_MODE, g_ledc_channel, 0);
|
||||
if (g_ledc_channel != NO_CAMERA_LEDC_CHANNEL) {
|
||||
ledc_stop(LEDC_LOW_SPEED_MODE, g_ledc_channel, 0);
|
||||
g_ledc_channel = NO_CAMERA_LEDC_CHANNEL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue