Get the text in the roller window and update the label

What MCU/Processor/Board and compiler are you using?

NXP MIMXRT1160-EVK / MCUXpresso IDE

What LVGL version are you using?

GUI Guider-1.3.0

What do you want to achieve?

Get text from a roller popup window and put that text on a label in another window
There are two roller pop-up windows, and it is possible to put it in the label of another window in the first roller pop-up window, but when you put it in the label of another window in the second roller pop-up window, the value of the first label is changed as well.

What have you tried so far?

I tried to store the value in the structure global variable and put that value into the label, but when I read the second roller value and put it in the label, the value in the first roller value global variable was initialized to 0, so it seemed that the value could not be read. The value changes according to the value of the second roller.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

//hearder file define
typedef struct{
	char *label_current;
}sMAIN_CONTROL;
extern sMAIN_CONTROL g_MAIN_PROJ;
extern sMAIN_CONTROL g_MAIN_SECOND;

//events_init.c
sMAIN_CONTROL g_MAIN_PROJ, g_MAIN_SECOND;

//first roller_proj
static void roller_proj_event_handler(lv_obj_t * obj, lv_event_t event)
{
	if(event == LV_EVENT_VALUE_CHANGED) {

       char buf[32];
	lv_roller_get_selected_str(guider_ui.set_projectile_roller_proj, buf, sizeof(buf));

	*g_MAIN_PROJ.label_current = buf;*

	/* go to main_home */
	lv_obj_clean(lv_scr_act());
	setup_scr_main_home(&guider_ui);
	lv_scr_load(guider_ui.main_home);

	}
}

//second roller_proj
static void roller_second_event_handler(lv_obj_t * obj, lv_event_t event)
{
	if(event == LV_EVENT_VALUE_CHANGED) {

		char second_buf[32];
		lv_roller_get_selected_str(guider_ui.set_second_roller_proj, second_buf, sizeof(second_buf));

		
		*g_MAIN_SECOND.label_current = second_buf;*
		
		/* go to main_home */
		lv_obj_clean(lv_scr_act());
		setup_scr_main_home(&guider_ui);
		lv_scr_load(guider_ui.main_home);
	}
}


//setup_scr_main_home.c
void setup_scr_main_home(lv_ui *ui){

//LABEL - PROJ
	//Write codes main_home_label_select_proj
	ui->main_home_label_select_proj = lv_label_create(ui->main_home, NULL);
	//lv_label_set_text(ui->main_home_label_select_proj, "aa");
	/* set text - main home */
	*lv_label_set_text(ui->main_home_label_select_proj, g_MAIN_PROJ.label_current);*

	lv_label_set_long_mode(ui->main_home_label_select_proj, LV_LABEL_LONG_BREAK);
	lv_label_set_align(ui->main_home_label_select_proj, LV_LABEL_ALIGN_CENTER);



	//LABEL - SECOND
	ui->main_home_label_select_second = lv_label_create(ui->main_home, NULL);
	//lv_label_set_text(ui->main_home_label_select_second, "hello");
	/* set text - main home */
	*lv_label_set_text(ui->main_home_label_select_second, g_MAIN_SECOND.label_current);*

	lv_label_set_long_mode(ui->main_home_label_select_second, LV_LABEL_LONG_BREAK);
	lv_label_set_align(ui->main_home_label_select_second, LV_LABEL_ALIGN_CENTER);
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.
strong text
image

When the button is pressed, it switches to the roller screen and
When a VALUED CHANGED event occurs on the roller screen, get the TXT in the roller and store it in a global variable, then return to the screen shot screen and try to change it to the TXT imported in the PROJ part

:grinning:

@kisvegabor/@embeddedt
Is this an unsupported feature?
It seems that the value of the global variable is initialized

It is currently LVGL version 7 and will be migrated to version 8.
please help thank you

1 Like

This line seems suspicious. Don’t you get warning for it?

  • Extra * at the end of the line?
  • *g_MAIN_PROJ.label_current mean g_MAIN_PROJ.label_current[0]

Wouldn’t be simpler to this?

typedef struct{
	char label_current[32];
}sMAIN_CONTROL;

...

lv_roller_get_selected_str(guider_ui.set_projectile_roller_proj, g_MAIN_PROJ.label_current, sizeof(g_MAIN_PROJ.label_current));
1 Like

image
image
image
image
image

What I’m trying to say is this

I don’t know why the value changes next to the first button when I press the second button and select an option for the roller.

I see the problem, but in the code you you sent earlier there are serious issues. I even wonder it’s compiled. So I suggest fixing them first.

1 Like

Thank you so much, it’s been resolved

Great! :slight_smile:

Finally what was the problem?

Changing the part you suggested solved the problem
thank you :grinning:


typedef struct{
	char label_current[32];
}sMAIN_CONTROL;

...

lv_roller_get_selected_str(guider_ui.set_projectile_roller_proj, g_MAIN_PROJ.label_current, sizeof(g_MAIN_PROJ.label_current));

Great, thanks for the feedback! :smiley: