semf
semf::LedDimming Class Reference

This class uses PwmOut and a SoftwareTimer in order to generate different waveforms. (e.g. sine, triangle), for switching the LED on and off. Additionally a pulsing mode and a constant on / off mode is available. More...

#include <leddimming.h>

Inheritance diagram for semf::LedDimming:
Inheritance graph
Collaboration diagram for semf::LedDimming:
Collaboration graph

Public Member Functions

 LedDimming (PwmOut &dimmPwmOut, app::TimeBase &timebase)
 Constructor. More...
 
 LedDimming (const LedDimming &other)=delete
 
void setBrightness (uint16_t maxBrightness) override
 Sets the maximum brightness of the LED. More...
 
void setBrightness (uint16_t minBrightness, uint16_t maxBrightness) override
 Sets the minimum and maximum brightness of the LED. More...
 
void setOn () override
 
void setOff () override
 
void toggle () override
 
void setBlinking (unsigned int onOffTime) override
 Start blinking the led with the same on-off time. More...
 
void setBlinking (unsigned int onTime, unsigned int offTime) override
 Starts blinking the led with different on and off time. More...
 
void setSine (unsigned int periodInTimeBaseTicks, unsigned int startIndexInTimeBaseTicks) override
 Starts showing a sine waveform on the led. More...
 
void setSine (unsigned int periodInTimeBaseTicks) override
 Starts showing a sine waveform on the led. More...
 
void setTriangle (unsigned int periodInTimeBaseTicks, unsigned int startIndexInTimeBaseTicks) override
 Starts showing a triangle waveform on the led. More...
 
void setTriangle (unsigned int periodInTimeBaseTicks) override
 Starts showing a triangle waveform on the led. Maximal brightness can be set by setBrightness function. Waveform starts at zero and is increasing afterwards. More...
 
Mode mode () const override
 Returns the active mode of the led. More...
 
- Public Member Functions inherited from semf::app::LedDimming
virtual ~LedDimming ()=default
 
virtual void setBrightness (uint16_t maxBrightness)=0
 Sets the maximum brightness of the LED. More...
 
virtual void setBrightness (uint16_t minBrightness, uint16_t maxBrightness)=0
 Sets the minimum and maximum brightness of the LED. More...
 
virtual void setBlinking (unsigned int onOffTime)=0
 Start blinking the led with the same on-off time. More...
 
virtual void setBlinking (unsigned int onTime, unsigned int offTime)=0
 Starts blinking the led with different on and off time. More...
 
virtual void setSine (unsigned int periodInTimeBaseTicks, unsigned int startIndexInTimeBaseTicks)=0
 Starts showing a sine waveform on the led. More...
 
virtual void setSine (unsigned int periodInTimeBaseTicks)=0
 Starts showing a sine waveform on the led. More...
 
virtual void setTriangle (unsigned int periodInTimeBaseTicks, unsigned int startIndexInTimeBaseTicks)=0
 Starts showing a triangle waveform on the led. More...
 
virtual void setTriangle (unsigned int periodInTimeBaseTicks)=0
 Starts showing a triangle waveform on the led. Maximal brightness can be set by setBrightness function. Waveform starts at zero and is increasing afterwards. More...
 
virtual Mode mode () const =0
 Returns the active mode of the led. More...
 
- Public Member Functions inherited from semf::app::Led
virtual ~Led ()=default
 
virtual void setOn ()=0
 
virtual void setOff ()=0
 
virtual void toggle ()=0
 

Additional Inherited Members

- Public Types inherited from semf::app::LedDimming
enum class  Mode : uint8_t {
  Off = 0 , On , Blinking , Sine ,
  Triangule
}
 

Detailed Description

This class uses PwmOut and a SoftwareTimer in order to generate different waveforms. (e.g. sine, triangle), for switching the LED on and off. Additionally a pulsing mode and a constant on / off mode is available.

PwmOut controls the output amplitude (brightness), while SoftwareTimer controls the time intervals for the pulse's samples and the pulse's period.

PwmOut has to be correctly configured before registering them to the class.

The timing of the SoftwareTimer depends to the hardware predefined configuration (e.g. clock speed, prescaler, etc.), recommended is the SysTick with 1ms resolution.

Timing resolution [ms] = 1000 * Auto-reload register value of the timer / timer's input clock[Hz].

Definition at line 24 of file leddimming.h.

Constructor & Destructor Documentation

◆ LedDimming() [1/2]

semf::LedDimming::LedDimming ( PwmOut dimmPwmOut,
app::TimeBase timebase 
)

Constructor.

Parameters
dimmPwmOutReference to the PwmOut object used for dimming.
timebaseTimeBase as clock source for the internal SoftwareTimer.

Definition at line 17 of file leddimming.cpp.

◆ LedDimming() [2/2]

semf::LedDimming::LedDimming ( const LedDimming other)
explicitdelete

Member Function Documentation

◆ mode()

LedDimming::Mode semf::LedDimming::mode ( ) const
overridevirtual

Returns the active mode of the led.

Returns
Active led mode setting.

Implements semf::app::LedDimming.

Definition at line 155 of file leddimming.cpp.

◆ setBlinking() [1/2]

void semf::LedDimming::setBlinking ( unsigned int  onOffTime)
overridevirtual

Start blinking the led with the same on-off time.

The timing of the SoftwareTimer module depends to the hardware predefined configuration (e.g. clock speed, prescaler, etc.), recommended is the SysTick with 1ms resolution.

Timing resolution [ms] = 1000 * Auto-reload register value of the timer / timer's input clock[Hz].

Parameters
onOffTimeOn and off time.

Implements semf::app::LedDimming.

Definition at line 78 of file leddimming.cpp.

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

◆ setBlinking() [2/2]

void semf::LedDimming::setBlinking ( unsigned int  onTime,
unsigned int  offTime 
)
overridevirtual

Starts blinking the led with different on and off time.

The timing of the SoftwareTimer module depends to the hardware predefined configuration (e.g. clock speed, prescaler, etc.), recommended is the SysTick with 1ms resolution.

Timing resolution [ms] = 1000 * Auto-reload register value of the timer / timer's input clock[Hz].

Parameters
onTimeOn time.
offTimeOff time.

Implements semf::app::LedDimming.

Definition at line 83 of file leddimming.cpp.

Here is the call graph for this function:

◆ setBrightness() [1/2]

void semf::LedDimming::setBrightness ( uint16_t  maxBrightness)
overridevirtual

Sets the maximum brightness of the LED.

Adjusts the LED brightness in blink mode and sets the maximum brightness for sine and triangle mode. There is also a function to set the minimum and maximum brightness for sine and triangle mode.

Parameters
maxBrightnessBrightness value, which is between 0 and 1000.

Implements semf::app::LedDimming.

Definition at line 23 of file leddimming.cpp.

Here is the call graph for this function:

◆ setBrightness() [2/2]

void semf::LedDimming::setBrightness ( uint16_t  minBrightness,
uint16_t  maxBrightness 
)
overridevirtual

Sets the minimum and maximum brightness of the LED.

For sine and triangle modes this function sets the minimum and maximum brightness. There is also a function to set only the maximum brightness, if only blinking and on / off is used. For blinking, on / off, the minBrightness is ignored.

Parameters
minBrightnessBrightness value, which is between 0 and 1000.
maxBrightnessBrightness value, which is between 0 and 1000.

Implements semf::app::LedDimming.

Definition at line 35 of file leddimming.cpp.

Here is the call graph for this function:

◆ setOff()

void semf::LedDimming::setOff ( )
overridevirtual

Switch the LED off.

Implements semf::app::Led.

Definition at line 61 of file leddimming.cpp.

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

◆ setOn()

void semf::LedDimming::setOn ( )
overridevirtual

Switch the LED on.

Implements semf::app::Led.

Definition at line 53 of file leddimming.cpp.

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

◆ setSine() [1/2]

void semf::LedDimming::setSine ( unsigned int  periodInTimeBaseTicks)
overridevirtual

Starts showing a sine waveform on the led.

Note
Maximal brightness can be set by setBrightness() function.
Waveform starts at half brightness setting and is increasing afterwards.
Parameters
periodInTimeBaseTicksPeriod of triangle is timer ticks by TimeBase (period time = periodInTimeBaseTicks * TimeBase timer period).

Implements semf::app::LedDimming.

Definition at line 109 of file leddimming.cpp.

Here is the call graph for this function:

◆ setSine() [2/2]

void semf::LedDimming::setSine ( unsigned int  periodInTimeBaseTicks,
unsigned int  startIndexInTimeBaseTicks 
)
overridevirtual

Starts showing a sine waveform on the led.

Maximal brightness can be set by setBrightness() function. Waveform starts at startIndexInTimeBaseTicks. Minimal brightness is zero in these examples.

  • If periodInTimeBaseTicks = 1000 and startIndexInTimeBaseTicks = 0, the waveform starts at half brightness increasing afterwards.
  • If periodInTimeBaseTicks = 1000 and startIndexInTimeBaseTicks = 250, the waveform starts at the maximum decreasing afterwards.
  • If periodInTimeBaseTicks = 1000 and startIndexInTimeBaseTicks = 500, the waveform starts at half brightness decreasing afterwards.
  • If periodInTimeBaseTicks = 1000 and startIndexInTimeBaseTicks = 750, the waveform starts at zero increasing afterwards.
Parameters
periodInTimeBaseTicksPeriod of triangle is timer ticks by TimeBase (period time = periodInTimeBaseTicks * TimeBase timer period).
startIndexInTimeBaseTicksindex in period to start waveform.

Implements semf::app::LedDimming.

Definition at line 99 of file leddimming.cpp.

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

◆ setTriangle() [1/2]

void semf::LedDimming::setTriangle ( unsigned int  periodInTimeBaseTicks)
overridevirtual

Starts showing a triangle waveform on the led. Maximal brightness can be set by setBrightness function. Waveform starts at zero and is increasing afterwards.

Parameters
periodInTimeBaseTicksPeriod of triangle is timer ticks by TimeBase (period time = periodInTimeBaseTicks * TimeBase timer period).

Implements semf::app::LedDimming.

Definition at line 137 of file leddimming.cpp.

Here is the call graph for this function:

◆ setTriangle() [2/2]

void semf::LedDimming::setTriangle ( unsigned int  periodInTimeBaseTicks,
unsigned int  startIndexInTimeBaseTicks 
)
overridevirtual

Starts showing a triangle waveform on the led.

Maximal brightness can be set by setBrightness function. Waveform starts at startIndexInTimeBaseTicks. Minimal brightness is zero in these examples.

  • If periodInTimeBaseTicks = 1000 and startIndexInTimeBaseTicks = 0, the waveform starts at the minimum increasing afterwards.
  • If periodInTimeBaseTicks = 1000 and startIndexInTimeBaseTicks = 500, the waveform starts at the maximum decreasing afterwards.
Parameters
periodInTimeBaseTicksPeriod of triangle is timer ticks by TimeBase (period time = periodInTimeBaseTicks * TimeBase timer period).
startIndexInTimeBaseTicksindex in period to start waveform.

Implements semf::app::LedDimming.

Definition at line 127 of file leddimming.cpp.

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

◆ toggle()

void semf::LedDimming::toggle ( )
overridevirtual

Toggle the led state.

Implements semf::app::Led.

Definition at line 69 of file leddimming.cpp.

Here is the call graph for this function: