Init
This commit is contained in:
32
src/timer.rs
Normal file
32
src/timer.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use embassy_time::{Duration, Instant};
|
||||
use lorawan_device::async_device::radio::Timer;
|
||||
|
||||
pub struct EmbassyTimer {
|
||||
start: Instant,
|
||||
}
|
||||
|
||||
impl EmbassyTimer {
|
||||
pub fn new() -> Self {
|
||||
Self { start: Instant::now() }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EmbassyTimer {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Timer for EmbassyTimer {
|
||||
fn reset(&mut self) {
|
||||
self.start = Instant::now();
|
||||
}
|
||||
|
||||
async fn at(&mut self, millis: u64) {
|
||||
embassy_time::Timer::at(self.start + Duration::from_millis(millis)).await
|
||||
}
|
||||
|
||||
async fn delay_ms(&mut self, millis: u64) {
|
||||
embassy_time::Timer::after_millis(millis).await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user