pub struct DutyCycle { /* private fields */ }Expand description
A repeating wake/sleep schedule.
Duty cycling is the simplest way to make a battery or solar node last: stay awake just long enough to do the work, then sleep through the rest of the period. The duty fraction - the share of each period spent awake - is a good first proxy for average power draw, so roughly halving it halves the energy the cycle costs.
§Examples
use core::time::Duration;
use pamoja_power::DutyCycle;
// Wake for one second every minute.
let cycle = DutyCycle::new(Duration::from_secs(1), Duration::from_secs(59));
assert_eq!(cycle.period(), Duration::from_secs(60));
assert!((cycle.fraction() - 1.0 / 60.0).abs() < 1e-6);Implementations§
Trait Implementations§
impl Copy for DutyCycle
impl Eq for DutyCycle
impl StructuralPartialEq for DutyCycle
Auto Trait Implementations§
impl Freeze for DutyCycle
impl RefUnwindSafe for DutyCycle
impl Send for DutyCycle
impl Sync for DutyCycle
impl Unpin for DutyCycle
impl UnsafeUnpin for DutyCycle
impl UnwindSafe for DutyCycle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more