How to update needle faster on gauge widget?

Description

I’ve just got my first LittlevGL example working with the gauge widget demo.

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

ESP32 on lv_arduino with a 480x320 ILI9488 display.

What do you want to achieve?

I want to move the needle faster, like a rev counter in a car but the update is very slow even with the delay reduced.

What have you tried so far?

The delay is set to 5ms but even if I reduce this, it does not make a difference on the update.

Code to reproduce

/*You code here*/
void loop() 
{
  uint8_t i;
  
  lv_task_handler();

  for(i =0 ;i<100;i++)
  {
    lv_gauge_set_value(gauge1, 0, i);
    lv_task_handler(); 
   delay(5);

  }
  
  delay(2);
  
}

See if reducing this value in lv_conf.h helps.

Hi embeddedt thanks for the reply.

The default value of LV_DISP_DEF_REFR_PERIOD was 30. I’ve changed it to 5 but it didn’t make any difference.

At the moment the needle take about 15 seconds to move from 0 to 100. Which far too long I think.

Any other idea ?

It can happen if the drawing or refreshing of the screen is very very slow.
15 sec means it has 150 ms for each “round”. Can you measure the run time of lv_task_handler?
Other question, where/how do call lv_tick_inc?

The lv_tick_inc is called inside the lv_tick_handler() which is Initialized by tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler); The tick period is 60.

I’ve measured the time it takes inside the lv_task_handler() like this:
digitalWrite(test, LOW);
lv_task_handler();
digitalWrite(test, HIGH);

and it is about 150ms.

I then change the size of the gauge from:

lv_obj_set_size(gauge1, 250, 250);
to
lv_obj_set_size(gauge1, 50, 50);

The time inside the lv_task_handler is now 7.2ms and the needle moves a lot faster but the gauge is now tiny compare to what I had before.

Is there a way of having large gauge and needle and make it the needle move faster ?

You’ll want to call it much more frequently than 60ms (if that’s what you’re doing right now). Ideally it should be 1-5 ms between calls.

Your display driver needs to be fast enough to redraw the gauge at that speed.