dashboard/mode/
init_charging.rs

1use crate::display_mod::{CENTER_POINT, DisplayDevice};
2use embedded_graphics::mono_font::MonoTextStyle;
3use embedded_graphics::mono_font::iso_8859_13::FONT_10X20;
4use embedded_graphics::prelude::WebColors;
5use embedded_graphics::primitives::StyledDrawable;
6use embedded_graphics::{
7    Drawable,
8    pixelcolor::Rgb666,
9    prelude::*,
10    primitives::{Arc, PrimitiveStyle},
11    text::{Alignment, Text},
12};
13
14pub const ANGLE_START: f32 = 130f32;
15pub const ARC_DIAMTER: u32 = 160;
16pub const BORDER_WIDTH: u32 = 2;
17pub const BATT_FONT_WIDTH: u32 = 20;
18pub const BATT_FONT_HEIGHT: u32 = 35;
19
20pub fn init_render_charging_gui(display: &mut DisplayDevice) {
21    // Render loading bar border
22    let border_style = PrimitiveStyle::with_stroke(Rgb666::CSS_DARK_GRAY, 12 + BORDER_WIDTH * 2);
23    Arc::with_center(
24        CENTER_POINT,
25        ARC_DIAMTER,
26        (ANGLE_START - BORDER_WIDTH as f32).deg(),
27        (360.0 - (ANGLE_START - 90.0 - BORDER_WIDTH as f32) * 2.0).deg(),
28    )
29    .draw_styled(&border_style, display)
30    .unwrap();
31
32    // Render Speed Unit
33    let batt_unit_style = MonoTextStyle::new(&FONT_10X20, Rgb666::WHITE);
34
35    Text::with_alignment(
36        "V",
37        CENTER_POINT
38            + Point::new(
39                BATT_FONT_WIDTH as i32 + FONT_10X20.character_size.width as i32 + 5,
40                BATT_FONT_HEIGHT as i32 / 2,
41            ),
42        batt_unit_style,
43        Alignment::Right,
44    )
45    .draw(display)
46    .unwrap();
47}