Compare commits

...

23 commits

Author SHA1 Message Date
Scott Shawcroft
d529ebdffb
Merge pull request #8 from tannewt/update_esp_camera_bae46be
Update esp camera bae46be
2024-03-25 13:47:47 -07:00
Scott Shawcroft
9abb23ed43
Merge remote-tracking branch 'espressif/master' into HEAD 2024-03-22 16:19:14 -07:00
Scott Shawcroft
8f3f2cc8cf
Merge pull request #7 from tannewt/merge_esp_camera
Merge esp camera upstream
2023-09-21 10:01:35 -07:00
Scott Shawcroft
e8d500e948
Merge remote-tracking branch 'origin/master' into circuitpython 2023-09-20 14:34:14 -07:00
75035312ed
Merge pull request #6 from adafruit/solarize
Add solarize effect
2023-08-02 10:19:24 -05:00
2758089a06
Add solarize effect
register 0x5003 bit 0 is solarize. needs a change in the pycamera app too.
2023-08-02 08:00:30 -05:00
Scott Shawcroft
68432607d5
Merge pull request #5 from adafruit/faster-probe
Faster probe
2023-08-01 13:14:03 -07:00
2cd2a6d69f
sccb: lower timeout when probing for camera
1000ms is too long. let's try 50ms.
2023-07-26 12:51:06 -05:00
2710e44802
sccb: don't perform an i2c bus scan 2023-07-26 12:50:38 -05:00
Dan Halbert
4ff7f348d0
Merge pull request #4 from deshipu/circuitpython
Make xclk pin optional
2022-12-16 13:43:13 -05:00
Radomir Dopieralski
d117548c22 Make xclk pin optional
Some camera modules come with a crystal oscillator that already provides
the main clock, and they don't have the xclk/mclk pin. We don't need to
initialize the PWM pin then.

(cherry picked from commit 896cb707dd)
2022-12-16 17:13:45 +01:00
Dan Halbert
7e51ff74b9
Merge pull request #2 from MicroDev1/master
Merge upstream updates
2022-09-20 12:15:45 -04:00
microDev
80b5754456
merge upstream updates 2022-09-17 16:10:32 +05:30
Dan Halbert
54c3f61c86
Merge pull request #1 from adafruit/safe-disable_out_clock
don't reset LEDC channel if it wasn't used by camera
2022-09-13 12:49:34 -04:00
Dan Halbert
7613e49686 don't reset LEDC channel if it wasn't used by camera 2022-09-12 21:11:26 -04:00
Jeff Epler
28804391c0 Fix timeout-get accidental recursion 2022-08-01 09:10:35 -05:00
Jeff Epler
524ba7e0d2 Ensure function declarations are prototypes
(this hid a bug)
2022-08-01 09:10:16 -05:00
Jeff Epler
86627584ef Make sure core pinning is not wrong
there's probably a way to do this in kconfig but I don't know it
2022-08-01 09:10:00 -05:00
Jeff Epler
a12beb9bdb wip 2022-07-29 14:23:37 -05:00
Jeff Epler
476bdc8ec6 use new name 2022-07-29 14:19:49 -05:00
Jeff Epler
2c75c07b44 Fix up sccb driver 2022-07-29 14:19:40 -05:00
Jeff Epler
0018898510 Rename to "sscb" for consistency, but support old name via union 2022-07-29 14:19:22 -05:00
Jeff Epler
6c31a4dccd Allow specifying the i2c port to use for sccb
To do this, put NO_PIN (-1) in `pin_sccb_sda` and set `sccb_i2c_port`.
2022-07-28 12:10:55 -05:00
8 changed files with 54 additions and 8 deletions

View file

@ -405,6 +405,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);
@ -530,3 +533,10 @@ void cam_give_all(void) {
cam_obj->frames[x].en = 1;
}
}
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;
}

View file

@ -356,14 +356,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;

View file

@ -202,6 +202,13 @@ esp_err_t esp_camera_init(const camera_config_t* config);
*/
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.
*
@ -209,6 +216,13 @@ esp_err_t esp_camera_deinit(void);
*/
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.
*
@ -248,4 +262,3 @@ void esp_camera_return_all(void);
#endif
#include "img_converters.h"

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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] = {

View file

@ -40,6 +40,11 @@ esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz)
esp_err_t camera_enable_out_clock(const 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);