Store/Retrieve pixformat to/from NVS
This commit is contained in:
@@ -70,6 +70,7 @@ typedef enum {
|
|||||||
static const char* TAG = "camera";
|
static const char* TAG = "camera";
|
||||||
#endif
|
#endif
|
||||||
static const char* CAMERA_SENSOR_NVS_KEY = "sensor";
|
static const char* CAMERA_SENSOR_NVS_KEY = "sensor";
|
||||||
|
static const char* CAMERA_PIXFORMAT_NVS_KEY = "pixformat";
|
||||||
|
|
||||||
typedef void (*dma_filter_t)(const dma_elem_t* src, lldesc_t* dma_desc, uint8_t* dst);
|
typedef void (*dma_filter_t)(const dma_elem_t* src, lldesc_t* dma_desc, uint8_t* dst);
|
||||||
|
|
||||||
@@ -1368,6 +1369,10 @@ esp_err_t esp_camera_save_to_nvs(const char *key)
|
|||||||
sensor_t *s = esp_camera_sensor_get();
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
ret = nvs_set_blob(handle,CAMERA_SENSOR_NVS_KEY,&s->status,sizeof(camera_status_t));
|
ret = nvs_set_blob(handle,CAMERA_SENSOR_NVS_KEY,&s->status,sizeof(camera_status_t));
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
uint8_t pf = s->pixformat;
|
||||||
|
ret = nvs_set_u8(handle,CAMERA_PIXFORMAT_NVS_KEY,pf);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
return ESP_ERR_CAMERA_NOT_DETECTED;
|
return ESP_ERR_CAMERA_NOT_DETECTED;
|
||||||
@@ -1382,6 +1387,7 @@ esp_err_t esp_camera_save_to_nvs(const char *key)
|
|||||||
esp_err_t esp_camera_load_from_nvs(const char *key)
|
esp_err_t esp_camera_load_from_nvs(const char *key)
|
||||||
{
|
{
|
||||||
nvs_handle_t handle;
|
nvs_handle_t handle;
|
||||||
|
uint8_t pf;
|
||||||
|
|
||||||
esp_err_t ret = nvs_open(key,NVS_READWRITE,&handle);
|
esp_err_t ret = nvs_open(key,NVS_READWRITE,&handle);
|
||||||
|
|
||||||
@@ -1419,6 +1425,10 @@ esp_err_t esp_camera_load_from_nvs(const char *key)
|
|||||||
s->set_whitebal(s,st.awb);
|
s->set_whitebal(s,st.awb);
|
||||||
s->set_wpc(s,st.wpc);
|
s->set_wpc(s,st.wpc);
|
||||||
}
|
}
|
||||||
|
ret = nvs_get_u8(handle,CAMERA_PIXFORMAT_NVS_KEY,&pf);
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
s->set_pixformat(s,pf);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return ESP_ERR_CAMERA_NOT_DETECTED;
|
return ESP_ERR_CAMERA_NOT_DETECTED;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user