-
Notifications
You must be signed in to change notification settings - Fork 616
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Device.GpioContains types for using general-purpose I/O (GPIO) pinsContains types for using general-purpose I/O (GPIO) pins
Description
Currently the PwmController class requires passing channel and chip every time.
There are couple of disadvantages of such approach:
- APIs are inconvenient and require user to store pin value and pass it on every call
- PWM settings along with pin have to be dragged along to all depending classes which also need to access PWM settings
- it is not known if channel is open or not
- other PWM implementation (i.e. SoftwarePwm does not use channel and chip and uses pin instead)
my proposition is to have simpler design which looks more or less like this:
public abstract PwmDevice : IDisposable
{
protected PwmDevice() {}
public abstract double FrequencyHz { get; } // note: can't change after setting up
public abstract double DutyCyclePercentage { get; set; } // 0.0 - 1.0
public static PwmDevice Create(int chip, int channel, double frequencyHz = 50.0, double dutyCyclePercentage = 0.0) { /* create default pwm device depending on the OS, default values are arbitrary and TBD */ }
}Notes:
- change range of DutyCycle from 0 - 100 to 0-100% because % in math equals to 0.01 and 100%=1.0. Also it combines with any other math done in the app much better. I.e.:
dutyCycle = a/band notdutyCycle = a/b*100 - channel will be open when constructed by default, when dutyCycle is 0 it technically does nothing anyway
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Device.GpioContains types for using general-purpose I/O (GPIO) pinsContains types for using general-purpose I/O (GPIO) pins