py: Add bindings for ControlId array information
diff mbox series

Message ID 20241010090210.757093-1-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • py: Add bindings for ControlId array information
Related show

Commit Message

Paul Elder Oct. 10, 2024, 9:02 a.m. UTC
Add python bindings for querying whether or not a ControlId is an array
type, and the size.

Example usage:
>>> cid
libcamera.ControlId(28, FrameDurationLimits, ControlType.Integer64)
>>> cid.isArray
True
>>> cid.size
2

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/py/libcamera/py_main.cpp | 2 ++
 1 file changed, 2 insertions(+)

Comments

Kieran Bingham Oct. 10, 2024, 8:28 p.m. UTC | #1
Quoting Paul Elder (2024-10-10 10:02:10)
> Add python bindings for querying whether or not a ControlId is an array
> type, and the size.
> 
> Example usage:
> >>> cid
> libcamera.ControlId(28, FrameDurationLimits, ControlType.Integer64)

And the same here, could we format this to be 
			FrameDurationLimits[2] ?

for array controls ?


> >>> cid.isArray
> True
> >>> cid.size
> 2
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  src/py/libcamera/py_main.cpp | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
> index 983b76f6e998..898ef319dc69 100644
> --- a/src/py/libcamera/py_main.cpp
> +++ b/src/py/libcamera/py_main.cpp
> @@ -400,6 +400,8 @@ PYBIND11_MODULE(_libcamera, m)
>                 .def_property_readonly("id", &ControlId::id)
>                 .def_property_readonly("name", &ControlId::name)
>                 .def_property_readonly("type", &ControlId::type)
> +               .def_property_readonly("isArray", &ControlId::isArray)
> +               .def_property_readonly("size", &ControlId::size)
>                 .def("__str__", [](const ControlId &self) { return self.name(); })
>                 .def("__repr__", [](const ControlId &self) {
>                         return py::str("libcamera.ControlId({}, {}, {})")
> -- 
> 2.39.2
>

Patch
diff mbox series

diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
index 983b76f6e998..898ef319dc69 100644
--- a/src/py/libcamera/py_main.cpp
+++ b/src/py/libcamera/py_main.cpp
@@ -400,6 +400,8 @@  PYBIND11_MODULE(_libcamera, m)
 		.def_property_readonly("id", &ControlId::id)
 		.def_property_readonly("name", &ControlId::name)
 		.def_property_readonly("type", &ControlId::type)
+		.def_property_readonly("isArray", &ControlId::isArray)
+		.def_property_readonly("size", &ControlId::size)
 		.def("__str__", [](const ControlId &self) { return self.name(); })
 		.def("__repr__", [](const ControlId &self) {
 			return py::str("libcamera.ControlId({}, {}, {})")