The class represent a pulse wide modulation file system interface. More...
Header: | #include <Pwm> |
Inherits: |
enum | Polarity { PolarityNormal, PolarityInversed, PolarityInvalid } |
Pwm(int chipNumber, QObject * parent = nullptr) | |
~Pwm() | |
int | chipNumber() |
bool | disable() |
long | dutyCycle() |
bool | enable() |
bool | exportPwm() |
double | frequency() |
bool | isEnabled() |
int | percentage() |
long | period() |
Pwm::Polarity | polarity() |
bool | setDutyCycle(long nanoSeconds) |
bool | setFrequency(double kHz) |
bool | setPercentage(int percentage) |
bool | setPeriod(long nanoSeconds) |
bool | setPolarity(Pwm::Polarity polarity) |
bool | isAvailable() |
The class represent a pulse wide modulation file system interface.
This class provides a convenient access to the linux kernel PWM (pulse wide modulation) file system.
By default, this class will check in the system path /sys/class/pwm/
for any PWM chips. You can find the kernel documentation here.
This class assumes a file system format where each hardware PWM chip has his own filepath.
/sys/class/pwm/pwmchip0 /sys/class/pwm/pwmchip1
The number pwmchip0
represents the chipNumber.
Constant | Value | Description |
---|---|---|
Pwm::PolarityNormal | 0 | Normal polarity. This is the default value. |
Pwm::PolarityInversed | 1 | Inversed polarity. |
Pwm::PolarityInvalid | 2 | The current polarity value is invalid. |
Constructs a new Pwm interface for the given chipNumber (/sys/class/pwm/pwmchip<chipNumber>
) with the given parent.
Destructor for this Pwm interface.
Returns the chip number of this Pwm.
The chip number indicates which file path will be used: /sys/class/pwm/pwmchip<chipNumber>
.
Returns true, if this Pwm interface has been disabled successfully.
Returns the duty cycle [ns] of the Pwm. The duty cycle is the active time of one period.
See also setDutyCycle().
Returns true, if this Pwm interface has been enabled successfully.
Returns true, if this Pwm interface has been exported successfully.
Returns the frequency [kHz] of the Pwm.
See also setFrequency().
[static]
bool Pwm::isAvailable()Returns true, if the path /sys/class/pwm
exists and is not empty.
Returns true, if this Pwm interface is enabled.
Returns the current percentage of this Pwm.
See also setPercentage().
Returns the period of this PWM.
See also setPeriod().
Returns the Polarity of this Pwm.
See also setPolarity().
Returns true, if the duty cycle [ns] of the Pwm has been set successfully to the given nanoSeconds. The duty cycle is the active time of one period.
See also dutyCycle().
Returns true, if the frequency [kHz] of this Pwm has been set successfully to the given kHz.
See also frequency().
Returns true, if the percentage of this Pwm has been set to percentage successfully.
See also percentage().
Returns true, if the period of this Pwm has been set to nanoSeconds successfully.
See also period().
Returns true, if the polarity of this Pwm has been set to polarity successfully.
See also polarity().