Add methods to inspect LED ring mode and direction

This commit is contained in:
Paul van Tilburg 2019-04-06 17:43:21 +02:00
parent 3730032ee6
commit b0dae59274
Signed by: paul
GPG Key ID: C6DE073EDA9EEC4D
1 changed files with 12 additions and 2 deletions

View File

@ -6,7 +6,7 @@ use hal::prelude::_embedded_hal_digital_OutputPin as OutputPin;
///
/// The direction can be interpreted as such when the mini-USB port of the board is being held
/// down.
#[derive(Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Direction {
/// Cycle clockwise.
Clockwise,
@ -25,7 +25,7 @@ impl Direction {
}
/// The mode the LED ring is in.
#[derive(Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Mode {
/// All LEDs are off.
Off,
@ -64,6 +64,11 @@ where
}
}
/// Returns the current cycle mode.
pub fn mode(&self) -> Mode {
self.mode
}
/// Enables cycle mode.
pub fn enable_cycle(&mut self) {
self.mode = Mode::Cycle;
@ -89,6 +94,11 @@ where
self.mode == Mode::Accelerometer
}
/// Returns the current cycle direction.
pub fn direction(&self) -> Direction {
self.direction
}
/// Reverses the cycle direction.
///
/// This will have no immediately visible effect if the LED ring is not in cycle mode