Description
How to make a button with a handler from an image?
What MCU/Processor/Board and compiler are you using?
STM32F407
What LVGL version are you using?
7
What do you want to achieve?
When you click on the button with the image, get an interrupt and a handler
What have you tried so far?
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.
static lv_style_t style;
lv_style_init(&style);
lv_style_set_radius(&style, LV_STATE_DEFAULT, 5);
lv_style_set_border_width(&style, LV_STATE_DEFAULT, 2); // Задайте свойство типа целочисленного типа в стиле
lv_style_set_border_color(&style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 7);
lv_style_set_pad_bottom(&style, LV_STATE_DEFAULT, 7);
lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 7);
lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 7);
#if LV_USE_IMG
/Create an object with the new style/
lv_obj_t * obj = lv_img_create(lv_scr_act(), NULL);
lv_obj_add_style(obj, LV_IMG_PART_MAIN, &style);
LV_IMG_DECLARE(Custom_set);
lv_img_set_src(obj, &Custom_set);
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 100, -40);
The code block(s) should be formatted like:
/*You code here*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.