Change object colour dynamically

Hey everyone,

I’m working on a project that uses a screen and has no input device - it purely shows data collected from a sensor.

I have three container objects that I want to change background colour of depending on the value of the sensor.

By default, all three objects are gray and only one object at a time is highlighted (the others should be gray). What’s the most elegant way of achieving this?

Any thoughts/pointers would be greatly appreciated.

EDIT: I was having runtime issues but found the source in my code - I’m still interested in the most efficient approach for this.

Hello! In newer versions of LVGL, you can use subjects to bind styles to objects. This allows you to change not only colors but any style property of the components. The subject can then be updated based on your sensor data. There is also color specific subjects.

You can learn more about it here: How to Use | LVGL Open