|
Doxygen with github
|
A component that simplifies LED control. More...
#include <ksLed.h>
Inheritance diagram for ksf::comps::ksLed:Public Member Functions | |
| virtual std::size_t | getInstanceType () const |
| Retrieves type ID of the object. | |
| virtual bool | isA (const std::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. | |
| virtual | ~ksLed () |
| Destructs the component and restores INPUT mode on the assigned pin. | |
| bool | init (ksApplication *app) 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. | |
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 | |
| virtual | ~ksRtti ()=default |
| Destructor. | |
| 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 std::size_t | getClassType () |
Static Public Member Functions inherited from ksf::ksComponent | |
| static std::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 } | |
| Holds current state of the component. | ||
A component that simplifies LED control.
Designed to help the device indicate its state using blink patterns, this component also includes additional features such as state inversion (driveAsActiveLow) and a low-power pin driving mode (driveAsPushPull). The driveAsPushPull mode utilizes pull resistors, significantly reducing 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.
|
inlinevirtual |
|
inline |
|
overridevirtual |
Initializes the LED component.
| app | 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().