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

[EEZ-FLOW] Properties for the user defined actions and widgets #527

Closed
2 tasks done
mvladic opened this issue Sep 8, 2024 · 2 comments
Closed
2 tasks done

[EEZ-FLOW] Properties for the user defined actions and widgets #527

mvladic opened this issue Sep 8, 2024 · 2 comments
Assignees
Milestone

Comments

@mvladic
Copy link
Contributor

mvladic commented Sep 8, 2024

Built-in actions and widgets can have one or more properties. For example, Delay action has "Milliseconds" property and Label widget has "Text" property. This feature will allow the same for the user defined actions and widgets.

  • Add "User properties" list for the user defined actions and widgets:

    image

    Each User Property has the following fields:

    • Name: the name of the property. You can use this name in expressions, same as local variable for example.
    • Type: is the type of property.
    • Assignable: check this option if user action or widget can change the passed value so that change is visible from the caller flow. This means that you can't set any expression for this property, but only expressions in which value can be assigned/stored. For example, you can't set my_var + 1 expression, but you can set my_var expression.
    • Display name: This name is visible from the place where user action or widget is used (see below)
    • Description: This description is displayed in the place where user action or widget is used (see below)
  • Add expression field for each user property where user action or widget is used:

    image

There is one important difference in user properties between action and widget. For the actions, properties are evaluated at the start of execution and for the widgets they are evaluated all the time - so it will be watched for the changes made in the page that contains user widget. This is same as for the built-in actions and widgets.

This feature should be available in the LVGL, Dashboard and EEZ-GUI projects.

@mvladic mvladic self-assigned this Sep 8, 2024
mvladic added a commit that referenced this issue Sep 8, 2024
@mvladic mvladic added this to the M23 milestone Sep 9, 2024
@mvladic
Copy link
Contributor Author

mvladic commented Sep 27, 2024

Implemented.

@mvladic
Copy link
Contributor Author

mvladic commented Dec 14, 2024

User properties are also accessible (for both read and write) from the native user actions, here is an example:

actions.h

#ifndef EEZ_LVGL_UI_EVENTS_H
#define EEZ_LVGL_UI_EVENTS_H

#include <lvgl/lvgl.h>

#ifdef __cplusplus
extern "C" {
#endif


enum {
    ACTION_MY_NATIVE_USER_ACTION_PROPERTY_A,
    ACTION_MY_NATIVE_USER_ACTION_PROPERTY_B,
    ACTION_MY_NATIVE_USER_ACTION_PROPERTY_RESULT,
};
extern void action_my_native_user_action(lv_event_t * e);



#ifdef __cplusplus
}
#endif

#endif /*EEZ_LVGL_UI_EVENTS_H*/

actions.cpp

#include "eez-flow.h"
#include "actions.h"

void action_my_native_user_action(lv_event_t *e) {
    using namespace eez;
    using namespace eez::flow;

    Value a = getUserProperty(ACTION_MY_NATIVE_USER_ACTION_PROPERTY_A);
    Value b = getUserProperty(ACTION_MY_NATIVE_USER_ACTION_PROPERTY_B);

    setUserProperty(ACTION_MY_NATIVE_USER_ACTION_PROPERTY_RESULT, Value(a.getInt32() + b.getInt32(), VALUE_TYPE_INT32));
}

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

3 participants