How to just draw an indicator dot on Scale instead of an arc


I’m getting linking errors when trying to call any of the demos.

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

ESP32S3 on Arduino 3.0 with Lovyan GFX

What LVGL version are you using?


What do you want to achieve?

As the title says, just draw a dot/circle/anything on the scale at the appropriate position without drawing the arc. Alternatively I’d like a way to rotate an object around a radius.

What have you tried so far?

I have tried with the knob but I don’t know how to style it. I have also tried making a very small arc, and drawing half a degree to each side of the current point also an arc with zero size.

However both these solution present a very bad problem, in that they both take far more cpu power (despite drawing very little) than just drawing the arc normally. I don’t understand why both of these are so cpu heavy compared to actually drawing a large arc.

Code to reproduce

I am defining the knob like this

#define TICK_DEG 4
lv_obj_t * arc;
static lv_obj_t * scale1;
void knobCreate(lv_obj_t* parent){

  scale1 = lv_scale_create(parent);
  lv_obj_set_size(scale1, 240, 240);
  lv_scale_set_mode(scale1, LV_SCALE_MODE_ROUND_INNER);
  lv_scale_set_post_draw(scale1, true);
  lv_obj_set_style_clip_corner(scale1, true, 0);

  /*Scale 1*/
  lv_obj_set_style_pad_all(scale1, -1, 0);
  arc = lv_arc_create(scale1);
  lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
  //lv_obj_remove_style(arc, NULL, LV_PART_MAIN);
  lv_obj_set_size(arc, lv_pct(100), lv_pct(100));
  lv_obj_set_style_arc_opa(arc, 0, 0);
  lv_obj_set_style_arc_width(arc, 20, LV_PART_INDICATOR);

  lv_obj_set_style_arc_color(arc, lv_palette_main(LV_PALETTE_BLUE), LV_PART_INDICATOR);
  //lv_obj_set_style_radius(scale1, LV_RADIUS_CIRCLE, 0);
  lv_obj_remove_flag(arc, LV_OBJ_FLAG_CLICKABLE);
  lv_scale_set_rotation(scale1, 270);
  lv_obj_set_style_outline_width(arc, 1, LV_PART_KNOB);
  lv_arc_set_knob_offset(arc, 0);
  lv_arc_set_angles(arc, 270.0f,270.0f);
  lv_arc_set_bg_angles(arc, 0, 360);
  //printf("range: %d\n",lv_arc_get_value(arc));

  lv_scale_set_angle_range(scale1, 360);
  lv_scale_set_range(scale1,0, 360);
  lv_scale_set_total_tick_count(scale1, 360);
  lv_scale_set_major_tick_every(scale1, TICK_DEG);
  lv_scale_set_label_show(scale1, false);
  lv_obj_set_style_length(scale1, 0, LV_PART_ITEMS);
  lv_obj_set_style_length(scale1, 10, LV_PART_INDICATOR); 

I am then setting the location with

shaftAngleDeg >= 0 ? lv_arc_set_angles(arc, shaftAngleDeg,shaftAngleDeg) : lv_arc_set_angles(arc, 360+shaftAngleDeg,360+shaftAngleDeg);

Calling this does work, the knob shows, but no arc is drawn. But it heavily drops frames to the point of being unusable.

but as mentioned above, if I do

shaftAngleDeg >= 0 ? lv_arc_set_angles(arc, 0,shaftAngleDeg) : lv_arc_set_angles(arc, 360+shaftAngleDeg, 0);

Then it uses far less CPU power and while it drops some frames, it remains usable.