Skip to content

WidgetTests LED_test.opi

kasemir edited this page Feb 15, 2017 · 3 revisions

Boolean vs. Multi-State LED

Display Builder uses plain LED for boolean PV, with on/off label and support for a 'bit' in a numeric value. A separate Multi-State LED handles more than 2 states, each with label and value, requiring a numeric value, no 'bit' support..

BOY combined this into one LED where details of properties and their behavior changed when the number of states was two or more.

In test screen, Display Builder updates legacy LED to plain or multi-state LED based on number of states.

Label color

Display Builder always uses the 'foreground_color' for labels.

In BOY, the 'On'/'Off' label for boolean LEDs (2 states) uses the 'foreground_color', while the label for LEDs with more than two states uses black or white depending on the best contrast for the current LED color:

// BOY LEDFigure#setBulbColorAndLabel
// These brightness weightings and threshold determined experimentally.
if ((color.getRed() * 299) + (color.getGreen() * 587) + (color.getBlue() * 114) > 105000)
   .. BLACK ..
else
   .. WHITE ..