Skip to content

Commit 3d5ab3a

Browse files
committed
Introduce internal type alias for Led
1 parent 12a1426 commit 3d5ab3a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/leds.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,25 @@ impl Direction {
3636
}
3737
}
3838

39+
type Led = Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>;
40+
3941
pub struct Leds {
4042
/// North
41-
pub ld3: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
43+
pub ld3: Led,
4244
/// NorthWest
43-
pub ld4: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
45+
pub ld4: Led,
4446
/// NorthEast
45-
pub ld5: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
47+
pub ld5: Led,
4648
/// West
47-
pub ld6: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
49+
pub ld6: Led,
4850
/// East
49-
pub ld7: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
51+
pub ld7: Led,
5052
/// SouthWest
51-
pub ld8: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
53+
pub ld8: Led,
5254
/// SouthEast
53-
pub ld9: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
55+
pub ld9: Led,
5456
/// South
55-
pub ld10: Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>,
57+
pub ld10: Led,
5658
}
5759

5860
impl Leds {
@@ -118,7 +120,7 @@ impl Leds {
118120
}
119121

120122
/// Mutably borrow a LED by the given direction (as noted on the board)
121-
pub fn for_direction(&mut self, direction: Direction) -> &mut Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh> {
123+
pub fn for_direction(&mut self, direction: Direction) -> &mut Led {
122124
match direction {
123125
Direction::North => &mut self.ld3,
124126
Direction::NorthEast => &mut self.ld5,
@@ -134,7 +136,7 @@ impl Leds {
134136
/// Consumes the `Leds` struct and returns an array
135137
/// where index 0 is N and each incrementing index
136138
/// rotates clockwise around the compass
137-
pub fn into_array(self) -> [Switch<gpioe::PEx<Output<PushPull>>, ActiveHigh>; 8] {
139+
pub fn into_array(self) -> [Led; 8] {
138140
[
139141
self.ld3, //N
140142
self.ld5, //NE

0 commit comments

Comments
 (0)