summaryrefslogtreecommitdiff
path: root/src/py
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2022-09-30 13:18:12 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-09-30 23:12:05 +0300
commitc97cf467ea79ed886dc549bff6837900427ca11e (patch)
treee6ea3b0bf1b47123100f4827675565290eedbbbc /src/py
parentdaec83536d2ce5be7e1e39fb1db1d07ff22de369 (diff)
py: Support controls that are ControlTypeNone
Such controls can now be created when a control doesn't have a reasonable or obvious default value. We support them using Python's "None" value, rather than generating a runtime error. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Christian Rauch <Rauch.Christian@gmx.de> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/py')
-rw-r--r--src/py/libcamera/py_helpers.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/py/libcamera/py_helpers.cpp b/src/py/libcamera/py_helpers.cpp
index 45aecce9..f685e606 100644
--- a/src/py/libcamera/py_helpers.cpp
+++ b/src/py/libcamera/py_helpers.cpp
@@ -55,6 +55,7 @@ py::object controlValueToPy(const ControlValue &cv)
return py::cast(v);
}
case ControlTypeNone:
+ return py::none();
default:
throw std::runtime_error("Unsupported ControlValue type");
}
@@ -91,6 +92,7 @@ ControlValue pyToControlValue(const py::object &ob, ControlType type)
case ControlTypeSize:
return ControlValue(ob.cast<Size>());
case ControlTypeNone:
+ return ControlValue();
default:
throw std::runtime_error("Control type not implemented");
}