Compare commits

...

17 commits

Author SHA1 Message Date
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
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
9 changed files with 73 additions and 23 deletions

View file

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

View file

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

View file

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

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

@ -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
*/

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

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