Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions cflib2/_rust.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,37 @@ class Crazyflie:
Returns:
Connected Crazyflie instance
"""
@staticmethod
async def power_off_stm32_domain(
link_context: LinkContext, uri: builtins.str
) -> None:
r"""
Power off the STM32 and deck subsystem

Cuts power to the STM32 and decks while keeping the nRF51 powered.
The Crazyflie can be powered on again using `power_on_stm32_domain()`.
This does not require a full connection.
"""
@staticmethod
async def power_on_stm32_domain(
link_context: LinkContext, uri: builtins.str
) -> None:
r"""
Power on the STM32 and deck subsystem

Powers the STM32 and decks back on after a `power_off_stm32_domain()`.
This does not require a full connection.
"""
@staticmethod
async def power_off_all(link_context: LinkContext, uri: builtins.str) -> None:
r"""
Power off the Crazyflie completely

Powers off the nRF51, STM32, and deck subsystem. Equivalent to
pressing the power button. The Crazyflie cannot be woken up via
radio after this.
This does not require a full connection.
"""
async def disconnect(self) -> None:
r"""
Disconnect from the Crazyflie
Expand Down
4 changes: 2 additions & 2 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension-module = ["pyo3/extension-module"]
[dependencies]
pyo3 = { version = "0.26" }
pyo3-async-runtimes = { version = "0.26", features = ["tokio-runtime"] }
crazyflie-lib = "0.6.0"
crazyflie-lib = "0.7.1"
crazyflie-link = "0.4.2"
tokio = { version = "1.48", features = ["full"] }
futures = "0.3.31"
Expand Down
45 changes: 45 additions & 0 deletions rust/src/crazyflie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,51 @@ impl Crazyflie {
})
}

/// Power off the STM32 and deck subsystem
///
/// Cuts power to the STM32 and decks while keeping the nRF51 powered.
/// The Crazyflie can be powered on again using `power_on_stm32_domain()`.
/// This does not require a full connection.
Comment thread
gemenerik marked this conversation as resolved.
#[staticmethod]
#[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))]
fn power_off_stm32_domain<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult<Bound<'py, PyAny>> {
let inner = link_context.inner.clone();
pyo3_async_runtimes::tokio::future_into_py(py, async move {
crazyflie_lib::Crazyflie::power_off_stm32_domain(&inner, &uri).await.map_err(to_pyerr)?;
Ok(())
})
}

/// Power on the STM32 and deck subsystem
///
/// Powers the STM32 and decks back on after a `power_off_stm32_domain()`.
/// This does not require a full connection.
#[staticmethod]
#[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))]
fn power_on_stm32_domain<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult<Bound<'py, PyAny>> {
let inner = link_context.inner.clone();
pyo3_async_runtimes::tokio::future_into_py(py, async move {
crazyflie_lib::Crazyflie::power_on_stm32_domain(&inner, &uri).await.map_err(to_pyerr)?;
Ok(())
})
}

/// Power off the Crazyflie completely
///
/// Powers off the nRF51, STM32, and deck subsystem. Equivalent to
/// pressing the power button. The Crazyflie cannot be woken up via
/// radio after this.
/// This does not require a full connection.
#[staticmethod]
#[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))]
fn power_off_all<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult<Bound<'py, PyAny>> {
let inner = link_context.inner.clone();
pyo3_async_runtimes::tokio::future_into_py(py, async move {
crazyflie_lib::Crazyflie::power_off_all(&inner, &uri).await.map_err(to_pyerr)?;
Ok(())
})
}
Comment thread
gemenerik marked this conversation as resolved.
Comment on lines +134 to +170
Comment thread
evoggy marked this conversation as resolved.

/// Disconnect from the Crazyflie
#[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))]
fn disconnect<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
Expand Down
Loading