Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LVGL+Flow] Spinbox specific properties can be expressions/assignable #492

Open
fietser28 opened this issue Aug 23, 2024 · 12 comments
Open
Assignees
Milestone

Comments

@fietser28
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
I can't dynamically change some of the properties of the spinbox.

Describe the solution you'd like
I would like to have the option to set the specific settings of the spinbox to an expression, not just literal.
These are the settings that the use of the spinbox doesn't change (expression not assignable).

In my case the spinbox properties need to change when I change to a different mode in my application. As an example I've filled in the expressions I need in the literal fields:
image

Describe alternatives you've considered

  1. Create a fixed spinbox for each mode and swap between these.
  2. Keep my current manual implementation in flow/native.

Additional context
This has a relation to #229 because spin boxes are mainly useful with encoders (imho).

@fietser28
Copy link
Collaborator Author

I noticed LVGL API is lacking:

  • lv_spinbox_get_range_min
  • lv_spinbox_get_range_max
  • lv_spinbox_get_digit_format_count
  • lv_spinbox_get_digit_format_position

So did some digging in lvgl sources. Would this be an option to use (to get min range value) as a temporary(?) workaround:

        lv_spinbox_t *spinbox = (lv_spinbox_t *)objects.obj14;
        int32_t cur_value =  spinbox->range_min;

@fietser28
Copy link
Collaborator Author

I've implemented part of it. Min/max range can be an expression now.
See branch: https://github.com/fietser28/studio/tree/spinbox

Will work on the format count and position options in the same way before creating a merge request.

Feel free to comment on the solution I used.
I might also create an issue in LVGL repo whether they will add the above calls. Probably won't be added backwards to v8.

@fietser28 fietser28 self-assigned this Aug 23, 2024
@fietser28
Copy link
Collaborator Author

image
is working now on MCU using my branch. The simulator is WIP.

@mvladic
Copy link
Contributor

mvladic commented Aug 26, 2024

I flew through the changes a bit and it looks pretty good to me. When you're done, I'll take a closer look. The next release should be by this Monday. If you can finish it by Friday then we can add it to this release.

@mvladic
Copy link
Contributor

mvladic commented Aug 28, 2024

I noticed LVGL API is lacking:

  • lv_spinbox_get_range_min
  • lv_spinbox_get_range_max
  • lv_spinbox_get_digit_format_count
  • lv_spinbox_get_digit_format_position

So did some digging in lvgl sources. Would this be an option to use (to get min range value) as a temporary(?) workaround:

        lv_spinbox_t *spinbox = (lv_spinbox_t *)objects.obj14;
        int32_t cur_value =  spinbox->range_min;

FYI In version 9.2 you can't access members of lv_spinbox or any other widget directly. Workaround is to include "lvgl/src/lvgl_private.h".

@fietser28
Copy link
Collaborator Author

FYI In version 9.2 you can't access members of lv_spinbox or any other widget directly. Workaround is to include "lvgl/src/lvgl_private.h".

Thanks for the tip.

I don't know if I will have the time to finish this before the end of the week.

@mvladic
Copy link
Contributor

mvladic commented Aug 28, 2024

I don't know if I will have the time to finish this before the end of the week.

Never mind, take your time and we will release it when it is ready.

@mvladic mvladic added this to the v1.0 milestone Sep 27, 2024
@fietser28
Copy link
Collaborator Author

fietser28 commented Sep 28, 2024

I've added some updates to the branch (while following master branch). Current status is:

In simulator:

  • V9.1 works, except when step is an assignable: Then clicking on a digit with mouse the position flips back.
  • V8.3 works until you click on the spinbox: Then simulation freezes. Can't figure out why.
  • AFIAK generated code works also in combination with groups on hardware
  • using expressions in the expression fields doesn't work reliably. Using variables works fine.

@fietser28
Copy link
Collaborator Author

Here is a test project to explore the different features.
spinboxTest.eez-project.zip

@fietser28
Copy link
Collaborator Author

fietser28 commented Sep 28, 2024

Also note the last commit I make Commented out unnecesairy callbacks: These are expressions not assignable?
. Is the assumption correct these callbacks are not needed/must not be present when the parameter is an expression?

@mvladic mvladic modified the milestones: v1.0, 0.18.0 Sep 28, 2024
@mvladic
Copy link
Contributor

mvladic commented Sep 30, 2024

I'm not happy how currently adding new LVGL widget works. We have separate definitions for editing and running inside simulator (lvglCreate functions) and for source code generator (lvglBuild functions). So, you need to implemented all these functions:

lvglCreateObj
lvglBuild
lvglBuildTickSpecific

and some more:

getIsAccessibleFromSourceCode
lvglPostBuild

And, even worse, for lvglCreate you need to implement wrapper code for the LVGL (the stuff in studio_api.cpp).

I think, ideally, you should implement only one function that should work for both simulator and source code generator. And you shouldn't need to write wrapper code.

I have some ideas how to do it, so for now I think you should stop working on this since it is possible that very soon I start to refactor all this lvglCreate and lvglBuild code.

@fietser28
Copy link
Collaborator Author

Ok, I agree with you on your analysis. For adding/changing a single widgets parameters I had to touch code in a lot of different places (was not easy to figure it out).

I also changed a few things in expression-property.tsx. Imho these functions will become unmaintainable if more LVGL versions and widgets are added.

@mvladic mvladic modified the milestones: 0.18.0, 0.19.0 Oct 5, 2024
@mvladic mvladic modified the milestones: 0.19.0, v1.0 Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants