Merge pull request #1353 from kwagyeman/kwabena/disable_auto_flush

Add disable full flush logic
This commit is contained in:
Ibrahim Abd Elkader 2021-06-09 19:04:01 +02:00 committed by GitHub
commit a3c7d65f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View File

@ -168,6 +168,7 @@ typedef struct _sensor {
uint16_t gs_bpp; // Grayscale bytes per pixel.
uint32_t hw_flags; // Hardware flags (clock polarities/hw capabilities)
const uint16_t *color_palette; // Color palette used for color lookup.
bool disable_full_flush; // Turn off default frame buffer flush policy when full.
vsync_cb_t vsync_callback; // VSYNC callback.
frame_cb_t frame_callback; // Frame callback.

View File

@ -568,6 +568,16 @@ static mp_obj_t py_sensor_get_framebuffers()
return mp_obj_new_int(framebuffer->n_buffers);
}
static mp_obj_t py_sensor_disable_full_flush(uint n_args, const mp_obj_t *args)
{
if (!n_args) {
return mp_obj_new_bool(sensor.disable_full_flush);
}
sensor.disable_full_flush = mp_obj_get_int(args[0]);
return mp_const_none;
}
static mp_obj_t py_sensor_set_special_effect(mp_obj_t sde)
{
if (sensor_set_special_effect(mp_obj_get_int(sde)) != 0) {
@ -985,6 +995,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_auto_rotation_obj, py_sensor_se
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_get_auto_rotation_obj, py_sensor_get_auto_rotation);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_framebuffers_obj, py_sensor_set_framebuffers);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_get_framebuffers_obj, py_sensor_get_framebuffers);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(py_sensor_disable_full_flush_obj, 0, 1, py_sensor_disable_full_flush);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_special_effect_obj, py_sensor_set_special_effect);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_sensor_set_lens_correction_obj, py_sensor_set_lens_correction);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_vsync_callback_obj, py_sensor_set_vsync_callback);
@ -1148,6 +1159,7 @@ STATIC const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_get_auto_rotation), (mp_obj_t)&py_sensor_get_auto_rotation_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_framebuffers), (mp_obj_t)&py_sensor_set_framebuffers_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_get_framebuffers), (mp_obj_t)&py_sensor_get_framebuffers_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable_full_flush), (mp_obj_t)&py_sensor_disable_full_flush_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_special_effect), (mp_obj_t)&py_sensor_set_special_effect_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_lens_correction), (mp_obj_t)&py_sensor_set_lens_correction_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_vsync_callback), (mp_obj_t)&py_sensor_set_vsync_callback_obj },

View File

@ -434,6 +434,8 @@ int sensor_reset()
// Reset default color palette.
sensor.color_palette = rainbow_table;
sensor.disable_full_flush = false;
// Restore shutdown state on reset.
sensor_shutdown(false);

View File

@ -582,6 +582,8 @@ int sensor_reset()
// Reset default color palette.
sensor.color_palette = rainbow_table;
sensor.disable_full_flush = false;
// Restore shutdown state on reset.
sensor_shutdown(false);
@ -1314,7 +1316,9 @@ void DCMI_DMAConvCpltUser(uint32_t addr)
__HAL_DCMI_DISABLE_IT(&DCMIHandle, DCMI_IT_FRAME);
__HAL_DCMI_CLEAR_FLAG(&DCMIHandle, DCMI_FLAG_FRAMERI);
// Reset the queue of frames when we start dropping frames.
framebuffer_flush_buffers();
if (!sensor.disable_full_flush) {
framebuffer_flush_buffers();
}
return;
}
@ -1634,7 +1638,7 @@ int sensor_snapshot(sensor_t *sensor, image_t *image, uint32_t flags)
// Get the destination buffer address.
vbuffer_t *buffer = framebuffer_get_tail(FB_PEEK);
if (!buffer) {
if ((sensor->pixformat == PIXFORMAT_JPEG) && (sensor->chip_id == OV2640_ID) && (!buffer)) {
return -3;
}