Some import cleanups
This commit is contained in:
parent
f37b18c205
commit
fedcb6629d
|
@ -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::{
|
use stm32f1xx_hal::{
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
|
gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
|
||||||
pac,
|
pac, qei,
|
||||||
prelude::*,
|
spi::{Spi, Spi1NoRemap},
|
||||||
qei, rcc,
|
timer::Tim3PartialRemap,
|
||||||
spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap},
|
|
||||||
stm32,
|
|
||||||
timer::{Tim3PartialRemap, Timer},
|
|
||||||
};
|
};
|
||||||
use tinybmp::Bmp;
|
|
||||||
|
|
||||||
use crate::profiles;
|
|
||||||
|
|
||||||
mod confirm_profile;
|
mod confirm_profile;
|
||||||
mod profile_selection;
|
mod profile_selection;
|
||||||
|
|
|
@ -1,23 +1,13 @@
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
drawable::Drawable, fonts::Text, pixelcolor::BinaryColor, pixelcolor::Rgb565, prelude::*,
|
drawable::Drawable, fonts::Text, pixelcolor::Rgb565, prelude::*,
|
||||||
primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder,
|
primitives::rectangle::Rectangle, style::PrimitiveStyleBuilder, style::TextStyleBuilder,
|
||||||
style::TextStyleBuilder,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
||||||
use profont::ProFont12Point;
|
use profont::ProFont12Point;
|
||||||
|
|
||||||
use st7735_lcd::Orientation;
|
use st7735_lcd::Orientation;
|
||||||
use stm32f1xx_hal::{
|
use stm32f1xx_hal::prelude::*;
|
||||||
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 crate::application::App;
|
use crate::application::App;
|
||||||
use crate::profiles;
|
use crate::profiles;
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
use arrayvec::ArrayString;
|
|
||||||
use core::fmt::Write;
|
|
||||||
use cortex_m::asm;
|
|
||||||
use cortex_m_rt::{entry, exception};
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565,
|
drawable::Drawable, fonts::Text, pixelcolor::Rgb565, prelude::*,
|
||||||
prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder,
|
primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder,
|
||||||
style::TextStyleBuilder,
|
style::TextStyleBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
use profont::{ProFont12Point, ProFont14Point, ProFont9Point};
|
|
||||||
use rtt_target::{rprintln, rtt_init_print};
|
|
||||||
use st7735_lcd::Orientation;
|
use st7735_lcd::Orientation;
|
||||||
use stm32f1xx_hal::{
|
use stm32f1xx_hal::{
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
|
@ -22,7 +17,6 @@ use stm32f1xx_hal::{
|
||||||
stm32,
|
stm32,
|
||||||
timer::{Tim3PartialRemap, Timer},
|
timer::{Tim3PartialRemap, Timer},
|
||||||
};
|
};
|
||||||
use tinybmp::Bmp;
|
|
||||||
|
|
||||||
use crate::application::App;
|
use crate::application::App;
|
||||||
use crate::profiles;
|
use crate::profiles;
|
||||||
|
|
|
@ -1,31 +1,15 @@
|
||||||
use arrayvec::ArrayString;
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
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::{
|
use stm32f1xx_hal::{
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
|
|
||||||
pac,
|
|
||||||
prelude::*,
|
prelude::*,
|
||||||
qei, rcc,
|
qei,
|
||||||
spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap},
|
spi::{Mode, Phase, Polarity, Spi},
|
||||||
stm32,
|
stm32,
|
||||||
timer::{Tim3PartialRemap, Timer},
|
timer::Timer,
|
||||||
};
|
};
|
||||||
use tinybmp::Bmp;
|
|
||||||
|
|
||||||
use crate::application::App;
|
use crate::application::App;
|
||||||
use crate::profiles;
|
|
||||||
|
|
||||||
pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> App {
|
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
|
// Take ownership over the raw flash and rcc devices and convert them into the corresponding
|
||||||
|
|
|
@ -1,27 +1,12 @@
|
||||||
use arrayvec::ArrayString;
|
|
||||||
use core::fmt::Write;
|
|
||||||
use cortex_m::asm;
|
|
||||||
use cortex_m_rt::{entry, exception};
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565,
|
drawable::Drawable, image::Image, pixelcolor::Rgb565, prelude::*,
|
||||||
prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder,
|
primitives::rectangle::Rectangle, style::PrimitiveStyleBuilder,
|
||||||
style::TextStyleBuilder,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
use profont::{ProFont12Point, ProFont14Point, ProFont9Point};
|
|
||||||
use rtt_target::{rprintln, rtt_init_print};
|
|
||||||
use st7735_lcd::Orientation;
|
use st7735_lcd::Orientation;
|
||||||
use stm32f1xx_hal::{
|
use stm32f1xx_hal::prelude::*;
|
||||||
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 tinybmp::Bmp;
|
use tinybmp::Bmp;
|
||||||
|
|
||||||
use crate::application::App;
|
use crate::application::App;
|
||||||
|
|
86
src/main.rs
86
src/main.rs
|
@ -2,28 +2,12 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use arrayvec::ArrayString;
|
|
||||||
use core::fmt::Write;
|
|
||||||
use cortex_m::asm;
|
use cortex_m::asm;
|
||||||
use cortex_m_rt::{entry, exception};
|
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 rtt_target::{rprintln, rtt_init_print};
|
||||||
use st7735_lcd::Orientation;
|
|
||||||
use stm32f1xx_hal::{
|
use stm32f1xx_hal::pac;
|
||||||
delay::Delay,
|
|
||||||
pac,
|
|
||||||
prelude::*,
|
|
||||||
qei::QeiOptions,
|
|
||||||
spi::{Mode, Phase, Polarity, Spi},
|
|
||||||
timer::Timer,
|
|
||||||
};
|
|
||||||
use tinybmp::Bmp;
|
|
||||||
|
|
||||||
mod application;
|
mod application;
|
||||||
mod max6675;
|
mod max6675;
|
||||||
|
@ -38,71 +22,9 @@ fn main() -> ! {
|
||||||
// Get access to the device specific peripherals from the peripheral access crate
|
// Get access to the device specific peripherals from the peripheral access crate
|
||||||
let dp = pac::Peripherals::take().unwrap();
|
let dp = pac::Peripherals::take().unwrap();
|
||||||
|
|
||||||
let mut app = application::setup(cp, dp);
|
let app = application::setup(cp, dp);
|
||||||
|
|
||||||
app.run()
|
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]
|
#[exception]
|
||||||
|
|
Loading…
Reference in New Issue