Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
HardwarePWM Class Reference

Hardware pulse width modulation. More...

#include <HardwarePWM.h>

Public Member Functions

 HardwarePWM (uint8 *pins, uint8 no_of_pins)
 Instantiate hardware PWM object. More...
 
bool analogWrite (uint8 pin, uint32 duty)
 Set PWM duty cycle. More...
 
bool setDuty (uint8 pin, uint32 duty)
 Set PWM duty cycle. More...
 
uint32 getDuty (uint8 pin)
 Get PWM duty cycle. More...
 
void setPeriod (uint32 period)
 Set PWM period. More...
 
uint32 getPeriod (void)
 Get PWM period. More...
 
uint8 getChannel (uint8 pin)
 Get channel number for a pin. More...
 
uint32 getMaxDuty ()
 Get the maximum duty cycle value. More...
 

Detailed Description

Hardware pulse width modulation.

Constructor & Destructor Documentation

HardwarePWM::HardwarePWM ( uint8 *  pins,
uint8  no_of_pins 
)

Instantiate hardware PWM object.

Parameters
pinsPointer to array of pins to control
no_of_pinsQuantity of elements in array of pins

Member Function Documentation

bool HardwarePWM::analogWrite ( uint8  pin,
uint32  duty 
)

Set PWM duty cycle.

Parameters
pinGPIO to set
dutyValue of duty cycle to set pin to
Return values
boolTrue on success
uint8 HardwarePWM::getChannel ( uint8  pin)

Get channel number for a pin.

Parameters
pinGPIO to interrogate
Return values
uint8Channel of GPIO
uint32 HardwarePWM::getDuty ( uint8  pin)

Get PWM duty cycle.

Parameters
pinGPIO to get duty cycle for
Return values
uint32Value of PWM duty cycle
uint32 HardwarePWM::getMaxDuty ( )

Get the maximum duty cycle value.

Return values
uint32Maximum permissible duty cycle
Note
Attempt to set duty of a pin above this value will fail
uint32 HardwarePWM::getPeriod ( void  )

Get PWM period.

Return values
uint32Value of PWM period
bool HardwarePWM::setDuty ( uint8  pin,
uint32  duty 
)

Set PWM duty cycle.

Parameters
pinGPIO to set
dutyValue of duty cycle to set pin to
Return values
boolTrue on success
void HardwarePWM::setPeriod ( uint32  period)

Set PWM period.

Parameters
periodPWM period
Note
All PWM pins share the same period