|
Treehopper C# API
|
Represents a single LED that may or may not have brightness control More...
Public Member Functions | |
| override string | ToString () |
| Gets a string representation of the LED's current state More... | |
Properties | |
| int | Channel [get] |
| Gets or sets the channel this LED belongs to More... | |
| double | Brightness [get, set] |
| Gets or sets the brightness (0.0 - 1.0) of the LED (if it has brightness control) More... | |
| bool | HasBrightnessControl [get] |
| Gets whether the LED has brightness control More... | |
| bool | State [get, set] |
| Gets or sets the state of the LED More... | |
Represents a single LED that may or may not have brightness control
The default State of a newly-constructed LED is "false" (off) with a Brightness of 1.0 (even if this LED does not support brightness control). This allows LEDs to be used with many non-dimmable display classes (such as SevenSegmentDigit, or BarGraph) that only control the LED state. Note that for an LED to be on, its state must be "true" and its brightness must be non-zero.
Do not confuse the State's value with the electrical value on the pin; most LED drivers are open-drain, thus a "true" state — i.e., when the LED is on — actually corresponds to the pin being driven to 0 (logic false); this is handled by the individual LED drivers to remove ambiguity. If your driver supports driving LEDs in either common-anode (open-drain) or common-cathode configurations, ensure the driver itself is configured to match your circuit.
You can also attach LEDs to pins that don't belong to LED drivers; see GpioLedDriver<TDigitalOutPin> and PwmLedDriver<TPwm>, which perform the necessary conversions.
| override string ToString | ( | ) |
Gets a string representation of the LED's current state
|
get |
Gets or sets the channel this LED belongs to
|
getset |
Gets or sets the brightness (0.0 - 1.0) of the LED (if it has brightness control)
The brightness is perceptual on a linear scale; i.e., a brightness of 0.5 will be perceived as half as bright as a brightness of 1.0.
Note that the LED will only illuminate if the State is true, regardless of the value of this property.
|
get |
Gets whether the LED has brightness control
|
getset |
Gets or sets the state of the LED
Note that if the LED has brightness control, it will only illuminate if the Brightness of the LED is also non-zero.