update asserts
This commit is contained in:
31
examples/widgets/btnmatrix/lv_example_btnmatrix_1.c
Normal file
31
examples/widgets/btnmatrix/lv_example_btnmatrix_1.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "../../../lvgl.h"
|
||||
#include <stdio.h>
|
||||
#if LV_USE_BTNMATRIX
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
uint32_t id = lv_btnmatrix_get_active_btn(obj);
|
||||
const char * txt = lv_btnmatrix_get_btn_text(obj, id);
|
||||
|
||||
printf("%s was pressed\n", txt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char * btnm_map[] = {"1", "2", "3", "4", "5", "\n",
|
||||
"6", "7", "8", "9", "0", "\n",
|
||||
"Action1", "Action2", ""};
|
||||
|
||||
void lv_example_btnmatrix_1(void)
|
||||
{
|
||||
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act(), NULL);
|
||||
lv_btnmatrix_set_map(btnm1, btnm_map);
|
||||
lv_btnmatrix_set_btn_width(btnm1, 10, 2); /*Make "Action1" twice as wide as "Action2"*/
|
||||
lv_btnmatrix_set_btn_ctrl(btnm1, 10, LV_BTNMATRIX_CTRL_CHECKABLE);
|
||||
lv_btnmatrix_set_btn_ctrl(btnm1, 11, LV_BTNMATRIX_CTRL_CHECKED);
|
||||
lv_obj_align(btnm1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_event_cb(btnm1, event_handler, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user