Giter Site home page Giter Site logo

Possible issue with buttons about lvgl HOT 15 CLOSED

lvgl avatar lvgl commented on May 21, 2024
Possible issue with buttons

from lvgl.

Comments (15)

kisvegabor avatar kisvegabor commented on May 21, 2024

Hi,

It should work properly. Can you send your code?

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

This is the function which is used to create the buttons:

`
#define PIN_X_PAD 5
#define PIN_Y_PAD 5
#define PIN_X_START 100
#define PIN_Y_START 200

lv_obj_t *bs[12];

void DrawKeyPad(lv_action_res_t (*kpFunc)(lv_obj_t *a, lv_dispi_t *b), lv_obj_t *scrn)
{
uint16_t x, y;
uint8_t c;
char ltr[] = "1";
lv_obj_t *label;

x = PIN_X_START;
y = PIN_Y_START;
for(c=1; c!=10; c++)
{
	bs[c] = lv_btn_create(scrn, NULL);
	lv_btn_set_pr_action(bs[c], kpFunc);
	lv_cont_set_fit(bs[c], true, true);
	lv_obj_set_pos(bs[c], x, y);
	label = lv_label_create(bs[c], NULL);

	ltr[0] = c+'0';
	lv_label_set_text(label, ltr);
	lv_obj_set_free_num(bs[c], c);

	if((c==3) || (c==6))
	{
		x = PIN_X_START;
		y = lv_obj_get_y(bs[c]) + lv_obj_get_height(bs[c]) + PIN_Y_PAD;
	}
	else
	{
		x = lv_obj_get_x(bs[c]) + lv_obj_get_width(bs[c]) + PIN_X_PAD;
	}
}

area_t coords;

bs[0] = lv_btn_create(scrn, NULL);
lv_btn_set_pr_action(bs[0], kpFunc);
lv_cont_set_fit(bs[0], true, true);
label = lv_label_create(bs[0], NULL);
lv_label_set_text(label, "0");
lv_obj_set_free_num(bs[0], 0);
lv_obj_get_cords(bs[8], &coords);
lv_obj_set_pos(bs[0], coords.x1, coords.y2 + PIN_Y_PAD);

bs[10] = lv_btn_create(scrn, NULL);
lv_btn_set_pr_action(bs[10], kpFunc);
lv_cont_set_fit(bs[10], true, true);
label = lv_label_create(bs[10], NULL);
lv_label_set_text(label, "Done");
lv_obj_set_free_num(bs[10], 10);
lv_obj_get_cords(bs[3], &coords);
lv_obj_set_pos(bs[10], coords.x2 + (PIN_X_PAD*3), coords.y1);

bs[11] = lv_btn_create(scrn, NULL);
lv_btn_set_pr_action(bs[11], kpFunc);
lv_cont_set_fit(bs[11], true, true);
label = lv_label_create(bs[11], NULL);
lv_label_set_text(label, "Del");
lv_obj_set_free_num(bs[11], 11);
lv_obj_get_cords(bs[9], &coords);
lv_obj_set_pos(bs[11], coords.x2 + (PIN_X_PAD*3), coords.y1);

}
`

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024

I've tested you code. It was rendered for me correctly after pushing the button. The strange thing is the buttons have a radius by default which is missing on your image.

Please, attache your lv_conf.h

btn

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

lv_conf.h attached

lv_conf.zip

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
#define LV_VDB_SIZE        (LV_HOR_RES * (LV_RES/10))		// (LV_HOR_RES * 30)

I suppose LV_RES is your own define. What is its value? Setting LV_RES to a 80 worked for me well.

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

LV_RES is set to the same as LV_VER_RES. Setting it to 80 has fixed that issue but looks to have caused others but I'll dig into them and open a new issue if I can locate the cause.

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024

It works for me with LV_VER_RES too.

It seems the borders are also missing on your buttons. Please try this code:

static lv_style_t style_test;
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_test);
style_test.empty = 1;
style_test.bwidth = 1 * LV_DOWNSCALE;
style_test.bcolor= COLOR_RED;
style_test.ccolor= COLOR_BLUE;

/*Red border*/
lv_obj_t * obj1 = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(obj1, &style_test);
lv_obj_set_pos(obj1, 10, 10);

/*Blue line*/
lv_obj_t * obj2 = lv_line_create(lv_scr_act(), NULL);
lv_obj_set_style(obj2, &style_test);
lv_obj_set_pos(obj2, 150, 10);
lv_line_set_auto_size(obj2, true);
static point_t points[2] = {{5, 5},{50, 5}};    /*Modify the coordinates to test*/
lv_line_set_points(obj2, points, 2);

It produces me the following result:
kepernyokep 2017-08-29 16 43 15

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

This is what I get:

20170829_172945

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

One thought - I'm currently using beta code but have only been updating lvgl and not misc. Does that need to be checked out as well?

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024

Yes, if you use lvgl:beta, you should use misc:beta as well. But in your case it can not be the problem. Anyway please checkout misc:beta

On your screenshot it is clearly seen the corners are not drawn. It is very strange. It seems the circle drawing algorithm is not working for you. Please attache your misc_conf.h as well. Maybe we find the issue there.

Thank you in advance!

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024

Please try this code as well to test circle drawing (#include "misc/gfx/circ.h"):

point_t c;
cord_t tmp;
circ_init(&c, &tmp, 10);

cord_t x = 0;
cord_t y = 0;
while(circ_cont(&c)) {
    x = CIRC_OCT1_X(c);
    y = CIRC_OCT1_Y(c);
    printf("Circle x: %d, y: %d\n", x, y);    /*Somehow print/read the variables*/
    circ_next(&c, &tmp);
}  

For me the output is:

Circle x: 10, y: 0
Circle x: 10, y: 1
Circle x: 10, y: 2
Circle x: 10, y: 3
Circle x: 9, y: 4
Circle x: 9, y: 5
Circle x: 8, y: 6
Circle x: 7, y: 7

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

I get the same results for the code you gave above. misc_conf.h attached
misc_conf.zip

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024

misc_conf.h looks good.

Are you using compiler optimization? If yes please try without it.

If it doesn't help we need to dig deeper. In lv_draw/lv_draw.c lv_draw_rect_border_corner() draws the rectangle border. You can dubug it to see whether it draws the circles cyclically or not. Don't care about what it does just see it draws in a cycle. The previous red border, blue line code is good to test.

from lvgl.

scopa90 avatar scopa90 commented on May 21, 2024

With optimisation off it creates such a large binary that it won't run. This is no longer an issue, though, as I now have rounded corners on buttons and do not have the ghost border decorations.

from lvgl.

kisvegabor avatar kisvegabor commented on May 21, 2024

I see. Then I close this issue again :)

Do you know what solved the issue?

from lvgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.