RemoteXY

Struct RemoteXY 

Source
pub struct RemoteXY<I, O, const ISIZE: usize, const OSIZE: usize> { /* private fields */ }
Expand description

RemoteXY struct that provides the interface to the RemoteXY app.

Implementations§

Source§

impl<I, O, const ISIZE: usize, const OSIZE: usize> RemoteXY<I, O, ISIZE, OSIZE>

Source

pub async fn new(server_addr: &str, conf_buffer: &[u8]) -> Result<Self>

Creates a new RemoteXY instance and starts the server. You have to provide the generic types InputData and OutputData as well as their sizes, e.g.: RemoteXY::<InputData, OutputData, 2, 2>::new(LOCAL_ADDR, CONF_BUF).unwrap(); Prefer using the remote_xy! macro which calculates the correct sizes for you.

Source

pub fn get_input(&self) -> I

Returns the current input data or the default value if no data is available.

Examples found in repository?
examples/simple.rs (line 41)
36async fn main() -> Result<()> {
37    let remotexy = remote_xy!(InputData, OutputData, "[::]:6377", CONF_BUF).await?;
38    let mut output = OutputData::default();
39
40    loop {
41        let input = remotexy.get_input();
42        println!("Received input: {:?}", input);
43
44        output.circularbar_1 = input.slider_1;
45        output.led_1 = input.switch_1;
46        remotexy.set_output(&output);
47
48        tokio::time::sleep(Duration::from_millis(200)).await;
49    }
50}
Source

pub fn set_output(&self, data: &O)

Sets the output data. The data is sent to the RemoteXY app on your smartphone.

Examples found in repository?
examples/simple.rs (line 46)
36async fn main() -> Result<()> {
37    let remotexy = remote_xy!(InputData, OutputData, "[::]:6377", CONF_BUF).await?;
38    let mut output = OutputData::default();
39
40    loop {
41        let input = remotexy.get_input();
42        println!("Received input: {:?}", input);
43
44        output.circularbar_1 = input.slider_1;
45        output.led_1 = input.switch_1;
46        remotexy.set_output(&output);
47
48        tokio::time::sleep(Duration::from_millis(200)).await;
49    }
50}
More examples
Hide additional examples
examples/output-only.rs (line 56)
39async fn main() -> Result<()> {
40    let remotexy = remote_xy!(InputData, OutputData, "[::]:6377", CONF_BUF).await?;
41    let mut output = OutputData::default();
42    let mut x = 0.0;
43
44    while remotexy.is_connected() == false {
45        tokio::time::sleep(Duration::from_millis(200)).await;
46    }
47
48    println!("Connected to RemoteXY app");
49
50    // wait some time to see the effect of default custum signals
51    tokio::time::sleep(Duration::from_millis(2000)).await;
52
53    println!("Starting to send data");
54    loop {
55        output.online_graph_1 = f32::sin(x);
56        remotexy.set_output(&output);
57        x += 0.1;
58
59        tokio::time::sleep(Duration::from_millis(50)).await;
60    }
61}
Source

pub fn is_connected(&self) -> bool

Returns true if the RemoteXY app is connected to the server.

Examples found in repository?
examples/output-only.rs (line 44)
39async fn main() -> Result<()> {
40    let remotexy = remote_xy!(InputData, OutputData, "[::]:6377", CONF_BUF).await?;
41    let mut output = OutputData::default();
42    let mut x = 0.0;
43
44    while remotexy.is_connected() == false {
45        tokio::time::sleep(Duration::from_millis(200)).await;
46    }
47
48    println!("Connected to RemoteXY app");
49
50    // wait some time to see the effect of default custum signals
51    tokio::time::sleep(Duration::from_millis(2000)).await;
52
53    println!("Starting to send data");
54    loop {
55        output.online_graph_1 = f32::sin(x);
56        remotexy.set_output(&output);
57        x += 0.1;
58
59        tokio::time::sleep(Duration::from_millis(50)).await;
60    }
61}

Trait Implementations§

Source§

impl<I, O, const ISIZE: usize, const OSIZE: usize> Drop for RemoteXY<I, O, ISIZE, OSIZE>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<I, O, const ISIZE: usize, const OSIZE: usize> Freeze for RemoteXY<I, O, ISIZE, OSIZE>

§

impl<I, O, const ISIZE: usize, const OSIZE: usize> !RefUnwindSafe for RemoteXY<I, O, ISIZE, OSIZE>

§

impl<I, O, const ISIZE: usize, const OSIZE: usize> Send for RemoteXY<I, O, ISIZE, OSIZE>
where I: Send, O: Send,

§

impl<I, O, const ISIZE: usize, const OSIZE: usize> Sync for RemoteXY<I, O, ISIZE, OSIZE>
where I: Sync, O: Sync,

§

impl<I, O, const ISIZE: usize, const OSIZE: usize> Unpin for RemoteXY<I, O, ISIZE, OSIZE>
where I: Unpin, O: Unpin,

§

impl<I, O, const ISIZE: usize, const OSIZE: usize> !UnwindSafe for RemoteXY<I, O, ISIZE, OSIZE>

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> 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.