Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
PWM Class Referenceabstract

Abstract interface for a PWM driver. More...

#include <PWM.hxx>

Inheritance diagram for PWM:
LinuxPWM PCA9685PWMBit Stm32PWMGroup::Channel TivaPWM openmrn_arduino::Esp32Ledc::Channel

Public Member Functions

virtual void set_period (uint32_t counts)=0
 Set PWM period.
 
virtual uint32_t get_period ()=0
 Get PWM period.
 
virtual void set_duty (uint32_t counts)=0
 Sets the duty cycle.
 
virtual uint32_t get_duty ()=0
 Gets the duty cycle.
 
void set_duty_percent (uint8_t percent)
 Sets the duty cycle.
 
uint8_t get_duty_percent ()
 Gets the duty cycle.
 
virtual uint32_t get_period_max ()=0
 Get max period supported.
 
virtual uint32_t get_period_min ()=0
 Get min period supported.
 

Protected Member Functions

constexpr PWM ()=default
 Constructor.
 
 ~PWM ()=default
 Destructor.
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (PWM)
 

Detailed Description

Abstract interface for a PWM driver.

Definition at line 42 of file PWM.hxx.

Constructor & Destructor Documentation

◆ ~PWM()

PWM::~PWM ( )
protecteddefault

Destructor.

This is protected, because only child classes should be allowed to destruct a PWM; but no implementation exists in order to make the the destructor trivial for C++. A trivial destructor is required for a constexpr class.

Member Function Documentation

◆ get_duty()

virtual uint32_t PWM::get_duty ( )
pure virtual

Gets the duty cycle.

Returns
counts duty cycle in counts

Implemented in PCA9685PWMBit, openmrn_arduino::Esp32Ledc::Channel, Stm32PWMGroup::Channel, TivaPWM, and LinuxPWM.

◆ get_duty_percent()

uint8_t PWM::get_duty_percent ( )
inline

Gets the duty cycle.

Returns
counts duty cycle in percent

Definition at line 71 of file PWM.hxx.

◆ get_period()

virtual uint32_t PWM::get_period ( )
pure virtual

Get PWM period.

Returns
PWM period in counts

Implemented in PCA9685PWMBit, openmrn_arduino::Esp32Ledc::Channel, Stm32PWMGroup::Channel, TivaPWM, and LinuxPWM.

◆ get_period_max()

virtual uint32_t PWM::get_period_max ( )
pure virtual

Get max period supported.

Returns
period in counts

Implemented in PCA9685PWMBit, openmrn_arduino::Esp32Ledc::Channel, Stm32PWMGroup::Channel, TivaPWM, and LinuxPWM.

◆ get_period_min()

virtual uint32_t PWM::get_period_min ( )
pure virtual

Get min period supported.

Returns
period in counts

Implemented in PCA9685PWMBit, openmrn_arduino::Esp32Ledc::Channel, Stm32PWMGroup::Channel, TivaPWM, and LinuxPWM.

◆ set_duty()

virtual void PWM::set_duty ( uint32_t  counts)
pure virtual

Sets the duty cycle.

Parameters
countsduty cycle in counts

Implemented in PCA9685PWMBit, openmrn_arduino::Esp32Ledc::Channel, Stm32PWMGroup::Channel, TivaPWM, and LinuxPWM.

◆ set_duty_percent()

void PWM::set_duty_percent ( uint8_t  percent)
inline

Sets the duty cycle.

Parameters
countsduty cycle in percent, range 0 to 100

Definition at line 63 of file PWM.hxx.

◆ set_period()

virtual void PWM::set_period ( uint32_t  counts)
pure virtual

Set PWM period.

Parameters
PWMperiod in counts

Implemented in PCA9685PWMBit, openmrn_arduino::Esp32Ledc::Channel, Stm32PWMGroup::Channel, TivaPWM, and LinuxPWM.


The documentation for this class was generated from the following file: