From c97cf467ea79ed886dc549bff6837900427ca11e Mon Sep 17 00:00:00 2001 From: David Plowman Date: Fri, 30 Sep 2022 13:18:12 +0100 Subject: 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 Reviewed-by: Kieran Bingham Reviewed-by: Christian Rauch Reviewed-by: Tomi Valkeinen Signed-off-by: Laurent Pinchart --- src/py/libcamera/py_helpers.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') 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()); case ControlTypeNone: + return ControlValue(); default: throw std::runtime_error("Control type not implemented"); } -- cgit v1.2.1