The constructor creates an instance of a FadeLED
object. This constructor should not be called directly by application code, but is called by the constructors of the FadeLED_Lin
and FadeLED_Exp
derived classes.
NOTE: On some Arduino devices, such as the Arduino UNO, the LED_BUILTIN
pin does not support PWM output.
- pin: const byte: PWM-capable GPIO pin which will drive an LED connected to it.
- invert: const bool: If
false
, the GPIO pin will be drivenHIGH
when theFadeLED
object goes to its on state. Ifinvert
iftrue
, the on state drives the GPIO pinLOW
. The default isfalse
(don't invert).
Checks if it is time to update the state of the FadeLED
object. This method should not be called directly by the user's application code; it will be called by the FadeLED_Lin
, FadeLED_Exp
, and FadeLED_Func
update()
methods from the Arduino sketch's loop()
function.
- bool:
true
if object's state has been updated.
Gets the state of the object.
- bool: Returns
true
if LED is either fully on or is fading from off to on, andfalse
if LED is fully off or fading from on to off.
Sets the state of the object to either turning-on or turning-off.
- state: bool: If
true
, sets object to turning-on state, otherwise it is set to turning-off.
FadeLED_Lin(const byte pin, const uint32_t onTime, const uint32_t offTIme, const bool invert = false)
The constructor creates an instance of a FadeLED_Lin
object, which in turn creates an instance of the FadeLED
base class. The FadeLED_Lin
object inherits the read()
and write()
methods from the base class.
NOTE: On some Arduino devices, such as the Arduino UNO, the LED_BUILTIN
pin does not support PWM output.
- pin: const byte: PWM-capable GPIO pin which will drive an LED connected to it.
- onTime: const uint32_t: Time in milliseconds that GPIO pin takes to go from fully-off to fully-on.
- offTime: const uint32_t: Time in milliseconds that GPIO pin takes to go from fully-on to fully-off.
- invert: const bool: If
false
, the GPIO pin will be drivenHIGH
when theFadeLED
object goes to its on state. Ifinvert
istrue
, the on state drives the GPIO pinLOW
. The default isfalse
(don't invert).
Checks if it is time to update the state of the FadeLED_Lin
object. This method should be called from within the Arduino sketch's loop()
function.
- bool:
true
if object's state has been updated.
FadeLED_Exp(const byte pin, const unsigned int onTime, const unsigned int offTIme, const bool invert = false)
The constructor creates an instance of a FadeLED_Exp
object, which in turn creates an instance of the FadeLED
base class. The FadeLED_Exp
object inherits the read()
and write()
methods from the base class.
NOTE: On some Arduino devices, such as the Arduino UNO, the LED_BUILTIN
pin does not support PWM output.
- pin: const byte: PWM-capable GPIO pin which will drive an LED connected to it.
- onTime: const uint32_t: Time in milliseconds that GPIO pin takes to go from fully-off to fully-on.
- offTime: const uint32_t: Time in milliseconds that GPIO pin takes to go from fully-on to fully-off.
- invert: const bool: If
false
, the GPIO pin will be drivenHIGH
when theFadeLED
object goes to its on state. Ifinvert
iftrue
, the on state drives the GPIO pinLOW
. The default isfalse
(don't invert).
Checks if it is time to update the state of the FadeLED_Exp
object. This method should be called from within the Arduino sketch's loop()
function.
- bool:
true
if object's state has been updated.
FadeLED_Func(const byte pin, const uint32_t onTime, const uint32_t offTime, const bool invert = false)
The constructor creates an instance of a FadeLED_Func
object, which in turn creates an instance of the FadeLED
base class. The FadeLED_Func
object inherits the read()
and write()
methods from the base class.
This class is used to create custom fade curves (output vs. time) besides the linear and exponential cases already supported by this library. Because an instance of the FadeLED_Func
class can call FadeLED::read()
to determine whether a fade cycle is in its turning-on or turning-off state, the code which converts the normalized output of an instance to the desired PWM level can generate non-symmetric fade curves, much like how FadeLED_Exp
already functions.
NOTE: On some Arduino devices, such as the Arduino UNO, the LED_BUILTIN
pin does not support PWM output.
- pin: const byte: PWM-capable GPIO pin which will drive an LED connected to it, or
NO_PWM
if output will be controlled outside theFadeLED_Func
class rather than with a call to the classset()
method. - onTime: const unsigned int: Time in milliseconds that GPIO pin takes to go from fully-off to fully-on.
- offTime: const unsigned int: Time in milliseconds that GPIO pin takes to go from fully-on to fully-off.
- invert: const bool: If
false
, the GPIO pin will be drivenHIGH
when theFadeLED
object goes to its on state. Ifinvert
istrue
, the on state drives the GPIO pinLOW
. The default isfalse
(don't invert).
Checks if it is time to update the state of the FadeLED_Func
object. This method should be called from within the Arduino sketch's loop()
function.
- bool:
true
if object's state has been updated.
Gets normalized value which ramps linearly with time from 0.0 when the FadeLED_Func
object is triggered, up to 1.0 until the on-time passes, then linearly back down to 0.0 until the off-time passes. The returned value is usually transformed by the application code to a new value between 0.0 and 1.0 which is then passed to method set()
.
double
: Normalized value of linear ramp between 0.0 (fully off) and 1.0 (fully on).
Sets output level, usually paired with a transform function after a call to the get()
method.
- f: const double: output level between 0.0 (fully off) and 1.0 (fully on).