Where should I add C code generated by Edgeline?

Hi! When I export the C code, how can I add it to my project? I’m using stm32. I add the folder of what edgeline exported next to the other files of my projects, then I gave the address of header and C code to cubeIDE. When I built my project, I saw a lot of errors in this file. What should I do?
Actually, I added lvgl to my project before adding the edgeline file, and I did some work like calling lv_init().
Thank you in advance.

What kind of error do you get?

void SetOpacity(lv_obj_t * target, int val)
{
    lv_obj_set_style_local_opa_scale(target, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, val);
}

void anim_callback_set_x(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_x(a->user_data, v);
}

void anim_callback_set_y(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_y(a->user_data, v);
}

void anim_callback_set_width(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_width(a->user_data, v);
}

void anim_callback_set_height(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_height(a->user_data, v);
}

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS2 ////////////////////

///////////////////// SCREENS ////////////////////
void BuildPages(void)
{
    Screen1 = lv_obj_create(NULL, NULL);

    Spinner1 = lv_spinner_create(Screen1, NULL);
    lv_obj_set_size(Spinner1, 80, 80);
    lv_obj_align(Spinner1, Screen1, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_hidden(Spinner1, false);
    lv_obj_set_click(Spinner1, false);
    lv_obj_clear_state(Spinner1, LV_STATE_DISABLED);
    lv_obj_set_drag(Spinner1, false);

    Image1 = lv_img_create(Screen1, NULL);
    lv_obj_set_click(Image1, false);
    lv_obj_set_hidden(Image1, false);
    lv_obj_set_size(Image1, 158, 273);
    lv_obj_align(Image1, Screen1, LV_ALIGN_CENTER, -170, 0);
    lv_obj_set_drag(Image1, false);
    lv_obj_set_style_local_bg_color(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0 * 256 * 256 + 0 * 256 + 0));
    lv_obj_set_style_local_bg_opa(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, 255);
    lv_obj_set_style_local_image_recolor(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT,
                                         lv_color_hex(46 * 256 * 256 + 16 * 256 + 218));
    lv_obj_set_style_local_image_recolor_opa(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, 255);

    lv_obj_clear_state(Image1, LV_STATE_DISABLED);

}

These lines have a lot of problems. I’ve written #include lvgl.h above, and helped me get rid of some errors, but I still have some problems and error in this code. For example some lines have “too many arguments to function” or “undeclared”.

Note that, the current version of EdgeLine is for LVGL v7.

I used lvgl v7.11, but when I added just this library, I had 1900 errors. However, I gave cubeIDE address of header files. All of these errors come from scr of lvgl folder. I didn’t have these issues with new version of lvgl.

#include "4.3 inch_ui.h"
#include "lvgl.h"
#include "lv_obj.h"
#include "lv_obj_style_dec.h"
#include "lv_style.h"
#include "lv_anim.h"
///////////////////// VARIABLES ////////////////////
lv_obj_t * Screen1;
lv_obj_t * Spinner1;
lv_obj_t * Image1;

///////////////////// IMAGES ////////////////////

///////////////////// FUNCTIONS ////////////////////
#define BAR_PROPERTY_VALUE 0
#define BAR_PROPERTY_VALUE_WITH_ANIM 1

void SetBarProperty(lv_obj_t * target, int id, int val)
{
    if(id == BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON);
    if(id == BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF);
}

#define BASIC_PROPERTY_POSITION_X 0
#define BASIC_PROPERTY_POSITION_Y 1
#define BASIC_PROPERTY_WIDTH 2
#define BASIC_PROPERTY_HEIGHT 3
#define BASIC_PROPERTY_CLICKABLE 4
#define BASIC_PROPERTY_HIDDEN 5
#define BASIC_PROPERTY_DRAGABLE 6
#define BASIC_PROPERTY_DISABLED 7

void SetBasicProperty(lv_obj_t * target, int id, int val)
{
    if(id == BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val);
    if(id == BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val);
    if(id == BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val);
    if(id == BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val);
}

void SetBasicPropertyB(lv_obj_t * target, int id, bool val)
{
    if(id == BASIC_PROPERTY_CLICKABLE) lv_obj_set_click(target, val);
    if(id == BASIC_PROPERTY_HIDDEN) lv_obj_set_hidden(target, val);
    if(id == BASIC_PROPERTY_DRAGABLE) lv_obj_set_drag(target, val);
    if(id == BASIC_PROPERTY_DISABLED) {
        if(val) lv_obj_add_state(target, LV_STATE_DISABLED);
        else lv_obj_clear_state(target, LV_STATE_DISABLED);
    }
}

#define BUTTON_PROPERTY_TOGGLE 0
#define BUTTON_PROPERTY_CHECKED 1

void SetButtonProperty(lv_obj_t * target, int id, bool val)
{
    if(id == BUTTON_PROPERTY_TOGGLE) lv_btn_toggle(target);
    if(id == BUTTON_PROPERTY_CHECKED) lv_btn_set_state(target, val ? LV_BTN_STATE_CHECKED_RELEASED : LV_BTN_STATE_RELEASED);
}

#define DROPDOWN_PROPERTY_SELECTED 0

void SetDropdownProperty(lv_obj_t * target, int id, int val)
{
    if(id == DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val);
}

#define IMAGE_PROPERTY_IMAGE 0

void SetImageProperty(lv_obj_t * target, int id, uint8_t * val)
{
    if(id == IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val);
}

#define LABEL_PROPERTY_TEXT 0

void SetLabelProperty(lv_obj_t * target, int id, char * val)
{
    if(id == LABEL_PROPERTY_TEXT) lv_label_set_text(target, val);
}

#define ROLLER_PROPERTY_SELECTED 0
#define ROLLER_PROPERTY_SELECTED_WITH_ANIM 1

void SetRollerProperty(lv_obj_t * target, int id, int val)
{
    if(id == ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON);
    if(id == ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF);
}

#define SLIDER_PROPERTY_VALUE 0
#define SLIDER_PROPERTY_VALUE_WITH_ANIM 1

void SetSliderProperty(lv_obj_t * target, int id, int val)
{
    if(id == SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON);
    if(id == SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF);
}

void ChangeScreen(lv_obj_t * target, int fademode, int spd, int delay)
{
    lv_scr_load_anim(target, fademode, spd, delay, false);
}

void SetOpacity(lv_obj_t * target, int val)
{
    lv_obj_set_style_local_opa_scale(target, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, val);
}

void anim_callback_set_x(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_x(a->user_data, v);
}

void anim_callback_set_y(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_y(a->user_data, v);
}

void anim_callback_set_width(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_width(a->user_data, v);
}

void anim_callback_set_height(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_height(a->user_data, v);
}

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS2 ////////////////////

///////////////////// SCREENS ////////////////////
void BuildPages(void)
{
    Screen1 = lv_obj_create(NULL, NULL);

    Spinner1 = lv_spinner_create(Screen1, NULL);
    lv_obj_set_size(Spinner1, 80, 80);
    lv_obj_align(Spinner1, Screen1, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_hidden(Spinner1, false);
    lv_obj_set_click(Spinner1, false);
    lv_obj_clear_state(Spinner1, LV_STATE_DISABLED);
    lv_obj_set_drag(Spinner1, false);

    Image1 = lv_img_create(Screen1, NULL);
    lv_obj_set_click(Image1, false);
    lv_obj_set_hidden(Image1, false);
    lv_obj_set_size(Image1, 158, 273);
    lv_obj_align(Image1, Screen1, LV_ALIGN_CENTER, -170, 0);
    lv_obj_set_drag(Image1, false);
    lv_obj_set_style_local_bg_color(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0 * 256 * 256 + 0 * 256 + 0));
    lv_obj_set_style_local_bg_opa(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, 255);
    lv_obj_set_style_local_image_recolor(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT,
                                         lv_color_hex(46 * 256 * 256 + 16 * 256 + 218));
    lv_obj_set_style_local_image_recolor_opa(Image1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, 255);

    lv_obj_clear_state(Image1, LV_STATE_DISABLED);

}



I added lvgl V7.11, and I solved some errors and problems, but still, my project has some errors. The code above is the c code that is generated by EdgeLine, and I add this file in the core folder next to the scr, inc and startup. It’s header file has an error that says “macro names must be identifiers”. In its c code there is some problems in lv_obj_set_x(a->user_data , v). This says has no member named user_data. Do you have any idea?

#include “4.3 inch_ui.h”

It seems like an invalid name. Having whitespace in the filename can cause issues.
Anyway, EdgeLine should take care of converting the filenames to a valid format. We will add it.

lv_obj_set_x(a->user_data , v).

Be sure to enable LV_USE_USER_DATA in lv_conf.h.

1 Like

Thank you for responding. I exported the c code again with a different name that’s started with a letter not a number. And I avoided whitespace. Actually, I still have some errors about user_data, and I enabled LV_USE_USER_DATA in lv_conf.h. I don’t know what is wrong. It’s the C code :point_down: :point_down:

#include "edgeline_ui.h"
#include "lv_theme.h"
#include "lv_anim.h"
///////////////////// VARIABLES ////////////////////
lv_obj_t * Screen1;
lv_obj_t * Spinner1;



///////////////////// IMAGES ////////////////////

///////////////////// FUNCTIONS ////////////////////
#define BAR_PROPERTY_VALUE 0
#define BAR_PROPERTY_VALUE_WITH_ANIM 1

void SetBarProperty(lv_obj_t * target, int id, int val)
{
    if(id == BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON);
    if(id == BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF);
}

#define BASIC_PROPERTY_POSITION_X 0
#define BASIC_PROPERTY_POSITION_Y 1
#define BASIC_PROPERTY_WIDTH 2
#define BASIC_PROPERTY_HEIGHT 3
#define BASIC_PROPERTY_CLICKABLE 4
#define BASIC_PROPERTY_HIDDEN 5
#define BASIC_PROPERTY_DRAGABLE 6
#define BASIC_PROPERTY_DISABLED 7

void SetBasicProperty(lv_obj_t * target, int id, int val)
{
    if(id == BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val);
    if(id == BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val);
    if(id == BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val);
    if(id == BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val);
}

void SetBasicPropertyB(lv_obj_t * target, int id, bool val)
{
    if(id == BASIC_PROPERTY_CLICKABLE) lv_obj_set_click(target, val);
    if(id == BASIC_PROPERTY_HIDDEN) lv_obj_set_hidden(target, val);
    if(id == BASIC_PROPERTY_DRAGABLE) lv_obj_set_drag(target, val);
    if(id == BASIC_PROPERTY_DISABLED) {
        if(val) lv_obj_add_state(target, LV_STATE_DISABLED);
        else lv_obj_clear_state(target, LV_STATE_DISABLED);
    }
}

#define BUTTON_PROPERTY_TOGGLE 0
#define BUTTON_PROPERTY_CHECKED 1

void SetButtonProperty(lv_obj_t * target, int id, bool val)
{
    if(id == BUTTON_PROPERTY_TOGGLE) lv_btn_toggle(target);
    if(id == BUTTON_PROPERTY_CHECKED) lv_btn_set_state(target, val ? LV_BTN_STATE_CHECKED_RELEASED : LV_BTN_STATE_RELEASED);
}

#define DROPDOWN_PROPERTY_SELECTED 0

void SetDropdownProperty(lv_obj_t * target, int id, int val)
{
    if(id == DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val);
}

#define IMAGE_PROPERTY_IMAGE 0

void SetImageProperty(lv_obj_t * target, int id, uint8_t * val)
{
    if(id == IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val);
}

#define LABEL_PROPERTY_TEXT 0

void SetLabelProperty(lv_obj_t * target, int id, char * val)
{
    if(id == LABEL_PROPERTY_TEXT) lv_label_set_text(target, val);
}

#define ROLLER_PROPERTY_SELECTED 0
#define ROLLER_PROPERTY_SELECTED_WITH_ANIM 1

void SetRollerProperty(lv_obj_t * target, int id, int val)
{
    if(id == ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON);
    if(id == ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF);
}

#define SLIDER_PROPERTY_VALUE 0
#define SLIDER_PROPERTY_VALUE_WITH_ANIM 1

void SetSliderProperty(lv_obj_t * target, int id, int val)
{
    if(id == SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON);
    if(id == SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF);
}

void ChangeScreen(lv_obj_t * target, int fademode, int spd, int delay)
{
    lv_scr_load_anim(target, fademode, spd, delay, false);
}

void SetOpacity(lv_obj_t * target, int val)
{
    lv_obj_set_style_local_opa_scale(target, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, val);
}

void anim_callback_set_x(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_x(a->user_data, v);
}

void anim_callback_set_y(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_y(a->user_data, v);
}

void anim_callback_set_width(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_width(a->user_data, v);
}

void anim_callback_set_height(lv_anim_t * a, lv_anim_value_t v)
{
    lv_obj_set_height(a->user_data, v);
}

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS2 ////////////////////

///////////////////// SCREENS ////////////////////
void BuildPages(void)
{
    Screen1 = lv_obj_create(NULL, NULL);

    Spinner1 = lv_spinner_create(Screen1, NULL);
    lv_obj_set_size(Spinner1, 80, 80);
    lv_obj_align(Spinner1, Screen1, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_hidden(Spinner1, false);
    lv_obj_set_click(Spinner1, false);
    lv_obj_clear_state(Spinner1, LV_STATE_DISABLED);
    lv_obj_set_drag(Spinner1, false);

}


And it’s the header file of edgline :point_down:

#ifndef EDGELINE_UI_H
#define EDGELINE_UI_H

#ifdef __cplusplus
extern "C" {
#endif

#include "lvgl.h"

extern lv_obj_t * Screen1;
extern lv_obj_t * Spinner1;



#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif

Thank you. All of errors were solved. As last question, did I copy the edgeline C code in right place? I copied that in the core folder, next to the inc, scr and startup folder. Is it OK?

1 Like

Form EdgeLine point of view it doesn’t important if you can build the code :slight_smile:
But once there is src and inc folder it might be worth using them for the c and h files.

1 Like

Ok. Thank you so much. Tomorrow I will test my code on an LCD, and I will share the result.