How to change the background of a numeric object if the value does not in range standard? The standard i build dynamic

How to change the background of a numeric object if the value does not in range standard? The standard i build dynamic
none 0.0 0

Hi @liaaa ,

To change the background color based on a numeric value, we recommend layering a Word Lamp behind a Numeric object (set the Numeric’s background to None). Then, use a macro to set the Word Lamp’s background for the states you need.

Below are a demo project and the macro I used. Feel free to modify them as needed.

macro_command main()

short num
short state

// Read the value from LW10
GetData(num, "Local HMI", LW, 10, 1)

// Evaluate range and set state accordingly
if num == 0 then
    state = 1
else if num <= 20 then
    state = 2
else
    state = 3
end if

// Write the result to LW0
SetData(state, "Local HMI", LW, 0, 1)

end macro_command

Demo Project

Post if needed to create multiple states within a Word Lamp using the Picture Library