From 239e5368be360c611f7ba32c3a218a70b84687b5 Mon Sep 17 00:00:00 2001 From: Kat Inskip Date: Fri, 17 Oct 2025 07:58:39 -0700 Subject: [PATCH] chore: reformat --- rustfmt.toml | 4 +++ src/main.rs | 98 ++++++++++++++++++++++++---------------------------- 2 files changed, 49 insertions(+), 53 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..07585f3 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,4 @@ +style_edition = "2021" +imports_granularity = "One" +group_imports = "StdExternalCrate" +reorder_imports = true diff --git a/src/main.rs b/src/main.rs index e730395..57123af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,59 +1,41 @@ #![no_std] #![no_main] -use esp_backtrace as _; -use embedded_graphics::{ - mono_font::{ - ascii::FONT_8X13, - MonoTextStyle, - MonoFont, +use { + display_interface_spi::{SPIInterface, *}, + embedded_graphics::{ + mono_font::{ascii::FONT_8X13, MonoFont, MonoTextStyle}, + pixelcolor::Rgb565, + prelude::*, + primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, Triangle}, + text::{Alignment, Text}, }, - pixelcolor::Rgb565, - prelude::*, - primitives::{ - Line, - PrimitiveStyle, - PrimitiveStyleBuilder, - Rectangle, - Triangle, - }, - text::{ - Alignment, - Text, + embedded_hal_bus::spi::{ExclusiveDevice, NoDelay}, + esp_backtrace as _, + esp_hal::{ + clock::CpuClock, + delay::Delay, + gpio::{AnyPin, Input, InputPin, Level, Output, OutputConfig, OutputPin}, + init, main, + peripherals::{Peripherals, ADC1, SPI2}, + rng::Rng, + spi::{ + master::{Config, Spi}, + Mode, + }, + time::Rate, + timer::timg::TimerGroup, + Blocking, }, + esp_println::println, + ili9341::{DisplaySize240x320, Ili9341, Orientation}, }; -use display_interface_spi::{SPIInterface, *}; -use embedded_hal_bus::spi::{ExclusiveDevice, NoDelay}; -use esp_hal::{ - rng::Rng, - timer::timg::TimerGroup, - delay::Delay, - gpio::{ - OutputPin, InputPin, - AnyPin, Level, Input, Output, OutputConfig}, - peripherals::{ADC1, Peripherals, SPI2}, - spi::{ - master::{Config, Spi}, - Mode, - }, - clock::CpuClock, - time::Rate, - Blocking, - main, - init, -}; -use ili9341::{ - DisplaySize240x320, - Ili9341, - Orientation, -}; -use esp_println::println; esp_bootloader_esp_idf::esp_app_desc!(); type TFTSpiDevice<'spi> = ExclusiveDevice, Output<'spi>, NoDelay>; type TFTSpiInterface<'spi> = -SPIInterface, Output<'spi>, NoDelay>, Output<'spi>>; + SPIInterface, Output<'spi>, NoDelay>, Output<'spi>>; type Ili<'spi> = Ili9341, Output<'spi>>; @@ -61,23 +43,32 @@ pub struct TFT<'spi> { display: Ili<'spi>, } -impl <'spi>TFT<'spi> { - fn draw_target(&mut self) -> DrawFlipper<'_,'spi> { - DrawFlipper { display: &mut self.display } +impl<'spi> TFT<'spi> { + fn draw_target(&mut self) -> DrawFlipper<'_, 'spi> { + DrawFlipper { + display: &mut self.display, + } } } -struct DrawFlipper<'a,'spi> { display: &'a mut Ili<'spi>, } +struct DrawFlipper<'a, 'spi> { + display: &'a mut Ili<'spi>, +} impl<'a, 'spi> DrawTarget for DrawFlipper<'a, 'spi> { type Error = as DrawTarget>::Error; type Color = as DrawTarget>::Color; fn draw_iter(&mut self, pixels: I) -> Result<(), Self::Error> - where I: IntoIterator> { + where + I: IntoIterator>, + { let width = self.bounding_box().size.width as i32; - self.display.draw_iter(pixels.into_iter().map(|mut p| { p.0.x = width - p.0.x; p })) + self.display.draw_iter(pixels.into_iter().map(|mut p| { + p.0.x = width - p.0.x; + p + })) } } -impl<'a> Dimensions for DrawFlipper<'a,'_> { +impl<'a> Dimensions for DrawFlipper<'a, '_> { fn bounding_box(&self) -> Rectangle { self.display.bounding_box() } @@ -110,7 +101,8 @@ impl<'spi> TFT<'spi> { &mut Delay::new(), Orientation::Landscape, DisplaySize240x320, - ).unwrap(); + ) + .unwrap(); TFT { display } }