From f0f38c61ff48453feef34b74d882466cd18d455f Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 9 Sep 2019 21:38:46 -0400 Subject: Clippy. --- usb/src/dotstar.rs | 16 +++++++++------- usb/src/logger.rs | 8 ++++---- usb/src/main.rs | 12 +++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/usb/src/dotstar.rs b/usb/src/dotstar.rs index c7eed7d..13ccb8d 100644 --- a/usb/src/dotstar.rs +++ b/usb/src/dotstar.rs @@ -8,6 +8,14 @@ use trinket_m0::{ use apa102_spi::Apa102; +type TrinketDotStar = Apa102< + SPIMaster1< + sercom::Sercom1Pad3>, + sercom::Sercom1Pad0>, + sercom::Sercom1Pad1>, + >, +>; + pub fn new( sercom: SERCOM1, miso: gpio::Pa31>, @@ -16,13 +24,7 @@ pub fn new( port: &mut gpio::Port, pm: &mut PM, clocks: &mut GenericClockController, -) -> Apa102< - SPIMaster1< - sercom::Sercom1Pad3>, - sercom::Sercom1Pad0>, - sercom::Sercom1Pad1>, - >, -> { +) -> TrinketDotStar { let gclk = clocks.gclk0(); let miso = miso.into_pad(port); let mosi = mosi.into_pad(port); diff --git a/usb/src/logger.rs b/usb/src/logger.rs index 7357c22..170607c 100644 --- a/usb/src/logger.rs +++ b/usb/src/logger.rs @@ -20,14 +20,14 @@ struct JoinedRingBuffer<'a> { impl<'a> JoinedRingBuffer<'a> { const fn new(rb: &'a RingBuffer) -> Self { let (lbr, lbw) = rb.split(); - Self { lbr: lbr, lbw: lbw } + Self { lbr, lbw } } } impl fmt::Write for JoinedRingBuffer<'_> { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { for b in s.bytes() { - if let Err(_) = self.lbw.unshift(b) { + if self.lbw.unshift(b).is_err() { // Ignore buffer full errors for logging. return Ok(()); } @@ -93,9 +93,9 @@ where } let jrb = unsafe { &mut JRB }; - write!( + writeln!( jrb, - "[{}] {} {} -- {}\r\n", + "[{}] {} {} -- {}\r", rtc::millis(), record.level(), record.target(), diff --git a/usb/src/main.rs b/usb/src/main.rs index 42cdf55..a87ecfb 100644 --- a/usb/src/main.rs +++ b/usb/src/main.rs @@ -39,6 +39,12 @@ use smart_leds::colors; use smart_leds_trait::SmartLedsWrite; use usb_host::Driver; +// Wow, would I love to not be annotating this type. +type UARTLogger = logger::SerialLogger< + sercom::UART0>, sercom::Sercom0Pad2>, (), ()>, + Pa10>, +>; + // A very unsafe copy of an LED to turn on when things go really, really wrong. static mut LED: usize = 0; @@ -111,11 +117,7 @@ fn main() -> ! { let uart_wrapped = logger::WriteWrapper::new(uart); let logger = logger::SerialLogger::new(uart_wrapped, red_led); - // Wow, would I love to not be annotating this type. - let logger_ref: &'static logger::SerialLogger< - sercom::UART0>, sercom::Sercom0Pad2>, (), ()>, - Pa10>, - > = unsafe { mem::transmute(&logger) }; + let logger_ref: &'static UARTLogger = unsafe { mem::transmute(&logger) }; unsafe { log::set_logger_racy(logger_ref).expect("couldn't set logger") }; log::set_max_level(LevelFilter::Trace); -- cgit v1.2.3