Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updade: Integrations navigator 0.3.1 - lib: Add read_leak method and examples #61

Merged
merged 3 commits into from Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/cpp/simple.cpp
Expand Up @@ -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]);
Expand Down
2 changes: 2 additions & 0 deletions examples/python/main.py
Expand Up @@ -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]}"
Expand Down
13 changes: 13 additions & 0 deletions src/lib.rs
Expand Up @@ -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
Expand Down Expand Up @@ -503,6 +515,7 @@ cpy_module!(
read_adc,
read_pressure,
read_temp,
read_leak,
read_mag,
read_accel,
read_gyro,
Expand Down