Skip to content

Commit 8cd9a22

Browse files
Apply some clippy suggestions.
1 parent a4785c6 commit 8cd9a22

4 files changed

Lines changed: 19 additions & 24 deletions

File tree

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn sign_on() {
682682
}
683683
if countdown == 1 {
684684
break;
685-
} else if countdown > 1 {
685+
} else {
686686
countdown -= 1;
687687
}
688688
}
@@ -1680,7 +1680,7 @@ pub extern "C" fn time_clock_set(time: common::Time) {
16801680
Ok(_) => {
16811681
defmt::info!("Time set in RTC OK");
16821682
}
1683-
Err(rtc::Error::BusError(_)) => {
1683+
Err(rtc::Error::Bus(_)) => {
16841684
defmt::warn!("Failed to talk to RTC to set time");
16851685
}
16861686
Err(rtc::Error::DriverBug) => {
@@ -2322,7 +2322,7 @@ unsafe fn HardFault(frame: &cortex_m_rt::ExceptionFrame) -> ! {
23222322
let tc = console::TextConsole::new();
23232323
tc.set_text_buffer(unsafe { &mut vga::GLYPH_ATTR_ARRAY });
23242324
for _col in 0..vga::MAX_TEXT_ROWS {
2325-
let _ = writeln!(&tc, "");
2325+
let _ = writeln!(&tc);
23262326
}
23272327
tc.move_to(0, 0);
23282328
tc.change_attr(Attr::new(

src/mcp23s17.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use super::SpiBus;
4040
/// Assumes the device is in `BANK = 0` mode.
4141
#[derive(defmt::Format, Debug, Copy, Clone, PartialEq, Eq)]
4242
#[repr(u8)]
43+
#[allow(clippy::upper_case_acronyms)]
4344
pub enum Register {
4445
/// Data Direction Register A
4546
DDRA = 0x00,

src/rtc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub use ds1307::{DateTimeAccess, NaiveDateTime};
3737

3838
/// The ways this module can fail
3939
pub enum Error<E> {
40-
BusError(E),
40+
Bus(E),
4141
DriverBug,
4242
NoRtcFound,
4343
}
@@ -108,14 +108,14 @@ impl Rtc {
108108
Self::Ds1307 => {
109109
let mut driver = ds1307::Ds1307::new(bus);
110110
driver.datetime().map_err(|e| match e {
111-
ds1307::Error::I2C(bus_error) => Error::BusError(bus_error),
111+
ds1307::Error::I2C(bus_error) => Error::Bus(bus_error),
112112
ds1307::Error::InvalidInputData => Error::DriverBug,
113113
})
114114
}
115115
Self::Mcp7940n => {
116116
let mut driver = mcp794xx::Mcp794xx::new_mcp7940n(bus);
117117
driver.datetime().map_err(|e| match e {
118-
mcp794xx::Error::Comm(bus_error) => Error::BusError(bus_error),
118+
mcp794xx::Error::Comm(bus_error) => Error::Bus(bus_error),
119119
mcp794xx::Error::InvalidInputData => Error::DriverBug,
120120
})
121121
}
@@ -137,14 +137,14 @@ impl Rtc {
137137
Self::Ds1307 => {
138138
let mut driver = ds1307::Ds1307::new(bus);
139139
driver.set_datetime(&new_time).map_err(|e| match e {
140-
ds1307::Error::I2C(bus_error) => Error::BusError(bus_error),
140+
ds1307::Error::I2C(bus_error) => Error::Bus(bus_error),
141141
ds1307::Error::InvalidInputData => Error::DriverBug,
142142
})
143143
}
144144
Self::Mcp7940n => {
145145
let mut driver = mcp794xx::Mcp794xx::new_mcp7940n(bus);
146146
driver.set_datetime(&new_time).map_err(|e| match e {
147-
mcp794xx::Error::Comm(bus_error) => Error::BusError(bus_error),
147+
mcp794xx::Error::Comm(bus_error) => Error::Bus(bus_error),
148148
mcp794xx::Error::InvalidInputData => Error::DriverBug,
149149
})
150150
}

src/vga/mod.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,28 +1445,22 @@ pub fn set_video_mode(mode: crate::common::video::Mode) -> bool {
14451445
}
14461446
}
14471447

1448-
/// Sets the current video mode
1448+
/// Check the given video mode is allowable
14491449
pub fn test_video_mode(mode: crate::common::video::Mode) -> bool {
1450-
match (
1451-
mode.timing(),
1452-
mode.format(),
1453-
mode.is_horiz_2x(),
1454-
mode.is_vert_2x(),
1455-
) {
1450+
matches!(
14561451
(
1457-
crate::common::video::Timing::T640x480,
1458-
crate::common::video::Format::Text8x16 | crate::common::video::Format::Text8x8,
1459-
false,
1460-
false,
1461-
) => true,
1452+
mode.timing(),
1453+
mode.format(),
1454+
mode.is_horiz_2x(),
1455+
mode.is_vert_2x(),
1456+
),
14621457
(
1463-
crate::common::video::Timing::T640x400,
1458+
crate::common::video::Timing::T640x480 | crate::common::video::Timing::T640x400,
14641459
crate::common::video::Format::Text8x16 | crate::common::video::Format::Text8x8,
14651460
false,
14661461
false,
1467-
) => true,
1468-
_ => false,
1469-
}
1462+
)
1463+
)
14701464
}
14711465

14721466
/// Get the current scan line.

0 commit comments

Comments
 (0)