-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I added a timer:
//state.rs
impl TimerState {
pub async fn draw(&mut self, _device: &mut Device<'_>) {}
pub async fn next(&mut self, device: &mut Device<'_>) -> WatchState {
let screen = &mut device.screen;
let button = &mut device.button;
let mut secs = 60;
let timer = async {
loop {
TimerView::new(time::Duration::seconds(secs))
.draw(screen.display())
.unwrap();
screen.on();
Timer::after_secs(1).await;
secs -= 1;
if secs <= 0 {
break;
}
}
};
let next = match select(button.wait(), timer).await {
Either::First(_) => WatchState::Menu(MenuState::new(MenuView::main())),
//What am I supposed to do here with `Either::Second(_)`?
Either::Second(_) => WatchState::Menu(MenuState::new(MenuView::main())),
};
next
}
}
//lib.rs
impl TimerView {
pub fn new(remaining: time::Duration) -> Self {
Self { remaining }
}
pub fn draw<D: DrawTarget<Color = Rgb>>(&self, display: &mut D) -> Result<(), D::Error> {
display.clear(Rgb::BLACK)?;
let mut buf: heapless::String<16> = heapless::String::new();
write!(
buf,
"{:02}:{:02}",
self.remaining.whole_minutes(),
self.remaining.whole_seconds() % 60,
)
.unwrap();
let cd = Text::with_text_style(
&buf,
display.bounding_box().center(),
watch_text_style(Rgb::CSS_LIME),
TextStyleBuilder::new()
.alignment(embedded_graphics::text::Alignment::Center)
.baseline(embedded_graphics::text::Baseline::Alphabetic)
.build(),
);
let display_area = display.bounding_box();
LinearLayout::vertical(Chain::new(cd))
.with_spacing(spacing::FixedMargin(10))
.with_alignment(horizontal::Center)
.arrange()
.align_to(&display_area, horizontal::Center, vertical::Center)
.draw(display)?;
Ok(())
}
}
I think that it would be nice to have the pinetime vibrate when it ends.
Right now the timer is too slow 1 minute takes like 120 seconds.
Can I fix it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels