I have odd behavior in my project…
I draw two lines that can change in color and thickness depending on certain data (currentSpeed). I’m currently doing tests to make it work but it seems like it starts updating, but then halfway the process stops it. The text is updating smootly
Oddly, although the trigger should be a currentSpeed = 70, one of the lines (I expected both) becomes thick at currentSpeed =100
Video of the error, it is about the lines next to the changing value
Global definitions
static lv_point_precise_t line_points1[] = { {260, 220}, {270, 130} };
static lv_point_precise_t line_points2[] = { {310, 220}, {300, 130} };
static lv_style_t style_line1;
In setup
lv_style_init(&style_line1);
lv_style_set_line_width(&style_line1, 2);
lv_style_set_line_color(&style_line1, lv_palette_main(LV_PALETTE_GREY));
lv_style_set_line_rounded(&style_line1, true);
/*Create a line and apply the new style*/
lv_obj_t * line1;
lv_obj_t * line2;
line1 = lv_line_create(lv_screen_active());
line2 = lv_line_create(lv_screen_active());
lv_line_set_points(line1, line_points1, 2); /*Set the points*/
lv_line_set_points(line2, line_points2, 2); /*Set the points*/
lv_obj_add_style(line1, &style_line1, 0);
lv_obj_add_style(line2, &style_line1, 0);
// lv_obj_center(line1);
and in main
void loop() {
lv_tick_inc(millis() - lastTick); //Update the tick timer. Tick is new for LVGL 9
lastTick = millis();
lv_timer_handler(); //Update the UI
delay(250);
lv_label_set_text_fmt(ui_Speed, "%d", currentSpeed);
currentSpeed += 10;
if (currentSpeed > 200) currentSpeed = 0;
if (currentSpeed < 70) {
lv_style_set_line_width(&style_line1, 2);
lv_style_set_line_color(&style_line1, lv_palette_main(LV_PALETTE_GREY));
}
if (currentSpeed >= 70)
lv_style_set_line_width(&style_line1, 8);
if (currentSpeed >= 140)
lv_style_set_line_color(&style_line1, lv_palette_main(LV_PALETTE_BLUE));
}