Description
I am using ESP-IDF and used the esp_lcd_touch example as my starting point (with touch disabled). This example worked as expected.
I then replaced the example_lvgl_demo_ui code with the code below and the line is not being drawn correctly on the screen. I actually see 3 lines.
I am using lv_line_create and lv_line_set_points with 2 points to create a line, then call lv_obj_update_layout.
Also, why does the border of the circle overwrite the line but the centre does not?
Thanks in advance for feedback. This has been driving me nuts!
What MCU/Processor/Board and compiler are you using?
Waveshare esp32-s3-lcd-1.28
What LVGL version are you using?
9.2
Code to reproduce
// spi_lcd_touch_example_main.c does the setup and calls example_lvgl_demo_ui
_lock_acquire(&lvgl_api_lock);
example_lvgl_demo_ui(display);
_lock_release(&lvgl_api_lock);
//lvgl_demo_ui.c contents below.
#include "lvgl.h"
#include <unistd.h>
#include <sys/lock.h>
#include "esp_err.h"
#include "esp_log.h"
#include <string.h>
static _lock_t lvgl_api_lock;
static const char *TAG = "lvgl";
void example_lvgl_demo_ui(lv_display_t *disp)
{
static lv_obj_t * dial;
dial = lv_obj_create(lv_screen_active());
lv_obj_set_size(dial , 100, 100);
lv_obj_set_style_bg_color(dial , lv_palette_main(LV_PALETTE_BLUE), 0);
lv_obj_set_style_radius(dial , LV_RADIUS_CIRCLE, 0);
lv_obj_set_pos(dial , 50,50);
lv_obj_update_layout(dial);
static lv_obj_t * hand;
static lv_point_precise_t p[] = {{50, 50}, {150, 150}};
hand = lv_line_create(dial);
lv_line_set_points(hand, p, 2);
lv_obj_update_layout(hand);
static lv_area_t coords;
static lv_point_precise_t *points;
points=lv_line_get_points(hand);
ESP_LOGI(TAG,"Points %ld %ld %ld %ld",points[0].x,points[0].y,points[1].x,points[1].y);
lv_obj_get_coords(hand, &coords);
ESP_LOGI(TAG,"Coords %ld %ld %ld %ld",coords.x1,coords.y1,coords.x2,coords.y2);
}
//I added logging to the lv functions to check what is being passed.
//lv_line.c
void lv_line_set_points(lv_obj_t * obj, const lv_point_precise_t points[], uint32_t point_num)
{
line_set_points(obj, points, point_num, false);
ESP_LOGI(TAG,"lv_sp = %ld %ld %ld %ld",points[0].x,points[0].y,points[1].x,points[1].y);
}
static void line_set_points(lv_obj_t * obj, const lv_point_precise_t points[], uint32_t point_num, bool mut)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_line_t * line = (lv_line_t *)obj;
line->point_array.constant = points;
line->point_num = point_num;
line->point_array_is_mutable = mut;
ESP_LOGI(TAG,"sp = %ld %ld %ld %ld",points[0].x,points[0].y,points[1].x,points[1].y);
lv_obj_refresh_self_size(obj);
lv_obj_invalidate(obj);
}
Screenshot and/or video
This is returned in the terminal.
I (539) LVGL: sp = 50 50 150 150
I (539) LVGL: lv_sp = 50 50 150 150
I (539) lvgl: Points 50 50 150 150
I (539) lvgl: Coords 65 65 214 214