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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}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)
16fn remote(sensor: InfraredSensor) -> Ev3Result<()> {
17 let remote = RemoteControl::new(sensor, 1)?;
18
19 loop {
20 remote.process()?;
21 println!(
22 "Button: {:?},{:?},{:?},{:?},{:?}",
23 remote.is_red_up(),
24 remote.is_red_down(),
25 remote.is_beacon(),
26 remote.is_blue_down(),
27 remote.is_blue_up(),
28 );
29
30 std::thread::sleep(std::time::Duration::from_secs(1));
31 }
32}Trait Implementations§
Source§impl Clone for RemoteControl
impl Clone for RemoteControl
Source§fn clone(&self) -> RemoteControl
fn clone(&self) -> RemoteControl
Returns a duplicate 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 !Freeze for RemoteControl
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more