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>
impl<I, O, const ISIZE: usize, const OSIZE: usize> RemoteXY<I, O, ISIZE, OSIZE>
Sourcepub async fn new(server_addr: &str, conf_buffer: &[u8]) -> Result<Self>
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.
Sourcepub fn get_input(&self) -> I
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}Sourcepub fn set_output(&self, data: &O)
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
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}Sourcepub fn is_connected(&self) -> bool
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§
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>
impl<I, O, const ISIZE: usize, const OSIZE: usize> Sync for RemoteXY<I, O, ISIZE, OSIZE>
impl<I, O, const ISIZE: usize, const OSIZE: usize> Unpin for RemoteXY<I, O, ISIZE, OSIZE>
impl<I, O, const ISIZE: usize, const OSIZE: usize> !UnwindSafe for RemoteXY<I, O, ISIZE, OSIZE>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more