HardwarePWM Class Reference
Hardware pulse width modulation. More...
#include <HardwarePWM.h>
Public Member Functions | |
HardwarePWM (uint8_t *pins, uint8_t no_of_pins) | |
Instantiate hardware PWM object. More... | |
virtual | ~HardwarePWM () |
bool | analogWrite (uint8_t pin, uint32_t duty) |
Set PWM duty cycle. More... | |
bool | setDutyChan (uint8_t chan, uint32_t duty, bool update=true) |
Set PWM duty cycle for a channel. More... | |
bool | setDuty (uint8_t pin, uint32_t duty, bool update=true) |
Set PWM duty cycle. More... | |
uint32_t | getDutyChan (uint8_t chan) |
Get PWM duty cycle. More... | |
uint32_t | getDuty (uint8_t pin) |
Get PWM duty cycle. More... | |
void | setPeriod (uint32_t period) |
Set PWM period. More... | |
uint32_t | getPeriod () |
Get PWM period. More... | |
uint8_t | getChannel (uint8_t pin) |
Get channel number for a pin. More... | |
uint32_t | getMaxDuty () |
Get the maximum duty cycle value. More... | |
void | update () |
This function is used to actually update the PWM. More... | |
Detailed Description
Hardware pulse width modulation.
Constructor & Destructor Documentation
◆ 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 |
Member Function Documentation
◆ analogWrite()
|
inline |
Set PWM duty cycle.
- Parameters
-
pin GPIO to set duty Value of duty cycle to set pin to
- Return values
-
bool True on success
- 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
-
pin GPIO to interrogate
- Return values
-
uint8_t Channel of GPIO
◆ getDuty()
|
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
◆ 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()
Set PWM duty cycle.
- Parameters
-
pin GPIO to set duty Value of duty cycle to set pin to update Update PWM output
- Return values
-
bool True on success
- 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()
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
-
bool True on success
◆ setPeriod()
void HardwarePWM::setPeriod | ( | uint32_t | period | ) |
Set PWM period.
- Parameters
-
period PWM period
- 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: