implement error view which displays all error on the display
This commit was merged in pull request #48.
This commit is contained in:
+47
-44
@@ -3,6 +3,8 @@ use crate::navigation::navigation::CARD_DATA;
|
||||
use crate::navigation::navigation::NewState;
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::peripherals::Peripherals;
|
||||
use alloc::boxed::Box;
|
||||
use core::error;
|
||||
|
||||
use alloc::format;
|
||||
use embedded_graphics::Drawable;
|
||||
@@ -37,55 +39,56 @@ impl Navigable for ScanMenu {
|
||||
fn display(
|
||||
&self,
|
||||
outputs: &mut Outputs,
|
||||
_: &Peripherals
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
let display = &mut outputs.primary_display;
|
||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
_: &Peripherals,
|
||||
) -> impl core::future::Future<Output = Result<(), Box<dyn error::Error>>> + Send {
|
||||
async move {
|
||||
let display = &mut outputs.primary_display;
|
||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
let display_area = display.bounding_box();
|
||||
let display_area = display.bounding_box();
|
||||
|
||||
Text::new("Scanning...", Point::new(20, 30), style)
|
||||
Text::new("Scanning...", Point::new(20, 30), style)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Create styles used by the drawing operations.
|
||||
let arc_stroke = PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Rgb565::WHITE)
|
||||
.stroke_width(5)
|
||||
.stroke_alignment(StrokeAlignment::Inside)
|
||||
.build();
|
||||
let character_style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
let text_style = TextStyleBuilder::new()
|
||||
.baseline(Baseline::Middle)
|
||||
.alignment(Alignment::Center)
|
||||
.build();
|
||||
|
||||
let sweep = self.progress as f32 * 360.0 / 255.0;
|
||||
|
||||
let width = display_area.size.width;
|
||||
let bounding_box =
|
||||
Rectangle::with_center(display_area.center(), Size::new_equal(4 * width / 5));
|
||||
// log::info!("bounding_box: {:?}", bounding_box);
|
||||
// log::info!("display_area: {:?}", display_area);
|
||||
// Draw an arc with a 5px wide stroke.
|
||||
Arc::new(
|
||||
bounding_box.top_left,
|
||||
bounding_box.size.width,
|
||||
90.0.deg(),
|
||||
sweep.deg(),
|
||||
)
|
||||
.into_styled(arc_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Create styles used by the drawing operations.
|
||||
let arc_stroke = PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Rgb565::WHITE)
|
||||
.stroke_width(5)
|
||||
.stroke_alignment(StrokeAlignment::Inside)
|
||||
.build();
|
||||
let character_style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
let text_style = TextStyleBuilder::new()
|
||||
.baseline(Baseline::Middle)
|
||||
.alignment(Alignment::Center)
|
||||
.build();
|
||||
|
||||
let sweep = self.progress as f32 * 360.0 / 255.0;
|
||||
|
||||
let width = display_area.size.width;
|
||||
let bounding_box =
|
||||
Rectangle::with_center(display_area.center(), Size::new_equal(4 * width / 5));
|
||||
// log::info!("bounding_box: {:?}", bounding_box);
|
||||
// log::info!("display_area: {:?}", display_area);
|
||||
// Draw an arc with a 5px wide stroke.
|
||||
Arc::new(
|
||||
bounding_box.top_left,
|
||||
bounding_box.size.width,
|
||||
90.0.deg(),
|
||||
sweep.deg(),
|
||||
)
|
||||
.into_styled(arc_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Draw centered text.
|
||||
let text = format!("{:.2}%", 100. * (self.progress as f32) / 255.);
|
||||
Text::with_text_style(&text, display_area.center(), character_style, text_style)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
core::future::ready(())
|
||||
// Draw centered text.
|
||||
let text = format!("{:.2}%", 100. * (self.progress as f32) / 255.);
|
||||
Text::with_text_style(&text, display_area.center(), character_style, text_style)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send {
|
||||
|
||||
Reference in New Issue
Block a user