diff --git a/src/led_ring.rs b/src/led_ring.rs index 4893546..a416eaa 100644 --- a/src/led_ring.rs +++ b/src/led_ring.rs @@ -1,12 +1,7 @@ //! Module for manipulating the LED ring. -use hal::gpio::{Output, PushPull}; -use hal::prelude::*; -/// Type alias for a generic LED output. -pub type Led = hal::gpio::gpiod::PD>; - -/// The cycle direction of the LED ring +/// The cycle direction of the LED ring. /// /// The direction can be interpreted as such when the mini-USB port of the board is being held /// down. @@ -55,9 +50,6 @@ pub struct LedRing { } impl LedRing { - /// The number of cycles between LED ring updates (used by tasks). - pub const PERIOD: u32 = 8_000_000; - /// Sets up the LED ring using using four LED GPIO outputs. pub fn from(leds: [Led; 4]) -> LedRing { LedRing { diff --git a/src/main.rs b/src/main.rs index c040415..58bd2c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ mod led_ring; -use crate::led_ring::{Led, LedRing}; +use crate::led_ring::LedRing; use core::fmt::Write; use cortex_m_semihosting::hprintln; use hal::{ @@ -28,6 +28,7 @@ use rtfm::app; type Accelerometer = hal::spi::Spi; type AccelerometerCs = hal::gpio::gpioe::PE3>; +type Led = hal::gpio::gpiod::PD>; type SerialTx = hal::serial::Tx; type SerialRx = hal::serial::Rx; type Spi1Sck = hal::gpio::gpioa::PA5>; @@ -35,11 +36,14 @@ type Spi1Miso = hal::gpio::gpioa::PA6>; type Spi1Mosi = hal::gpio::gpioa::PA7>; type UserButton = hal::gpio::gpioa::PA0>; +/// The number of cycles between LED ring updates (used by tasks). +const PERIOD: u32 = 8_000_000; + #[app(device = hal::stm32)] const APP: () = { static mut button: UserButton = (); static mut buffer: Vec = (); - static mut led_ring: LedRing = (); + static mut led_ring: LedRing = (); static mut exti: EXTI = (); static mut serial_rx: SerialRx = (); static mut serial_tx: SerialTx = (); @@ -125,7 +129,7 @@ const APP: () = { if led_ring.is_mode_cycle() { led_ring.advance(); schedule - .cycle_leds(scheduled + LedRing::PERIOD.cycles()) + .cycle_leds(scheduled + PERIOD.cycles()) .unwrap(); } }); @@ -154,7 +158,7 @@ const APP: () = { let directions = [acc_y < 0, acc_x < 0, acc_y > 0, acc_x > 0]; led_ring.specific_on(directions); schedule - .accel_leds(scheduled + LedRing::PERIOD.cycles()) + .accel_leds(scheduled + PERIOD.cycles()) .unwrap(); } })