semf
semf::app::LedDimming Class Referenceabstract

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::app::LedDimming:
Inheritance graph
Collaboration diagram for semf::app::LedDimming:
Collaboration graph

Public Types

enum class  Mode : uint8_t {
  Off = 0 , On , Blinking , Sine ,
  Triangule
}
 

Public Member Functions

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
 

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 34 of file leddimming.h.

Member Enumeration Documentation

◆ Mode

enum class semf::app::LedDimming::Mode : uint8_t
strong

Led operation modes.

Enumerator
Off 
On 
Blinking 
Sine 
Triangule 

Definition at line 38 of file leddimming.h.

Constructor & Destructor Documentation

◆ ~LedDimming()

virtual semf::app::LedDimming::~LedDimming ( )
virtualdefault

Member Function Documentation

◆ mode()

virtual Mode semf::app::LedDimming::mode ( ) const
pure virtual

Returns the active mode of the led.

Returns
Active led mode setting.

Implemented in semf::LedDimming.

◆ setBlinking() [1/2]

virtual void semf::app::LedDimming::setBlinking ( unsigned int  onOffTime)
pure virtual

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.

Implemented in semf::LedDimming.

◆ setBlinking() [2/2]

virtual void semf::app::LedDimming::setBlinking ( unsigned int  onTime,
unsigned int  offTime 
)
pure virtual

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.

Implemented in semf::LedDimming.

◆ setBrightness() [1/2]

virtual void semf::app::LedDimming::setBrightness ( uint16_t  maxBrightness)
pure virtual

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.

Implemented in semf::LedDimming.

◆ setBrightness() [2/2]

virtual void semf::app::LedDimming::setBrightness ( uint16_t  minBrightness,
uint16_t  maxBrightness 
)
pure virtual

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.

Implemented in semf::LedDimming.

◆ setSine() [1/2]

virtual void semf::app::LedDimming::setSine ( unsigned int  periodInTimeBaseTicks)
pure virtual

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).

Implemented in semf::LedDimming.

◆ setSine() [2/2]

virtual void semf::app::LedDimming::setSine ( unsigned int  periodInTimeBaseTicks,
unsigned int  startIndexInTimeBaseTicks 
)
pure virtual

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.

Implemented in semf::LedDimming.

◆ setTriangle() [1/2]

virtual void semf::app::LedDimming::setTriangle ( unsigned int  periodInTimeBaseTicks)
pure virtual

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).

Implemented in semf::LedDimming.

◆ setTriangle() [2/2]

virtual void semf::app::LedDimming::setTriangle ( unsigned int  periodInTimeBaseTicks,
unsigned int  startIndexInTimeBaseTicks 
)
pure virtual

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.

Implemented in semf::LedDimming.