lv_gui_builder icon indicating copy to clipboard operation
lv_gui_builder copied to clipboard

Build-time configuration needs to be adjustable at run-time

Open AGlass0fMilk opened this issue 6 years ago • 11 comments

When building for GUI builder, certain parameters of the LittlevGL configuration should be adjustable at run-time. Some examples include:

  • Display resolution
  • Color depth
  • Cursor blink speed

Additionally, all modules must be enabled for use by the GUI builder.

I have to look a bit deeper to see how complicated it would be to change things like the display resolution at run-time. Some things will likely require an entire restart of the lvgl rendering system.

It could be useful to introduce a new preprocessor macro that will enable modules such as: #if USE_LV_ARC != 0 || GUI_BUILDER_BUILD

AGlass0fMilk avatar Mar 06 '19 02:03 AGlass0fMilk

@AGlass0fMilk Work is already being done to upgrade LittlevGL to dynamically handle rotation/multiple displays, which should solve that part of the problem: https://github.com/littlevgl/lvgl/issues/329

embeddedt avatar Mar 06 '19 03:03 embeddedt

Aa @embeddedt mentioned a lot of formerly defined parameters will be (or already) reworked to be run-time settable.

It could be useful to introduce a new preprocessor macro that will enable modules such as: #if USE_LV_ARC != 0 || GUI_BUILDER_BUILD

We should have 2 lv_conf.h:

  1. for the Python binding. Here everything should be enabled to add all options to the editor. The user has nothing to do with that.
  2. and other for the exported GUI code. Here some options can be automatically disabled when they are not used in the editor.

kisvegabor avatar Mar 06 '19 14:03 kisvegabor

@kisvegabor It's been a while but I read through some of the issues in lvgl and it seems this requirement is complete in the dev-6.0 feature branch? Is that correct?

I am working on updating the pylvgl binding to lvgl 6.0, see https://github.com/rreilink/pylvgl/issues/3

AGlass0fMilk avatar May 22 '19 04:05 AGlass0fMilk

It's been a while but I read through some of the issues in lvgl and it seems this requirement is complete in the dev-6.0 feature branch? Is that correct?

Yes, we turned all possible hard-coded settings to run-time configuration. So I think we can close this issue.

I am working on updating the pylvgl binding to lvgl 6.0, see rreilink/pylvgl#3

Awesome! We are planning to release v6.0 in June so there is some time to update things if necessary.

kisvegabor avatar May 22 '19 04:05 kisvegabor

@kisvegabor could you briefly go over what "all possible hard-coded settings" are and what API(s) have been introduced to alter them at run-time?

AGlass0fMilk avatar May 22 '19 13:05 AGlass0fMilk

@AGlass0fMilk

  • Most of the display-related settings (resolution, buffer size, etc.) are now configured at runtime. This should give you an idea: https://github.com/littlevgl/lvgl/blob/dev-6.0/porting/lv_port_disp_template.c

    • However, there is now a hardcoded maximum display size, though we could just set it to a reasonable value for a typical embedded platform (i.e. I see little need to go beyond 1024x768).
  • A similar concept was applied for input devices, though they have always been configurable at runtime.

  • As @kisvegabor mentioned, we can just enable all feature-related options with a separate lv_conf.h for the GUI builder. That way those settings don't need to be altered at runtime.

The only remaining hardcoded settings besides those that would be worth changing IMO are:

The other hardcoded settings are outside of the scope of the GUI builder (things like color depth and memory management).

embeddedt avatar May 22 '19 14:05 embeddedt

@AGlass0fMilk Have look at these structs to see the run time configurable parameters:

  • Display: https://github.com/littlevgl/lvgl/blob/dev-6.0/src/lv_hal/lv_hal_disp.h#L59
  • Indev: https://github.com/littlevgl/lvgl/blob/dev-6.0/src/lv_hal/lv_hal_indev.h#L71

@embeddedt

LV_COLOR_TRANSP: This probably needs to be made into a runtime setting, because it would depend on the application being built. I don't think this would be difficult to change.

We can make it configurable for each display if you find it reasonable.

Possibly the text settings.

It could be possible too to store these values in variables and pointers and use the defines as default values.

The cursor blink and pasword show times for the text area.

We can turn them object specific properties and use the defines as default values here too.

I just saw something which can be problematic. See LV_USE_EXT_CLICK_AREA. This define replaces a function with an other. Fortunately, there aren't so many cases like this. Here the solution could be to enable both functions and hide the #if LV_USE_EXT_CLICK_AREA == ... part inside them.

kisvegabor avatar May 23 '19 04:05 kisvegabor

This define replaces a function with an other. Fortunately, there aren't so many cases like this. Here the solution could be to enable both functions and hide the #if LV_USE_EXT_CLICK_AREA == ... part inside them.

Why not just enable the full API (with padding for all sides) and if the tiny version is used, use the larger of the two values?

It would work somewhat like this:

/**
 * Set the size of an extended clickable area
 *
 * If TINY mode is used, only the largest of the horizontal and vertical padding
 * values are considered.
 *
 * @param obj pointer to an object
 * @param left extended clickable are on the left [px]
 * @param right extended clickable are on the right [px]
 * @param top extended clickable are on the top [px]
 * @param bottom extended clickable are on the bottom [px]
 */
void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom)
{
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
    obj->ext_click_pad.x1 = left;
    obj->ext_click_pad.x2 = right;
    obj->ext_click_pad.y1 = top;
    obj->ext_click_pad.y2 = bottom;
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
    obj->ext_click_pad_hor= LV_MATH_MAX(left, right);
    obj->ext_click_pad_ver = LV_MATH_MAX(top, bottom);
#endif
}

The advantage of this setup is that regular users no longer need to adjust their code if they change that config setting.

embeddedt avatar May 23 '19 14:05 embeddedt

@embeddedt I updated it as you suggested https://github.com/littlevgl/lvgl/commit/d3d9fde2451d266aab9a4117e41eaa405116abf8

If you agree I can make LV_COLOR_TRANSP, text, and Text area setting run-time configurable.

kisvegabor avatar May 24 '19 04:05 kisvegabor

@kisvegabor Excellent! That's exactly what I was thinking!

embeddedt avatar May 24 '19 12:05 embeddedt

I updated LV_COLOR_TRANSP, LV_TA_CURSOR_BLINK_TIME and LV_TA_PWD_SHOW_TIME. See https://github.com/littlevgl/lvgl/commit/b0fffaa55b52e517ddac4c66f7044dff24b0fffd

kisvegabor avatar May 25 '19 14:05 kisvegabor