Hardware pulse width modulation.
More...
#include <HardwarePWM.h>
Hardware pulse width modulation.
◆ HardwarePWM()
HardwarePWM::HardwarePWM |
( |
uint8_t * |
pins, |
|
|
uint8_t |
no_of_pins |
|
) |
| |
Instantiate hardware PWM object.
- Parameters
-
pins | Pointer to array of pins to control |
no_of_pins | Quantity of elements in array of pins |
◆ ~HardwarePWM()
virtual HardwarePWM::~HardwarePWM |
( |
| ) |
|
|
virtual |
◆ analogWrite()
bool HardwarePWM::analogWrite |
( |
uint8_t |
pin, |
|
|
uint32_t |
duty |
|
) |
| |
|
inline |
Set PWM duty cycle.
- Parameters
-
pin | GPIO to set |
duty | Value of duty cycle to set pin to |
- Return values
-
- Note
- Default frequency is 1khz but can be varied by various function
◆ getChannel()
uint8_t HardwarePWM::getChannel |
( |
uint8_t |
pin | ) |
|
Get channel number for a pin.
- Parameters
-
- Return values
-
◆ getDuty()
uint32_t HardwarePWM::getDuty |
( |
uint8_t |
pin | ) |
|
|
inline |
Get PWM duty cycle.
- Parameters
-
pin | GPIO to get duty cycle for |
- Return values
-
uint32_t | Value of PWM duty cycle |
◆ getDutyChan()
uint32_t HardwarePWM::getDutyChan |
( |
uint8_t |
chan | ) |
|
Get PWM duty cycle.
- Parameters
-
chan | Channel to get duty cycle for |
- Return values
-
uint32_t | Value of PWM duty cycle |
◆ getFrequency()
uint32_t HardwarePWM::getFrequency |
( |
uint8_t |
pin | ) |
|
Get PWM Frequency.
- Parameters
-
pin | GPIO to get frequency for |
- Return values
-
uint32_t | Value of Frequency |
◆ getMaxDuty()
uint32_t HardwarePWM::getMaxDuty |
( |
| ) |
|
|
inline |
Get the maximum duty cycle value.
- Return values
-
uint32_t | Maximum permissible duty cycle |
- Note
- Attempt to set duty of a pin above this value will fail
◆ getPeriod()
uint32_t HardwarePWM::getPeriod |
( |
| ) |
|
Get PWM period.
- Return values
-
uint32_t | Value of PWM period |
◆ setDuty()
bool HardwarePWM::setDuty |
( |
uint8_t |
pin, |
|
|
uint32_t |
duty, |
|
|
bool |
update = true |
|
) |
| |
|
inline |
Set PWM duty cycle.
- Parameters
-
pin | GPIO to set |
duty | Value of duty cycle to set pin to |
update | Update PWM output |
- Return values
-
- Note
- This function is used to set the pwm duty cycle for a given pin. If parameter 'update' is false then you have to call update() later to update duties.
◆ setDutyChan()
bool HardwarePWM::setDutyChan |
( |
uint8_t |
chan, |
|
|
uint32_t |
duty, |
|
|
bool |
update = true |
|
) |
| |
Set PWM duty cycle for a channel.
- Parameters
-
chan | Channel to set |
duty | Value of duty cycle to set channel to |
update | Update PWM output |
- Return values
-
◆ setPeriod()
void HardwarePWM::setPeriod |
( |
uint32_t |
period | ) |
|
Set PWM period.
- Parameters
-
- Note
- All PWM pins share the same period
◆ update()
void HardwarePWM::update |
( |
| ) |
|
This function is used to actually update the PWM.
The documentation for this class was generated from the following file: