Skip to content

Commit

Permalink
feat: add constants to RcChannelsPacked
Browse files Browse the repository at this point in the history
  • Loading branch information
tact1m4n3 committed May 26, 2024
1 parent c51d7ba commit 0800ef6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This crate provides a #\[no_std\] parser for the crossfire protocol.
Check out the [examples](examples/) directory.

## Documentation
Not available yet.
Available on [docs.rs](https://docs.rs/crsf).

## License
Licensed under the [MIT License](LICENSE).
Expand Down
13 changes: 13 additions & 0 deletions src/packet/payload/rc_channels_packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ pub const LEN: usize = 22;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct RcChannelsPacked(pub [u16; 16]);

impl RcChannelsPacked {
/// Minimum channel value
pub const CHANNEL_VALUE_MIN: u16 = 172;
/// Channel value coresponding to 1000 in betaflight
pub const CHANNEL_VALUE_1000: u16 = 191;
/// Middle channel value
pub const CHANNEL_VALUE_MID: u16 = 992;
/// Channel value coresponding to 2000 in betaflight
pub const CHANNEL_VALUE_2000: u16 = 1792;
/// Max channel value
pub const CHANNEL_VALUE_MAX: u16 = 1811;
}

/// The raw decoder (parser) for the RcChannelsPacked packet.
pub fn raw_decode(data: &[u8; LEN]) -> RcChannelsPacked {
// Convert u8 to u16 to make room for bit shifting
Expand Down

0 comments on commit 0800ef6

Please sign in to comment.