[PATCH v3 3/3] py: Add bindings for ControlId enum name

Paul Elder paul.elder at ideasonboard.com
Wed Sep 11 11:36:00 CEST 2024


Add python bindings for querying enum value names from a ControlId.

Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

---
Changes in v3:
- s/enumName/enumToString/
- s/enum_name/enum_str/

New in v2
---
 src/py/libcamera/py_main.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
index ab33f38a8..f2897b11c 100644
--- a/src/py/libcamera/py_main.cpp
+++ b/src/py/libcamera/py_main.cpp
@@ -404,7 +404,8 @@ PYBIND11_MODULE(_libcamera, m)
 		.def("__repr__", [](const ControlId &self) {
 			return py::str("libcamera.ControlId({}, {}, {})")
 				.format(self.id(), self.name(), self.type());
-		});
+		})
+		.def("enum_str", &ControlId::enumToString);
 
 	pyControlInfo
 		.def_property_readonly("min", [](const ControlInfo &self) {
-- 
2.39.2



More information about the libcamera-devel mailing list