lvgl / lv_demos

Examples, tutorials and applications for the LVGL embedded GUI library
https://lvgl.io
488 stars 366 forks source link

lv_demo_widgets problem - no buffer size info #121

Closed tdjastrzebski closed 2 years ago

tdjastrzebski commented 2 years ago

I think I found a problem in lv_demo_widgets.c. chart_event_cb() and shop_chart_event_cb() functions contain this line providing chart tick labels:

lv_snprintf(dsc->text, sizeof(dsc->text), "%s", month[dsc->value]);

The problem is sizeof(dsc->text) yields a pointer size (=4U) while the actual buffer length specified in lv_chart.c draw_x_ticks() function is 16 (hardcoded):

char buf[16];
...
part_draw_dsc.text = buf;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);

Perhaps .textSize property should be added to lv_obj_draw_part_dsc_t in addition to the buffer pointer .text.
Demo code as is currently can render only 3 chart tick label characters. LVGL rev 8.1-Dev (current)

kisvegabor commented 2 years ago

Good catch!

I agree with your suggestion. Could you send a pull request?

tdjastrzebski commented 2 years ago

PR lvgl/lvgl/pull/2694 and #127 created

kisvegabor commented 2 years ago

Both PRs are merged so I close this issue.