okHex (Wire Out)
The okHex component displays four bits of a Wire Out endpoint as a hexadecimal digit. Multiple okHex components may be attached to the same Wire Out endpoint. For example, to display an entire byte in hex, you could display two okHex components side-by-side. Attach the left component to bit 4 and the right component to bit 0.
ELEMENT | TYPE | DESCRIPTION |
---|---|---|
position | POSITION | Position of the top left corner. |
size | SIZE | Size in pixels. |
label | TEXT | Label text, shown inside the button. |
tooltip | TEXT | Tooltip text. |
endpoint | HEX BYTE | Endpoint address for the corresponding Wire Out. |
bit | NUMBER | Least-significant bit to which this component addresses. The hex value comes from the specified bit and its three neighbors to the left. For example, if bit=2, the hex value will be taken from bits 5:2. |
color | COLOR | Sets the numeral color. |
XML Example
<object class="okHex">
<label>x[3:0]</label>
<position>217,22</position>
<size>35,50</size>
<endpoint>0x20</endpoint>
<bit>0</bit>
<tooltip>Counter #1 (low nibble)</tooltip>
</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 value displayed by the control will also be updated, 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 numeric value corresponding to the new wire in value.
The hex
object, provided to the script function, or returned by FindHexDisplay()
method of the panel object, provides the following additional methods:
GetValue()
returns the value currently displayed by the control.SetValue(value)
allows to change this value.SetColor(color)
allows to change the color used by the control, using any of the ways of specifying the color described in the “Control class” section.
Here is an example of a function, which could be called from another component callback or when the value of the wire connected to okHex
component itself changes, which updates the displayed value and its color depending on its range:
Lua:
function UpdateHex2(value)
local hex = okUI:FindPanel("panel1"):FindHexDisplay("hex")
hex:SetValue(value)
if value < 8 then
hex:SetColor(OpalKellyUI.Green)
elseif value < 12 then
hex:SetColor(OpalKellyUI.Yellow)
else
hex:SetColor(OpalKellyUI.Red)
end
end
Code language: JavaScript (javascript)
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.