Doxygen with github
|
A component that simplifies driving the LED. More...
#include <ksLed.h>
Public Member Functions | |
virtual const size_t | getInstanceType () const |
Retrieves type ID of the object. | |
virtual bool | isA (const size_t id) const |
Checks whether object is of given type. | |
ksLed (uint8_t pin, bool activeLow=false, bool driveAsPushPull=false) | |
Constructs the LED object. | |
bool | init (ksApplication *owner) override |
Initializes the LED component. | |
bool | loop (ksApplication *app) override |
Executes core of the LED component logic. | |
void | setBlinking (uint32_t blinkIntervalMs, uint32_t blinkLoops=0) |
Sets LED blinking pattern. | |
bool | isBlinking () const |
Returns whether LED is currently blinking. | |
bool | isEnabled () const |
Returns whether the LED is actually enabled. | |
void | setEnabled (bool enabled) |
Enables or disables the LED. | |
void | setDriveAsPushPull (bool driveAsPushPull) |
Enables or disables the push/pull driving mode. | |
uint8_t | getPin () const |
Returns a pin number assigned to the LED. | |
virtual | ~ksLed () |
Destructs the component and restores INPUT mode on the assigned pin. | |
Public Member Functions inherited from ksf::ksComponent | |
virtual bool | postInit (ksApplication *app) |
Method called after component initialization, used to setup references to other components. | |
Public Member Functions inherited from ksf::ksRtti | |
template<typename TType> | |
TType * | as () |
Tries to cast object to the type provided as a template parameter. | |
template<typename TType> | |
const TType * | as () const |
Tries to cast object to the type provided as a template parameter (const version). | |
Static Public Member Functions | |
static const size_t | getClassType () |
Static Public Member Functions inherited from ksf::ksComponent | |
static const size_t | getClassType () |
Protected Attributes | ||
uint8_t | pin {0} | |
Pin number assigned to LED. | ||
uint32_t | lastBlinkTimeMs {0} | |
Timestamp of previous state change (milliseconds). | ||
uint32_t | blinkIntervalMs {0} | |
Intervals between state change (0 to disable blinking). | ||
uint32_t | blinkLoops {0} | |
Number of state change cycles (0 for infinite loop). | ||
struct { | ||
bool activeLow: 1 | ||
True if the LED should be active low, otherwise false. | ||
bool driveAsPushPull: 1 | ||
True if the LED should be driven as push-pull, otherwise false. | ||
} | bitflags = {false, false} | |
Protected Attributes inherited from ksf::ksComponent | ||
ksComponentState::TYPE | componentState { ksComponentState::NotInitialized } | |
A component that simplifies driving the LED.
It was designed to help the device to signal it's state using blink pattern. This component has also some extra features like state inversion (driveAsActiveLow) and low-power pin driving mode knowm as driveAsPushPull, which uses pull resistors and significantly reduces the amout of emitted light.
ksf::comps::ksLed::ksLed | ( | uint8_t | pin, |
bool | activeLow = false, | ||
bool | driveAsPushPull = false ) |
Constructs the LED object.
pin | Pin number assigned to LED. |
activeLow | True if the LED should be active low, otherwise false |
driveAsPushPull | True if the LED should be driven as push-pull, otherwise false |
References driveAsPushPull, and pin.
Referenced by getInstanceType().
|
inlinevirtual |
Retrieves type ID of the object.
Reimplemented from ksf::ksComponent.
References ksLed().
|
inline |
|
overridevirtual |
Initializes the LED component.
owner | Pointer to parent ksApplication object. |
Reimplemented from ksf::ksComponent.
References pin, and setEnabled().
|
inlinevirtual |
Checks whether object is of given type.
id | Type ID to check against. |
Reimplemented from ksf::ksComponent.
bool ksf::comps::ksLed::isBlinking | ( | ) | const |
Returns whether LED is currently blinking.
References blinkIntervalMs.
bool ksf::comps::ksLed::isEnabled | ( | ) | const |
Returns whether the LED is actually enabled.
References pin.
Referenced by loop(), and setDriveAsPushPull().
|
overridevirtual |
Executes core of the LED component logic.
Reimplemented from ksf::ksComponent.
References blinkIntervalMs, blinkLoops, isEnabled(), lastBlinkTimeMs, setBlinking(), and setEnabled().
void ksf::comps::ksLed::setBlinking | ( | uint32_t | blinkIntervalMs, |
uint32_t | blinkLoops = 0 ) |
Sets LED blinking pattern.
blinkIntervalMs | Interval in milliseconds between toggle action (0 to disable blinking) |
blinkLoops | Number of state toggle loops/cycles (0 for infinite loop). |
References blinkIntervalMs, blinkLoops, lastBlinkTimeMs, and setEnabled().
Referenced by loop().
void ksf::comps::ksLed::setDriveAsPushPull | ( | bool | driveAsPushPull | ) |
Enables or disables the push/pull driving mode.
driveAsPushPull | True if LED should is driven as push-pull, false otherwise. |
References driveAsPushPull, isEnabled(), pin, and setEnabled().
void ksf::comps::ksLed::setEnabled | ( | bool | enabled | ) |
Enables or disables the LED.
enabled | True to enable LED, false to disable. |
References pin.
Referenced by init(), loop(), ksf::comps::ksWifiConfigurator::postInit(), setBlinking(), and setDriveAsPushPull().