From 7e0d04b23f4fcc832af2aad3323073fb2fbbf638 Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Wed, 28 Feb 2024 17:50:04 -0300 Subject: [PATCH 1/3] src: lib: leak: Add read_leak method --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 80fa5519c..de0f742bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -338,6 +338,18 @@ fn read_gyro() -> AxisData { with_navigator!().read_gyro().into() } +#[cpy_fn] +#[comment_c = "Reads the state of leak detector pin from Navigator."] +#[comment_py = "Reads the state of leak detector pin from Navigator.\n\n + Returns:\n + bool: The current state. `True` -> Leak detection, `False` -> No leak.\n + Examples:\n + >>> import bluerobotics_navigator as navigator\n + >>> leak_detector = navigator.read_leak()"] +fn read_leak() -> bool { + with_navigator!().read_leak() +} + #[cpy_fn] #[comment_c = "Enables or disables the PWM chip (PCA9685), using the firmware and OE_pin."] #[comment_py = "Enables or disables the PWM chip (PCA9685), using the firmware and OE_pin.\n @@ -503,6 +515,7 @@ cpy_module!( read_adc, read_pressure, read_temp, + read_leak, read_mag, read_accel, read_gyro, From f8539575765f29e58775addf7ae5e88c6ee03c2a Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Wed, 28 Feb 2024 17:51:52 -0300 Subject: [PATCH 2/3] examples: Python: Add leak_read method to example --- examples/python/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/python/main.py b/examples/python/main.py index 8a4982351..4f30f2469 100755 --- a/examples/python/main.py +++ b/examples/python/main.py @@ -23,6 +23,8 @@ def navigator_check(): print(f"Pressure: {navigator.read_pressure()}") + print(f"Leak sensor: {navigator.read_leak()}") + Data = navigator.read_adc_all() print( f"Data ADC Channels: 1 = {Data.channel[0]}, 2 = {Data.channel[1]}, 3 = {Data.channel[2]}, 4 = {Data.channel[3]}" From 9f5eba10e500ac3027cc9fa449c61c93aea5f6d5 Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Wed, 28 Feb 2024 18:54:35 -0300 Subject: [PATCH 3/3] examples: Cpp: Add leak_read method to example --- examples/cpp/simple.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/cpp/simple.cpp b/examples/cpp/simple.cpp index c257dbe8b..c70a5c288 100644 --- a/examples/cpp/simple.cpp +++ b/examples/cpp/simple.cpp @@ -32,6 +32,8 @@ int main() { printf("Pressure: %f\n", read_pressure()); + printf("Leak sensor: %s\n", read_leak() ? "true" : "false"); + ADCData adc = read_adc_all(); printf("Reading ADC Channels: 1 = %f, 2 = %f, 3 = %f, 4 = %f\n", adc.channel[0], adc.channel[1], adc.channel[2], adc.channel[3]);