embedded-hal icon indicating copy to clipboard operation
embedded-hal copied to clipboard

Pwm trait requires real-world time knowledge

Open eldruin opened this issue 5 years ago • 1 comments
trafficstars

The Pwm trait is cumbersome to implement in a driver like the PCA9685 driver due to the try_set_period and try_get_period methods, which depend on knowledge of the "real-world" frequency on which everything is running.

This can even be an external input and thus subject to external change plus configurable through a prescaler or power configuration and so on.

Even when solving this (e.g. by having the user provide the value directly), in the try_set_period implementation the driver will need to calculate an approximation to a combination of prescaler and/or other configs. This may be possible but I feel this is something that the driver user would rather determine themselves so that the authoritatively provided frequency is followed exactly.

Additionally, choosing a Time type seems difficult because of precision and conversion issues.

eldruin avatar Jun 20 '20 13:06 eldruin

Additionally, choosing a Time type seems difficult because of precision and conversion issues.

I have released (and continue to develop) embedded-time (#211) aimed at allowing use of Time-type values efficiently in embedded systems.

PTaylor-us avatar Jun 20 '20 15:06 PTaylor-us