Fix up set windowing and add way to get current window.

This commit is contained in:
Kwabena W. Agyeman 2020-02-17 18:35:10 -08:00
parent 1a344bd9cd
commit f02a16ef3d
2 changed files with 15 additions and 3 deletions

View File

@ -243,7 +243,8 @@ static mp_obj_t py_sensor_get_framesize() {
return mp_obj_new_int(sensor.framesize);
}
static mp_obj_t py_sensor_set_windowing(mp_obj_t roi_obj) {
static mp_obj_t py_sensor_set_windowing(mp_obj_t roi_obj)
{
int x, y, w, h;
int res_w = resolution[sensor.framesize][0];
int res_h = resolution[sensor.framesize][1];
@ -278,10 +279,18 @@ static mp_obj_t py_sensor_set_windowing(mp_obj_t roi_obj) {
}
if (sensor_set_windowing(x, y, w, h) != 0) {
return mp_const_false;
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Failed to set windowing!"));
}
return mp_const_true;
return mp_const_none;
}
static mp_obj_t py_sensor_get_windowing()
{
return mp_obj_new_tuple(4, (mp_obj_t []) {mp_obj_new_int(MAIN_FB()->x),
mp_obj_new_int(MAIN_FB()->y),
mp_obj_new_int(MAIN_FB()->u),
mp_obj_new_int(MAIN_FB()->v)});
}
static mp_obj_t py_sensor_set_gainceiling(mp_obj_t gainceiling) {
@ -684,6 +693,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_framerate_obj, py_sensor_se
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_framesize_obj, py_sensor_set_framesize);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_get_framesize_obj, py_sensor_get_framesize);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_windowing_obj, py_sensor_set_windowing);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_get_windowing_obj, py_sensor_get_windowing);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_gainceiling_obj, py_sensor_set_gainceiling);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_contrast_obj, py_sensor_set_contrast);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_sensor_set_brightness_obj, py_sensor_set_brightness);
@ -812,6 +822,7 @@ STATIC const mp_map_elem_t globals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_framesize), (mp_obj_t)&py_sensor_set_framesize_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_get_framesize), (mp_obj_t)&py_sensor_get_framesize_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_windowing), (mp_obj_t)&py_sensor_set_windowing_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_get_windowing), (mp_obj_t)&py_sensor_get_windowing_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_gainceiling), (mp_obj_t)&py_sensor_set_gainceiling_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_contrast), (mp_obj_t)&py_sensor_set_contrast_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_brightness), (mp_obj_t)&py_sensor_set_brightness_obj },

View File

@ -253,6 +253,7 @@ Q(get_framesize)
Q(set_vsync_output)
Q(set_binning)
Q(set_windowing)
Q(get_windowing)
Q(set_gainceiling)
Q(set_contrast)
Q(set_brightness)