Skip to main content

pamoja_duty_cycle_from_fraction

Function pamoja_duty_cycle_from_fraction 

Source
#[unsafe(no_mangle)]
pub extern "C" fn pamoja_duty_cycle_from_fraction( period_us: u64, fraction: f32, ) -> PamojaDutyCycle
Expand description

Creates a duty cycle that spends a fraction of each period awake.

The time awake is rounded down to a whole microsecond and the rest of the period is spent asleep, so the two always add up to the period and the awake share never runs over the fraction.

§Arguments

  • period_us - the whole period, in microseconds.
  • fraction - the share of the period spent awake, clamped to 0.0 through 1.0. A fraction that is not a number keeps the node asleep for the whole period.

§Returns

The duty cycle.