From fedcb6629de3c3505186872414fe1368d73f8c24 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Wed, 23 Dec 2020 23:52:23 +0100 Subject: [PATCH] Some import cleanups --- src/application/mod.rs | 26 +-------- src/application/profile_selection.rs | 16 +----- src/application/run_profile.rs | 14 ++--- src/application/setup.rs | 24 ++------ src/application/splash.rs | 25 ++------ src/main.rs | 86 ++-------------------------- 6 files changed, 23 insertions(+), 168 deletions(-) diff --git a/src/application/mod.rs b/src/application/mod.rs index 2a8af4e..057517d 100644 --- a/src/application/mod.rs +++ b/src/application/mod.rs @@ -1,30 +1,10 @@ -use arrayvec::ArrayString; -use core::fmt::Write; -use cortex_m::asm; -use cortex_m_rt::{entry, exception}; -use embedded_graphics::{ - drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565, - prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder, - style::TextStyleBuilder, -}; - -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use profont::{ProFont12Point, ProFont14Point, ProFont9Point}; -use rtt_target::{rprintln, rtt_init_print}; -use st7735_lcd::Orientation; use stm32f1xx_hal::{ delay::Delay, gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull}, - pac, - prelude::*, - qei, rcc, - spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap}, - stm32, - timer::{Tim3PartialRemap, Timer}, + pac, qei, + spi::{Spi, Spi1NoRemap}, + timer::Tim3PartialRemap, }; -use tinybmp::Bmp; - -use crate::profiles; mod confirm_profile; mod profile_selection; diff --git a/src/application/profile_selection.rs b/src/application/profile_selection.rs index e0852a5..ee781ce 100644 --- a/src/application/profile_selection.rs +++ b/src/application/profile_selection.rs @@ -1,23 +1,13 @@ use embedded_graphics::{ - drawable::Drawable, fonts::Text, pixelcolor::BinaryColor, pixelcolor::Rgb565, prelude::*, - primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder, - style::TextStyleBuilder, + drawable::Drawable, fonts::Text, pixelcolor::Rgb565, prelude::*, + primitives::rectangle::Rectangle, style::PrimitiveStyleBuilder, style::TextStyleBuilder, }; use embedded_hal::digital::v2::{InputPin, OutputPin}; use profont::ProFont12Point; use st7735_lcd::Orientation; -use stm32f1xx_hal::{ - delay::Delay, - gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull}, - pac, - prelude::*, - qei, rcc, - spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap}, - stm32, - timer::{Tim3PartialRemap, Timer}, -}; +use stm32f1xx_hal::prelude::*; use crate::application::App; use crate::profiles; diff --git a/src/application/run_profile.rs b/src/application/run_profile.rs index 8a83e56..dcf8c9b 100644 --- a/src/application/run_profile.rs +++ b/src/application/run_profile.rs @@ -1,16 +1,11 @@ -use arrayvec::ArrayString; -use core::fmt::Write; -use cortex_m::asm; -use cortex_m_rt::{entry, exception}; use embedded_graphics::{ - drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565, - prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder, + drawable::Drawable, fonts::Text, pixelcolor::Rgb565, prelude::*, + primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder, style::TextStyleBuilder, }; -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use profont::{ProFont12Point, ProFont14Point, ProFont9Point}; -use rtt_target::{rprintln, rtt_init_print}; +use embedded_hal::digital::v2::OutputPin; + use st7735_lcd::Orientation; use stm32f1xx_hal::{ delay::Delay, @@ -22,7 +17,6 @@ use stm32f1xx_hal::{ stm32, timer::{Tim3PartialRemap, Timer}, }; -use tinybmp::Bmp; use crate::application::App; use crate::profiles; diff --git a/src/application/setup.rs b/src/application/setup.rs index 3d1d357..429eb00 100644 --- a/src/application/setup.rs +++ b/src/application/setup.rs @@ -1,31 +1,15 @@ -use arrayvec::ArrayString; -use core::fmt::Write; -use cortex_m::asm; -use cortex_m_rt::{entry, exception}; -use embedded_graphics::{ - drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565, - prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder, - style::TextStyleBuilder, -}; +use embedded_hal::digital::v2::OutputPin; -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use profont::{ProFont12Point, ProFont14Point, ProFont9Point}; -use rtt_target::{rprintln, rtt_init_print}; -use st7735_lcd::Orientation; use stm32f1xx_hal::{ delay::Delay, - gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull}, - pac, prelude::*, - qei, rcc, - spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap}, + qei, + spi::{Mode, Phase, Polarity, Spi}, stm32, - timer::{Tim3PartialRemap, Timer}, + timer::Timer, }; -use tinybmp::Bmp; use crate::application::App; -use crate::profiles; pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> App { // Take ownership over the raw flash and rcc devices and convert them into the corresponding diff --git a/src/application/splash.rs b/src/application/splash.rs index e621f5b..33f3fe9 100644 --- a/src/application/splash.rs +++ b/src/application/splash.rs @@ -1,27 +1,12 @@ -use arrayvec::ArrayString; -use core::fmt::Write; -use cortex_m::asm; -use cortex_m_rt::{entry, exception}; use embedded_graphics::{ - drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565, - prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder, - style::TextStyleBuilder, + drawable::Drawable, image::Image, pixelcolor::Rgb565, prelude::*, + primitives::rectangle::Rectangle, style::PrimitiveStyleBuilder, }; -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use profont::{ProFont12Point, ProFont14Point, ProFont9Point}; -use rtt_target::{rprintln, rtt_init_print}; +use embedded_hal::digital::v2::OutputPin; + use st7735_lcd::Orientation; -use stm32f1xx_hal::{ - delay::Delay, - gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull}, - pac, - prelude::*, - qei, rcc, - spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap}, - stm32, - timer::{Tim3PartialRemap, Timer}, -}; +use stm32f1xx_hal::prelude::*; use tinybmp::Bmp; use crate::application::App; diff --git a/src/main.rs b/src/main.rs index 68ead16..7cc7a3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,28 +2,12 @@ #![no_std] #![no_main] -use arrayvec::ArrayString; -use core::fmt::Write; use cortex_m::asm; use cortex_m_rt::{entry, exception}; -use embedded_graphics::{ - drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565, - prelude::*, primitives::rectangle::Rectangle, style::PrimitiveStyleBuilder, - style::TextStyleBuilder, -}; -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use profont::{ProFont12Point, ProFont9Point}; + use rtt_target::{rprintln, rtt_init_print}; -use st7735_lcd::Orientation; -use stm32f1xx_hal::{ - delay::Delay, - pac, - prelude::*, - qei::QeiOptions, - spi::{Mode, Phase, Polarity, Spi}, - timer::Timer, -}; -use tinybmp::Bmp; + +use stm32f1xx_hal::pac; mod application; mod max6675; @@ -38,71 +22,9 @@ fn main() -> ! { // Get access to the device specific peripherals from the peripheral access crate let dp = pac::Peripherals::take().unwrap(); - let mut app = application::setup(cp, dp); + let app = application::setup(cp, dp); app.run() - - /* - - let mut disp = st7735_lcd::ST7735::new(spi, dc, rst, true, false, 160, 128); - disp_cs.set_low().unwrap(); - disp.init(&mut delay).unwrap(); - disp.set_orientation(&Orientation::LandscapeSwapped) - .unwrap(); - - let style_black = PrimitiveStyleBuilder::new() - .fill_color(Rgb565::BLACK) - .build(); - Rectangle::new(Point::new(0, 0), Point::new(160, 128)) - .into_styled(style_black) - .draw(&mut disp) - .unwrap(); - - let bmp = Bmp::from_slice(include_bytes!("logo.bmp")).unwrap(); - let image = Image::new(&bmp, Point::new(16, 0)); - image.draw(&mut disp).unwrap(); - - let (_spi, _dc, _rst) = disp.release(); - spi = _spi; - dc = _dc; - rst = _rst; - disp_cs.set_high().unwrap(); - - let text_lager = TextStyleBuilder::new(ProFont12Point) - .text_color(Rgb565::WHITE) - .build(); - - loop { - let temp = max6675::read(&mut spi, &mut max_cs).unwrap(); - rprintln!("T: {}", temp); - - // Create a fixed buffer of length 12 - let mut buf = ArrayString::<[_; 10]>::new(); - // Output `Value: 12.35` - write!(&mut buf, "T: {}", qei.count() / 4).expect("Failed to write to buffer"); - - disp_cs.set_low().unwrap(); - let mut disp = st7735_lcd::ST7735::new(spi, dc, rst, true, false, 160, 128); - - Rectangle::new(Point::new(0, 100), Point::new(160, 128)) - .into_styled(style_black) - .draw(&mut disp) - .unwrap(); - - Text::new(&buf, Point::new(60, 100)) - .into_styled(text_lager) - .draw(&mut disp) - .unwrap(); - - let (_spi, _dc, _rst) = disp.release(); - spi = _spi; - dc = _dc; - rst = _rst; - disp_cs.set_high().unwrap(); - - delay.delay_ms(250u16); - } - */ } #[exception]