Skip to content

Commit

Permalink
expose RF24::tx_delay in bindings
Browse files Browse the repository at this point in the history
and adjust doc comments
  • Loading branch information
2bndy5 committed Jan 8, 2025
1 parent f56b124 commit ad73cec
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 1 deletion.
32 changes: 32 additions & 0 deletions bindings/node/src/radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,38 @@ impl RF24 {
.map_err(|e| Error::new(Status::GenericFailure, format!("{e:?}")))
}

/// @group Configuration
#[napi(getter, js_name = "txDelay")]
pub fn get_tx_delay(&self) -> u32 {
self.inner.tx_delay
}

/// The driver will delay for this duration (32 bit unsigned int of microseconds)
/// when {@link RF24.asTx | `asTx`} is called.
///
/// If the auto-ack feature is disabled, then this can be set as low as 0.
/// If the auto-ack feature is enabled, then set to 100 microseconds minimum on
/// generally faster devices (like RPi).
///
/// This value cannot be negative.
///
/// Since this value can be optimized per the radio's data rate, this value is
/// automatically adjusted when changing
/// {@link RF24.dataRate | `dataRate`}.
/// If setting this to a custom value be sure, to set it *after*
/// changing the radio's data rate.
///
/// > [!WARNING]
/// > If set to 0, ensure 130 microsecond delay
/// > after calling {@link RF24.asTx | `asTx`}
/// > and before transmitting.
///
/// @group Configuration
#[napi(setter, js_name = "txDelay")]
pub fn set_tx_delay(&mut self, value: u32) -> () {
self.inner.tx_delay = value;
}

/// Configure the IRQ pin to reflect the specified {@link StatusFlags | `StatusFlags`}.
///
/// @param flags - If no value is given, then all flags are reflected by the IRQ pin.
Expand Down
29 changes: 29 additions & 0 deletions bindings/python/src/radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,35 @@ impl RF24 {
.map_err(|e| PyRuntimeError::new_err(format!("{e:?}")))
}

/// The driver will delay for this duration (32 bit unsigned int of microseconds)
/// when [`as_tx()`][rf24_py.RF24.as_tx] is called.
///
/// If the auto-ack feature is disabled, then this can be set as low as 0.
/// If the auto-ack feature is enabled, then set to 100 microseconds minimum on
/// generally faster devices (like RPi).
///
/// This value cannot be negative.
///
/// Since this value can be optimized per the radio's data rate, this value is
/// automatically adjusted when changing
/// [`data_rate`][rf24_py.RF24.data_rate].
/// If setting this to a custom value be sure, to set it *after*
/// changing the radio's data rate.
///
/// Warning:
/// If set to 0, ensure 130 microsecond delay
/// after calling [`as_tx()`][rf24_py.RF24.as_tx]
/// and before transmitting.
#[setter]
pub fn set_tx_delay(&mut self, value: u32) -> () {
self.inner.tx_delay = value;
}

#[getter]
pub fn get_tx_delay(&self) -> u32 {
self.inner.tx_delay
}

/// Configure the IRQ pin to reflect the specified [`StatusFlags`][rf24_py.StatusFlags].
///
/// Other Parameters:
Expand Down
1 change: 1 addition & 0 deletions crates/rf24-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ See the examples in the repository's [examples/rust](https://github.com/nRF24/rf
- [`RF24`][rf24-struct]`::`[`is_powered()`](fn@crate::radio::prelude::EsbPower::is_powered)
- [`RF24`][rf24-struct]`::`[`power_up()`](fn@crate::radio::prelude::EsbPower::power_up)
- [`RF24`][rf24-struct]`::`[`power_down()`](fn@crate::radio::prelude::EsbPower::power_down)
- [`RF24::tx_delay`](value@crate::radio::RF24::tx_delay)
- [`RF24::is_plus_variant()`](fn@crate::radio::RF24::is_plus_variant)
18 changes: 17 additions & 1 deletion crates/rf24-rs/src/radio/rf24/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,24 @@ pub struct RF24<SPI, DO, DELAY> {
/// The delay (in microseconds) in which [`RF24::as_rx()`] will wait for
/// ACK packets to complete.
///
/// This value is automatically adjusted when calling
/// If the auto-ack feature is disabled, then this can be set as low as 0.
/// If the auto-ack feature is enabled, then set to 100 microseconds minimum on
/// generally faster devices (like RPi).
///
/// Since this value can be optimized per the radio's data rate, this value is
/// automatically adjusted when calling
/// [`EsbDataRate::set_data_rate()`](fn@crate::radio::prelude::EsbDataRate::set_data_rate).
/// If setting this to a custom value be sure, to set it *after*
/// changing the radio's data rate.
///
/// <div class="warning">
///
/// If set to 0, ensure 130 microsecond delay
/// after calling [`RF24::as_rx()`]
/// and before transmitting.
///
/// </div>
///
pub tx_delay: u32,
_spi: SPI,
/// The CE pin for the radio.
Expand Down
3 changes: 3 additions & 0 deletions docs/src/python-api/classes/RF24.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
::: rf24_py.RF24.power_down
options:
heading_level: 3
::: rf24_py.RF24.tx_delay
options:
heading_level: 3
::: rf24_py.RF24.is_plus_variant
options:
heading_level: 3
4 changes: 4 additions & 0 deletions rf24_py.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class RF24:
def power(self, enable: bool | int) -> None: ...
def power_down(self) -> None: ...
def power_up(self, delay: int | None = None) -> None: ...
@property
def tx_delay(self) -> int: ...
@tx_delay.setter
def tx_delay(self, value: int): ...
def set_status_flags(self, flags: StatusFlags | None = None) -> None: ...
def clear_status_flags(self, flags: StatusFlags | None = None) -> None: ...
def update(self) -> None: ...
Expand Down

0 comments on commit ad73cec

Please sign in to comment.