Hi, I’m learning still and need some help. I need to check if two labels have the same info and the do an event. I cant get it to work. I have done the following. Any help maybe?
I want the label text to be compared, but I think im on the wrong path here.
static void button_change_colour_event_handler_b2(lv_event_t *e) {//button B2 color change B
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *btn = (lv_obj_t *)lv_event_get_user_data(e);
lv_obj_t *option_aa = (lv_obj_t *)(lv_label_get_text(objects.b2_number));
lv_obj_t *option_bb = (lv_obj_t *)(lv_label_get_text(objects.caller_label));
if (option_aa == option_bb) {
lv_obj_set_style_bg_color(btn, lv_color_hex(0xE0301E), LV_PART_MAIN | LV_STATE_DEFAULT); // red change B2
}
}
you can find in docs lv_label_get_text()
prototype, it:
char * lv_label_get_text(const lv_obj_t * obj)
so this function get the text of a label. There is no sense to compare text pointers, you need to compare labels text. Use strcmp()
.
Thanks, I’m going to play around, I can program closed eyes in Visual Basic, by learning another language is always tricky.
Just wish there was examples on the internet of someone trying to do wat I’m trying.
2 labels to compare and then do an event, like change button color and so on.
But thank you for the response.
if (strcmp(lv_label_get_text(objects.b2_number), lv_label_get_text(objects.caller_label)) == 0) {
lv_obj_set_style_bg_color(btn, lv_color_hex(0xE0301E), LV_PART_MAIN | LV_STATE_DEFAULT); // red change B2
}
Thank you so much Glory-man. Was it actually that easy?! I was on the total wrong track. Now i feel very silly. THANK YOU!!!