semf
semf::SoftPwm Class Reference

The SoftPwm class outputs a PWM signal on the given GPIO. More...

#include <softpwm.h>

Inheritance diagram for semf::SoftPwm:
Inheritance graph
Collaboration diagram for semf::SoftPwm:
Collaboration graph

Public Member Functions

 SoftPwm (Gpio &output, app::TimeBase &timebase, bool inverted=false)
 Constructor. More...
 
 SoftPwm (const SoftPwm &other)=delete
 
virtual ~SoftPwm ()=default
 
void setMaxValue (unsigned int maxValue) override
 Set the maximum possible PWM value. More...
 
unsigned int maxValue () const override
 Returns the maximum possible PWM value. More...
 
void set (unsigned int value, bool inverted=false) override
 Set a PWM value. Duty cycle is value / maxValue. More...
 
unsigned int value () const override
 Returns the current PWM value. More...
 
void start () override
 
void stop () override
 
bool isEnabled () const override
 Returns the current status of PWM module. More...
 
- Public Member Functions inherited from semf::Pwm
virtual ~Pwm ()=default
 
virtual void setMaxValue (unsigned int maxValue)=0
 Set the maximum possible PWM value. More...
 
virtual unsigned int maxValue () const =0
 Returns the maximum possible PWM value. More...
 
virtual void set (unsigned int value, bool inverted=false)=0
 Set a PWM value. Duty cycle is value / maxValue. More...
 
virtual unsigned int value () const =0
 Returns the current PWM value. More...
 
virtual void start ()=0
 
virtual void stop ()=0
 
virtual bool isEnabled () const =0
 Returns the current status of PWM module. More...
 

Additional Inherited Members

- Public Attributes inherited from semf::Pwm
Signal< Errorerror
 

Detailed Description

The SoftPwm class outputs a PWM signal on the given GPIO.

The timing of the PWM is controlled by an internal SoftwareTimer. The cycle time of a PWM can can be set by setMaxValue() function and lasts, maxValue x time base cycle time. The duty cycle can be set by set() function.

Definition at line 30 of file softpwm.h.

Constructor & Destructor Documentation

◆ SoftPwm() [1/2]

semf::SoftPwm::SoftPwm ( Gpio output,
app::TimeBase timebase,
bool  inverted = false 
)

Constructor.

Parameters
outputGPIO to output the SoftPwm.
timebaseTimeBase used for internal SoftwareTimer.
invertedtrue for inverted PWM signal on the output pin.

Definition at line 15 of file softpwm.cpp.

◆ SoftPwm() [2/2]

semf::SoftPwm::SoftPwm ( const SoftPwm other)
explicitdelete

◆ ~SoftPwm()

virtual semf::SoftPwm::~SoftPwm ( )
virtualdefault

Member Function Documentation

◆ isEnabled()

bool semf::SoftPwm::isEnabled ( ) const
overridevirtual

Returns the current status of PWM module.

Returns
  • true: PWM is enabled and active,
  • false: PWM is disabled and not active.

Implements semf::Pwm.

Definition at line 61 of file softpwm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxValue()

unsigned int semf::SoftPwm::maxValue ( ) const
overridevirtual

Returns the maximum possible PWM value.

Returns
The maximum possible PWM value.

Implements semf::Pwm.

Definition at line 27 of file softpwm.cpp.

Here is the caller graph for this function:

◆ set()

void semf::SoftPwm::set ( unsigned int  value,
bool  inverted = false 
)
overridevirtual

Set a PWM value. Duty cycle is value / maxValue.

Parameters
valueThe new PWM value.
invertedInvert the PWM output.

Implements semf::Pwm.

Definition at line 32 of file softpwm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMaxValue()

void semf::SoftPwm::setMaxValue ( unsigned int  maxValue)
overridevirtual

Set the maximum possible PWM value.

Parameters
maxValueThe maximum possible PWM value.

Implements semf::Pwm.

Definition at line 21 of file softpwm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void semf::SoftPwm::start ( )
overridevirtual

Start the PWM hardware.

Implements semf::Pwm.

Definition at line 48 of file softpwm.cpp.

Here is the caller graph for this function:

◆ stop()

void semf::SoftPwm::stop ( )
overridevirtual

Stop the PWM hardware.

Implements semf::Pwm.

Definition at line 54 of file softpwm.cpp.

Here is the call graph for this function:

◆ value()

unsigned int semf::SoftPwm::value ( ) const
overridevirtual

Returns the current PWM value.

Returns
The current PWM value.

Implements semf::Pwm.

Definition at line 43 of file softpwm.cpp.

Here is the caller graph for this function: