mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1970 from openmv/sensor_auto_func_fail
modules/py_sensor: Print warning on missing sensor controls.
This commit is contained in:
commit
79a4e169d7
10
.github/workflows/changelog.json
vendored
10
.github/workflows/changelog.json
vendored
@ -24,6 +24,10 @@
|
||||
"title": "## 💾 Drivers",
|
||||
"labels": ["drivers"]
|
||||
},
|
||||
{
|
||||
"title": "## 🧱 Modules",
|
||||
"labels": ["modules"]
|
||||
},
|
||||
{
|
||||
"title": "## 🐍 Micropython",
|
||||
"labels": ["micropython"]
|
||||
@ -93,6 +97,12 @@
|
||||
"target": "$1",
|
||||
"on_property": "title"
|
||||
},
|
||||
{
|
||||
"pattern": "(^modules)(.+)",
|
||||
"method": "replace",
|
||||
"target": "$1",
|
||||
"on_property": "title"
|
||||
},
|
||||
{
|
||||
"pattern": "(^micropython)(.+)",
|
||||
"method": "replace",
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
* Sensor Python module.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
@ -32,6 +33,7 @@ static mp_obj_t vsync_callback = mp_const_none;
|
||||
static mp_obj_t frame_callback = mp_const_none;
|
||||
|
||||
#define sensor_raise_error(err) mp_raise_msg(&mp_type_RuntimeError, (mp_rom_error_text_t) sensor_strerror(err))
|
||||
#define sensor_print_error(op) printf("\x1B[31mWARNING: %s control is not supported by this image sensor.\x1B[0m\n", op);
|
||||
|
||||
#if MICROPY_PY_IMU
|
||||
static void do_auto_rotation(int pitch_deadzone, int roll_activezone) {
|
||||
@ -394,8 +396,11 @@ static mp_obj_t py_sensor_set_auto_gain(uint n_args, const mp_obj_t *args, mp_ma
|
||||
|
||||
int error = sensor_set_auto_gain(enable, gain_db, gain_db_ceiling);
|
||||
if (error != 0) {
|
||||
if (error != SENSOR_ERROR_CTL_UNSUPPORTED) {
|
||||
sensor_raise_error(error);
|
||||
}
|
||||
sensor_print_error("Auto Gain");
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
@ -412,8 +417,11 @@ static mp_obj_t py_sensor_set_auto_exposure(uint n_args, const mp_obj_t *args, m
|
||||
int exposure_us = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_exposure_us), -1);
|
||||
int error = sensor_set_auto_exposure(mp_obj_get_int(args[0]), exposure_us);
|
||||
if (error != 0) {
|
||||
if (error != SENSOR_ERROR_CTL_UNSUPPORTED) {
|
||||
sensor_raise_error(error);
|
||||
}
|
||||
sensor_print_error("Auto Exposure");
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
@ -433,8 +441,11 @@ static mp_obj_t py_sensor_set_auto_whitebal(uint n_args, const mp_obj_t *args, m
|
||||
|
||||
int error = sensor_set_auto_whitebal(enable, rgb_gain_db[0], rgb_gain_db[1], rgb_gain_db[2]);
|
||||
if (error != 0) {
|
||||
if (error != SENSOR_ERROR_CTL_UNSUPPORTED) {
|
||||
sensor_raise_error(error);
|
||||
}
|
||||
sensor_print_error("Auto White Balance");
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
@ -474,8 +485,11 @@ static mp_obj_t py_sensor_set_auto_blc(uint n_args, const mp_obj_t *pos_args, mp
|
||||
|
||||
int error = sensor_set_auto_blc(enable, regs_present ? regs : NULL);
|
||||
if (error != 0) {
|
||||
if (error != SENSOR_ERROR_CTL_UNSUPPORTED) {
|
||||
sensor_raise_error(error);
|
||||
}
|
||||
sensor_print_error("Auto BLC");
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user