mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
sensors/ov5640: Add night mode control.
This commit is contained in:
parent
25d4f197c1
commit
53d69d3473
@ -707,14 +707,13 @@ static mp_obj_t py_sensor_ioctl(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (OMV_ENABLE_OV7725 == 1)
|
||||
case IOCTL_SET_NIGHT_MODE: {
|
||||
if (n_args >= 2) {
|
||||
error = sensor_ioctl(request, mp_obj_get_int(args[1]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case IOCTL_GET_NIGHT_MODE: {
|
||||
int enabled;
|
||||
error = sensor_ioctl(request, &enabled);
|
||||
@ -723,7 +722,6 @@ static mp_obj_t py_sensor_ioctl(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case IOCTL_LEPTON_GET_WIDTH: {
|
||||
int width;
|
||||
@ -1100,10 +1098,8 @@ STATIC const mp_map_elem_t globals_dict_table[] = {
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_RESET_AUTO_FOCUS), MP_OBJ_NEW_SMALL_INT(IOCTL_RESET_AUTO_FOCUS)},
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_WAIT_ON_AUTO_FOCUS), MP_OBJ_NEW_SMALL_INT(IOCTL_WAIT_ON_AUTO_FOCUS)},
|
||||
#endif
|
||||
#if (OMV_ENABLE_OV7725 == 1)
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_SET_NIGHT_MODE), MP_OBJ_NEW_SMALL_INT(IOCTL_SET_NIGHT_MODE)},
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_GET_NIGHT_MODE), MP_OBJ_NEW_SMALL_INT(IOCTL_GET_NIGHT_MODE)},
|
||||
#endif
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_LEPTON_GET_WIDTH), MP_OBJ_NEW_SMALL_INT(IOCTL_LEPTON_GET_WIDTH)},
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_LEPTON_GET_HEIGHT), MP_OBJ_NEW_SMALL_INT(IOCTL_LEPTON_GET_HEIGHT)},
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_LEPTON_GET_RADIOMETRY), MP_OBJ_NEW_SMALL_INT(IOCTL_LEPTON_GET_RADIOMETRY)},
|
||||
|
||||
@ -1326,6 +1326,7 @@ static int set_lens_correction(sensor_t *sensor, int enable, int radi, int coef)
|
||||
|
||||
static int ioctl(sensor_t *sensor, int request, va_list ap) {
|
||||
int ret = 0;
|
||||
uint8_t reg;
|
||||
|
||||
switch (request) {
|
||||
case IOCTL_SET_READOUT_WINDOW: {
|
||||
@ -1371,7 +1372,6 @@ static int ioctl(sensor_t *sensor, int request, va_list ap) {
|
||||
case IOCTL_WAIT_ON_AUTO_FOCUS: {
|
||||
mp_uint_t start_tick = mp_hal_ticks_ms(), delay_ms = va_arg(ap, uint32_t);
|
||||
for (;;) {
|
||||
uint8_t reg;
|
||||
ret = omv_i2c_readb2(&sensor->i2c_bus, sensor->slv_addr, AF_CMD_ACK, ®);
|
||||
if ((ret < 0) || (!reg)) {
|
||||
break;
|
||||
@ -1384,6 +1384,21 @@ static int ioctl(sensor_t *sensor, int request, va_list ap) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case IOCTL_SET_NIGHT_MODE: {
|
||||
int enable = va_arg(ap, int);
|
||||
ret = omv_i2c_readb2(&sensor->i2c_bus, sensor->slv_addr, AEC_CTRL_00, ®);
|
||||
ret |= omv_i2c_writeb2(&sensor->i2c_bus, sensor->slv_addr, AEC_CTRL_00,
|
||||
(reg & 0xFB) | ((enable != 0) << 2));
|
||||
break;
|
||||
}
|
||||
case IOCTL_GET_NIGHT_MODE: {
|
||||
int *enable = va_arg(ap, int *);
|
||||
ret = omv_i2c_readb2(&sensor->i2c_bus, sensor->slv_addr, AEC_CTRL_00, ®);
|
||||
if (ret >= 0) {
|
||||
*enable = reg & 0x4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = -1;
|
||||
break;
|
||||
@ -1435,5 +1450,4 @@ int ov5640_init(sensor_t *sensor) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // (OMV_ENABLE_OV5640 == 1)
|
||||
|
||||
@ -87,6 +87,8 @@
|
||||
#define TIMING_TC_REG_20 0x3820
|
||||
#define TIMING_TC_REG_21 0x3821
|
||||
|
||||
#define AEC_CTRL_00 0x3A00
|
||||
|
||||
#define AEC_GAIN_CEILING_H 0x3A18
|
||||
#define AEC_GAIN_CEILING_L 0x3A18
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user