Struct ev3dev_lang_rust::sensors::RemoteControl
source · pub struct RemoteControl { /* private fields */ }Expand description
Seeks EV3 Remote Controller in beacon mode.
Implementations§
source§impl RemoteControl
impl RemoteControl
sourcepub fn new(sensor: InfraredSensor, channel: u8) -> Ev3Result<RemoteControl>
pub fn new(sensor: InfraredSensor, channel: u8) -> Ev3Result<RemoteControl>
Wrap a InfraredSensor into a BeaconSeeker
Examples found in repository?
examples/infrared-sensor.rs (line 17)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}sourcepub fn is_red_up(&self) -> bool
pub fn is_red_up(&self) -> bool
Checks if red_up button is pressed.
Examples found in repository?
examples/infrared-sensor.rs (line 23)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}sourcepub fn is_red_down(&self) -> bool
pub fn is_red_down(&self) -> bool
Checks if red_down button is pressed.
Examples found in repository?
examples/infrared-sensor.rs (line 24)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}sourcepub fn is_blue_up(&self) -> bool
pub fn is_blue_up(&self) -> bool
Checks if blue_up button is pressed.
Examples found in repository?
examples/infrared-sensor.rs (line 27)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}sourcepub fn is_blue_down(&self) -> bool
pub fn is_blue_down(&self) -> bool
Checks if blue_down button is pressed.
Examples found in repository?
examples/infrared-sensor.rs (line 26)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}sourcepub fn is_beacon(&self) -> bool
pub fn is_beacon(&self) -> bool
Checks if beacon button is pressed.
Examples found in repository?
examples/infrared-sensor.rs (line 25)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}sourcepub fn process(&self) -> Ev3Result<()>
pub fn process(&self) -> Ev3Result<()>
Check for currently pressed buttons. If the new state differs from the old state, call the appropriate button event handlers.
Examples found in repository?
examples/infrared-sensor.rs (line 20)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
let remote = RemoteControl::new(sensor, 1)?;
loop {
remote.process()?;
println!(
"Button: {:?},{:?},{:?},{:?},{:?}",
remote.is_red_up(),
remote.is_red_down(),
remote.is_beacon(),
remote.is_blue_down(),
remote.is_blue_up(),
);
std::thread::sleep(std::time::Duration::from_secs(1));
}
}Trait Implementations§
source§impl Clone for RemoteControl
impl Clone for RemoteControl
source§fn clone(&self) -> RemoteControl
fn clone(&self) -> RemoteControl
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RemoteControl
impl !Send for RemoteControl
impl !Sync for RemoteControl
impl Unpin for RemoteControl
impl !UnwindSafe for RemoteControl
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