Utilities for type and units conversions.
Summary
Functions
Ensures you have an integer in case you were passing a binary. Can raise, since String.to_integer/1 can raise an ArgumentError
Linux's sysfs PWM interface expects to get period and duty cycle values expressed in nanoseconds.
Functions
Ensures you have an integer in case you were passing a binary. Can raise, since String.to_integer/1 can raise an ArgumentError
iex> Pwmx.Utils.ensure_int!(10)
10
iex> Pwmx.Utils.ensure_int!("10")
10
Linux's sysfs PWM interface expects to get period and duty cycle values expressed in nanoseconds.
iex> Pwmx.Utils.to_nanoseconds(10, :ms)
10_000_000
iex> Pwmx.Utils.to_nanoseconds(10, :ns)
10