Skip to content

Commit 20b6cc9

Browse files
committed
init meeting sign ui title and progress outline
1 parent 665d248 commit 20b6cc9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/control_panel/state.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ impl ControlPanelState {
145145
USBPowerMosfet::USB_POWER_2_TEXT.draw(&mut self.display)?;
146146
USBPowerMosfet::One.draw(&mut self.display, self.usb_power_1.output_level())?;
147147
USBPowerMosfet::Two.draw(&mut self.display, self.usb_power_2.output_level())?;
148+
MeetingSignUI::TITLE_TEXT.draw(&mut self.display)?;
149+
MeetingSignUI.draw(&mut self.display, Level::High)?;
148150

149151
self.display.flush()?;
150152
Ok(())
@@ -457,3 +459,51 @@ impl UISection {
457459
Self::BORDER_RADIUS,
458460
);
459461
}
462+
463+
struct MeetingSignUI;
464+
impl MeetingSignUI {
465+
const TEXT_FONT: MonoFont<'_> = ascii::FONT_6X12;
466+
const MIDDLE_X: i32 = UISection::USB_POWER_X
467+
+ (UISection::USB_POWER_SIZE.width + (UISection::MEETING_SIGN_SIZE.width / 2)
468+
- UISection::BORDER_WIDTH) as i32;
469+
470+
const STYLE: MonoTextStyle<'_, BinaryColor> =
471+
MonoTextStyle::new(&Self::TEXT_FONT, BinaryColor::On);
472+
const CENTER_ALIGNED: TextStyle = TextStyleBuilder::new()
473+
.alignment(Alignment::Center)
474+
// .baseline(Baseline::Middle)
475+
.build();
476+
477+
pub const TITLE_TEXT: Text<'_, MonoTextStyle<'_, BinaryColor>> = Text::with_text_style(
478+
"Meeting Sign",
479+
Point::new(Self::MIDDLE_X, 50),
480+
Self::STYLE,
481+
Self::CENTER_ALIGNED,
482+
);
483+
484+
pub const BORDER_ON_STYLE: PrimitiveStyle<BinaryColor> =
485+
PrimitiveStyle::with_stroke(BinaryColor::On, 1);
486+
pub const BORDER_OFF_STYLE: PrimitiveStyle<BinaryColor> =
487+
PrimitiveStyle::with_stroke(BinaryColor::Off, 1);
488+
const PROGRESS_SIZE: Size = Size::new(UISection::MEETING_SIGN_SIZE.width - 20, 12);
489+
pub const PROGRESS_OUTLINE: RoundedRectangle = RoundedRectangle::with_equal_corners(
490+
Rectangle::new(
491+
Point::new(Self::MIDDLE_X - (Self::PROGRESS_SIZE.width as i32 / 2), 25),
492+
Self::PROGRESS_SIZE,
493+
),
494+
Size::new(3, 3),
495+
);
496+
497+
pub fn draw<D: DrawTarget<Color = BinaryColor>>(
498+
&self,
499+
target: &mut D,
500+
power: Level,
501+
) -> Result<(), D::Error> {
502+
let style = match power {
503+
Level::High => Self::BORDER_ON_STYLE,
504+
Level::Low => Self::BORDER_OFF_STYLE,
505+
};
506+
Self::PROGRESS_OUTLINE.draw_styled(&style, target)?;
507+
Ok(())
508+
}
509+
}

0 commit comments

Comments
 (0)