okLED (Wire Out)
This component implements a simple on/off indicator analagous to a physical LED. It is attached to a specified bit on a specified Wire Out endpoint and monitors the status of that bit. Both the style (round or square) and color (a 24-bit RGB value) may be specified.
The LED is on when the Wire Out is asserted (logic 1) and off when the Wire Out is deasserted (logic 0). When on, the LED is displayed in the specified color. When off, the LED is darkened.
ELEMENT | TYPE | DESCRIPTION |
---|---|---|
position | POSITION | Position of the top left corner. |
size | SIZE | Size in pixels. |
label | TEXT | Label text. The optional ‘align’ property can be “left | right | top | bottom” and specifies the text alignment relative to the LED. |
tooltip | TEXT | Tooltip text. |
endpoint | HEX BYTE | Endpoint address for the corresponding Wire Out. |
bit | NUMBER | Bit to which this component addresses (0=LSB, 15=MSB). |
color | COLOR | The LED “on” color. The “off” color is automatically computed as a darker version of this color. |
style | STYLE | ROUND – Displays a round LED.SQUARE – Displays a square LED. |
XML Example
<object class="okLED">
<position>135,50</position>
<size>25,25</size>
<label align="bottom">X</label>
<style>SQUARE</style>
<color>#ff0000</color>
<endpoint>0x20</endpoint>
<bit>1</bit>
</object>
Code language: HTML, XML (xml)
Lua Scripting
This component supports executing a script function when the value of the specified bit of the given endpoint changes. By default, the LED state will also be updated as it would happen without the script function, however this can be prevented by calling event:PreventDefault()
as described in the “Default Behaviour” section of FrontPanel Scripting.
Notice that this component can also be used as a standalone indicator, not bound to any input wire. In this case it must have a name, so that it can be used by the other script functions, as otherwise it would be perfectly unusable.
The event
parameter of the script function provides GetValue()
method returning the boolean value corresponding to the new wire in value.
The led
object, provided to the script function, or returned by FindLED()
method of the panel object, provides the following additional methods:
SetColor(color)
changes the LED color using any of the ways of specifying the color described in the “Control class” section.SetAlignment(alignment)
allows to change the text alignment, the possible values foralignment
argument areAlignLeft
,AlignRight
,AlignTop
andAlignBottom
.SetLEDState(value)
andGetLEDState()
allow to change or retrieve the current LED state.
All XML components that support Lua scripting also inherit from the Control class. Please refer to the FrontPanel Scripting documentation for more information on this class.