Skip to main content

RemoteControl

Struct RemoteControl 

Source
pub struct RemoteControl<V: Validator = DjiValidator> { /* private fields */ }
Available on crate feature remote only.
Expand description

Decoded view of the remote-control state.

The struct is designed for lock-free sharing across tasks/threads in embedded runtimes. update writes a new snapshot atomically per field, and all getters are wait-free atomic loads.

§Generic Parameter

V is the validator type used for CRC16 checksum verification. It must implement the Validator trait, which defines how to calculate the CRC16 checksum for the frame. By default, V is set to DjiValidator, which uses the standard DJI CRC16 algorithm.

Implementations§

Source§

impl<V: Validator> RemoteControl<V>

Source

pub const fn new() -> RemoteControl<V>

Creates a zero-initialized remote-control state.

Source

pub fn update(&self, data: &[u8]) -> Result<usize, UnPackError>

Parses one 21-byte VT03/VT13 uplink frame and updates internal state.

Returns the number of consumed bytes (21) on success.

§Errors
Source§

impl<V: Validator> RemoteControl<V>

Source

pub fn right_horizontal(&self) -> i16

Right stick horizontal channel (ch0), (±660, centered at 0).

Source

pub fn right_vertical(&self) -> i16

Right stick vertical channel (ch1), (±660, centered at 0).

Source

pub fn left_vertical(&self) -> i16

Left stick vertical channel (ch2), (±660, centered at 0).

Source

pub fn left_horizontal(&self) -> i16

Left stick horizontal channel (ch3), (±660, centered at 0).

Source

pub fn switch(&self) -> Switch

Three-position switch state (C/N/S).

Source

pub fn pause(&self) -> bool

Pause key state, true if pressed.

Source

pub fn left_fn(&self) -> bool

Left function key state, true if pressed.

Source

pub fn right_fn(&self) -> bool

Right function key state, true if pressed.

Source

pub fn wheel(&self) -> i16

Wheel channel, (±660, centered at 0).

Source

pub fn trigger(&self) -> bool

Trigger state, true if pressed.

Source§

impl<V: Validator> RemoteControl<V>

Source

pub fn mouse_vx(&self) -> i16

Mouse X delta: i16.

Source

pub fn mouse_vy(&self) -> i16

Mouse Y delta: i16.

Source

pub fn mouse_vz(&self) -> i16

Mouse wheel/scroll delta: i16.

Source

pub fn left_button(&self) -> bool

Left mouse button state, true if pressed.

Source

pub fn right_button(&self) -> bool

Right mouse button state, true if pressed.

Source

pub fn mid_button(&self) -> bool

Middle mouse button state, true if pressed.

Source§

impl<V: Validator> RemoteControl<V>

Source

pub fn keyboard_w(&self) -> bool

Keyboard W key state, true if pressed.

Source

pub fn keyboard_s(&self) -> bool

Keyboard S key state, true if pressed.

Source

pub fn keyboard_a(&self) -> bool

Keyboard A key state, true if pressed.

Source

pub fn keyboard_d(&self) -> bool

Keyboard D key state, true if pressed.

Source

pub fn keyboard_shift(&self) -> bool

Keyboard Shift key state, true if pressed.

Source

pub fn keyboard_ctrl(&self) -> bool

Keyboard Ctrl key state, true if pressed.

Source

pub fn keyboard_q(&self) -> bool

Keyboard Q key state, true if pressed.

Source

pub fn keyboard_e(&self) -> bool

Keyboard E key state, true if pressed.

Source

pub fn keyboard_r(&self) -> bool

Keyboard R key state, true if pressed.

Source

pub fn keyboard_f(&self) -> bool

Keyboard F key state, true if pressed.

Source

pub fn keyboard_g(&self) -> bool

Keyboard G key state, true if pressed.

Source

pub fn keyboard_z(&self) -> bool

Keyboard Z key state, true if pressed.

Source

pub fn keyboard_x(&self) -> bool

Keyboard X key state, true if pressed.

Source

pub fn keyboard_c(&self) -> bool

Keyboard C key state, true if pressed.

Source

pub fn keyboard_v(&self) -> bool

Keyboard V key state, true if pressed.

Source

pub fn keyboard_b(&self) -> bool

Keyboard B key state, true if pressed.

Trait Implementations§

Source§

impl<V: Validator> Clone for RemoteControl<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug + Validator> Debug for RemoteControl<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Validator> Default for RemoteControl<V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<V: Validator> Display for RemoteControl<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<V: Validator> Format for RemoteControl<V>

Available on crate feature defmt only.
Source§

fn format(&self, fmt: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

§

impl<V = DjiValidator> !Freeze for RemoteControl<V>

§

impl<V> RefUnwindSafe for RemoteControl<V>
where V: RefUnwindSafe,

§

impl<V> Send for RemoteControl<V>
where V: Send,

§

impl<V> Sync for RemoteControl<V>
where V: Sync,

§

impl<V> Unpin for RemoteControl<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for RemoteControl<V>

§

impl<V> UnwindSafe for RemoteControl<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.