semf
|
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>
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 } |
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.
semf::LedDimming::LedDimming | ( | PwmOut & | dimmPwmOut, |
app::TimeBase & | timebase | ||
) |
Constructor.
dimmPwmOut | Reference to the PwmOut object used for dimming. |
timebase | TimeBase as clock source for the internal SoftwareTimer . |
Definition at line 17 of file leddimming.cpp.
|
explicitdelete |
|
overridevirtual |
Returns the active mode of the led.
Implements semf::app::LedDimming.
Definition at line 155 of file leddimming.cpp.
|
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].
onOffTime | On and off time. |
Implements semf::app::LedDimming.
Definition at line 78 of file leddimming.cpp.
|
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].
onTime | On time. |
offTime | Off time. |
Implements semf::app::LedDimming.
Definition at line 83 of file leddimming.cpp.
|
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.
maxBrightness | Brightness value, which is between 0 and 1000. |
Implements semf::app::LedDimming.
Definition at line 23 of file leddimming.cpp.
|
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.
minBrightness | Brightness value, which is between 0 and 1000. |
maxBrightness | Brightness value, which is between 0 and 1000. |
Implements semf::app::LedDimming.
Definition at line 35 of file leddimming.cpp.
|
overridevirtual |
Switch the LED off.
Implements semf::app::Led.
Definition at line 61 of file leddimming.cpp.
|
overridevirtual |
Switch the LED on.
Implements semf::app::Led.
Definition at line 53 of file leddimming.cpp.
|
overridevirtual |
Starts showing a sine waveform on the led.
setBrightness()
function. periodInTimeBaseTicks | Period 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.
|
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.
periodInTimeBaseTicks | Period of triangle is timer ticks by TimeBase (period time = periodInTimeBaseTicks * TimeBase timer period). |
startIndexInTimeBaseTicks | index in period to start waveform. |
Implements semf::app::LedDimming.
Definition at line 99 of file leddimming.cpp.
|
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.
periodInTimeBaseTicks | Period 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.
|
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.
periodInTimeBaseTicks | Period of triangle is timer ticks by TimeBase (period time = periodInTimeBaseTicks * TimeBase timer period). |
startIndexInTimeBaseTicks | index in period to start waveform. |
Implements semf::app::LedDimming.
Definition at line 127 of file leddimming.cpp.
|
overridevirtual |
Toggle the led state.
Implements semf::app::Led.
Definition at line 69 of file leddimming.cpp.