IoT::Devices

class LED

File Information

Library: IoT/Devices
Package: Devices
Header: IoT/Devices/LED.h

Description

The base class for LEDs.

Each instance of the LED class represents a single physical LED. Some LED devices support different brightness levels, this is accounted for by allowing to specify a brightness level in range 0.0 to 1.0, where 0.0 turns the LED off and 1.0 is the maximum brightness.

Some implementations may also support blinking LEDs. This is exposed via the "blinkOn" and "blinkOff" properties, which take as values the time in milliseconds the LED should be on, or off, respectively. There is also a shortcut method, blink(), which allows setting both properties at once.

To turn on blinking, both "blinkOn" and "blinkOff" must be set to a non-zero value. Furthermore, the brightness must be non-zero.

Inheritance

Direct Base Classes: Device

All Base Classes: Device

Member Summary

Member Functions: blink, getBrightness, off, on, setBrightness

Inherited Functions: getFeature, getPropertyBool, getPropertyDouble, getPropertyInt, getPropertyInt16, getPropertyInt64, getPropertyString, getPropertyTimestamp, hasFeature, hasProperty, setFeature, setPropertyBool, setPropertyDouble, setPropertyInt, setPropertyInt16, setPropertyInt64, setPropertyString, setPropertyTimestamp

Constructors

LED

LED();

Creates the LED.

Destructor

~LED virtual

~LED();

Destroys the LED.

Member Functions

blink virtual

virtual void blink(
    int onMilliseconds,
    int offMilliseconds
) = 0;

Turns on blinking of the LED.

May not be supported by all implementations.

getBrightness virtual

virtual double getBrightness() const = 0;

Returns the current brightness of the LED in range 0.0 to 1.0.

0.0 means off, every value > 0.0 means on, with 1.0 being the maximum brightness level.

Note that most LED devices do not support different brightness levels and can only be turned on or off.

off virtual

virtual void off() = 0;

Convenience method that turns the LED off by calling setBrightness(0.0).

on virtual

virtual void on() = 0;

Convenience method that turns the LED on by calling setBrightness(1.0).

setBrightness virtual

virtual void setBrightness(
    double brightness
) = 0;

Sets the brightness of the LED.

0.0 means off, every value > 0.0 means on, with 1.0 being the maximum brightness level.

Note that most LED devices do not support different brightness levels and can only be turned on or off.

Securely control IoT edge devices from anywhere   Connect a Device