How to dynamically change the pallete of a specific object

What MCU/Processor/Board and compiler are you using?

ESP32 - M5Stack Core2

What LVGL version are you using?

8.3.3

What do you want to achieve?

I want to set the color pallete of a bar, so that when the device is charging it is LV_PALETTE_GREEN but if it’s running on battery power its LV_PALETTE_BLUE

What have you tried so far?

Attempting to print to serial the colour while it’s defaulted to LV_PALETTE_GREEN

Code example

  if(M5.Axp.isCharging() == true) {
    //Some code with LVGL here to change the bar pallete to LV_PALETTE_GREEN
  }
  else {
    //Some code with LVGL here to change the bar pallete to LV_PALETTE_BLUE
  }

Is this possible? Why has no one replied after 2 weeks?