diff --git a/src/application/confirm_profile.rs b/src/application/confirm_profile.rs
index 85869cd..392b957 100644
--- a/src/application/confirm_profile.rs
+++ b/src/application/confirm_profile.rs
@@ -4,7 +4,6 @@ use embedded_graphics::{
};
use embedded_hal::digital::v2::{InputPin, OutputPin};
-use profont::{ProFont12Point, ProFont14Point};
use st7735_lcd::Orientation;
use stm32f1xx_hal::prelude::*;
@@ -21,44 +20,12 @@ impl App {
disp.set_orientation(&Orientation::LandscapeSwapped)
.unwrap();
- let style_black = PrimitiveStyleBuilder::new()
- .fill_color(Rgb565::BLACK)
- .build();
- let rect = Rectangle::new(Point::new(0, 0), Point::new(160, 128)).into_styled(style_black);
+ let rect = Rectangle::new(Point::new(0, 0), Point::new(160, 128))
+ .into_styled(self.styles.fill_black);
rect.draw(&mut disp).unwrap();
- let text = TextStyleBuilder::new(ProFont12Point)
- .text_color(Rgb565::WHITE)
- .build();
-
- let text_big = TextStyleBuilder::new(ProFont14Point)
- .text_color(Rgb565::WHITE)
- .build();
-
- let text_big_black = TextStyleBuilder::new(ProFont14Point)
- .text_color(Rgb565::BLACK)
- .build();
-
- let normal_box = PrimitiveStyleBuilder::new()
- .fill_color(Rgb565::BLACK)
- .stroke_color(Rgb565::WHITE)
- .stroke_width(1)
- .build();
-
- let ok_box = PrimitiveStyleBuilder::new()
- .fill_color(Rgb565::GREEN)
- .stroke_color(Rgb565::WHITE)
- .stroke_width(1)
- .build();
-
- let cancel_box = PrimitiveStyleBuilder::new()
- .fill_color(Rgb565::RED)
- .stroke_color(Rgb565::WHITE)
- .stroke_width(1)
- .build();
-
Text::new("Confirm profile", Point::new(4, 4))
- .into_styled(text)
+ .into_styled(self.styles.text)
.draw(&mut disp)
.unwrap();
@@ -66,7 +33,7 @@ impl App {
profiles::REFLOW_PROFILES[self.selected_profile].get_name(),
Point::new(20, 50),
)
- .into_styled(text_big)
+ .into_styled(self.styles.text_big)
.draw(&mut disp)
.unwrap();
@@ -77,25 +44,41 @@ impl App {
while press_count < 5 {
if needs_redraw {
- let style = if confirmed { ok_box } else { normal_box };
+ let style = if confirmed {
+ self.styles.ok_box
+ } else {
+ self.styles.normal_box
+ };
Rectangle::new(Point::new(4, 104), Point::new(70, 124))
.into_styled(style)
.draw(&mut disp)
.unwrap();
- let text_style = if confirmed { text_big_black } else { text_big };
+ let text_style = if confirmed {
+ self.styles.text_big_black
+ } else {
+ self.styles.text_big
+ };
Text::new("Start", Point::new(12, 105))
.into_styled(text_style)
.draw(&mut disp)
.unwrap();
- let style = if !confirmed { cancel_box } else { normal_box };
+ let style = if !confirmed {
+ self.styles.cancel_box
+ } else {
+ self.styles.normal_box
+ };
Rectangle::new(Point::new(90, 104), Point::new(155, 124))
.into_styled(style)
.draw(&mut disp)
.unwrap();
- let text_style = if !confirmed { text_big_black } else { text_big };
+ let text_style = if !confirmed {
+ self.styles.text_big_black
+ } else {
+ self.styles.text_big
+ };
Text::new("Cancel", Point::new(96, 105))
.into_styled(text_style)
.draw(&mut disp)
diff --git a/src/application/mod.rs b/src/application/mod.rs
index 057517d..4caa117 100644
--- a/src/application/mod.rs
+++ b/src/application/mod.rs
@@ -1,3 +1,5 @@
+use embedded_hal::digital::v2::{InputPin, OutputPin};
+use st7735_lcd::Orientation;
use stm32f1xx_hal::{
delay::Delay,
gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
@@ -11,9 +13,12 @@ mod profile_selection;
mod run_profile;
mod setup;
mod splash;
+mod styles;
pub use setup::setup;
+use styles::Styles;
+
type AppSPI = Spi<
pac::SPI1,
Spi1NoRemap,
@@ -30,6 +35,9 @@ type AppQEI = qei::Qei<
(gpiob::PB4>, gpiob::PB5>),
>;
+type AppDisp =
+ st7735_lcd::ST7735>, gpioa::PA1