Description
- if I create a button matrix, its width may be 600, it consists of 3 buttons(like A, B, C),so each button’s width is 200. how to hide one the last button©, but each button’s width is still 200, I just hide the last button, but not change the whole size of the button matrix.
2.below is my code, I want to set the button matrix should has one button pressed everytime.
I set the button A pressed first, when I run the code, I clicked the button A, it turn to the unpressed. What I want is even if I always clicked the same button of in a button matrix, it should be pressed always.
What MCU/Processor/Board and compiler are you using?
eclipse
What do you want to achieve?
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.
The code block(s) should be formatted like:
static void btnm_event_cb(lv_obj_t* btnm, lv_event_t event)
{
if (event != LV_EVENT_CLICKED)
return;
}
void main ()
{
static const char* btnm_map[] = {"CH A", "CH B", "CH C", ""};
btnm = lv_btnm_create(parent, NULL);
lv_btnm_set_map(btnm, btnm_map);
lv_obj_set_size(btnm, 600, 33);
lv_btnm_set_btn_ctrl_all(btnm, LV_BTNM_CTRL_TGL_ENABLE);
lv_btnm_set_one_toggle(btnm, true);
lv_btnm_set_pressed(btnm, 0);
lv_obj_align(btnm, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(btnm, btnm_event_cb);
static lv_style_t style_btnm_bg;
lv_style_copy(&style_btnm_bg, &lv_style_pretty);
style_btnm_bg.body.padding.top = 0;
style_btnm_bg.body.padding.bottom = 0;
style_btnm_bg.body.padding.left = 0;
style_btnm_bg.body.padding.right = 0;
style_btnm_bg.body.padding.inner = 0;
static lv_style_t style_btnm_rel;
lv_style_copy(&style_btnm_rel, &lv_style_btn_rel);
style_btnm_rel.body.radius = 0;
style_btnm_rel.body.padding.top = 0;
style_btnm_rel.body.padding.bottom = 0;
style_btnm_rel.body.padding.left = 0;
style_btnm_rel.body.padding.right = 0;
style_btnm_rel.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
style_btnm_rel.body.border.width = 1;
static lv_style_t style_btnm_pr;
lv_style_copy(&style_btnm_pr, &lv_style_btn_pr);
style_btnm_pr.body.radius = 0;
style_btnm_pr.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
style_btnm_pr.body.border.width = 1;
static lv_style_t style_btnm_tgl_rel;
lv_style_copy(&style_btnm_tgl_rel, &lv_style_btn_tgl_rel);
style_btnm_tgl_rel.body.radius = 0;
style_btnm_tgl_rel.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
style_btnm_tgl_rel.body.border.width = 1;
static lv_style_t style_btnm_tgl_pr;
lv_style_copy(&style_btnm_tgl_pr, &lv_style_btn_tgl_pr);
style_btnm_tgl_pr.body.radius = 0;
style_btnm_tgl_pr.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
style_btnm_tgl_pr.body.border.width = 1;
lv_btnm_set_style(btnm, LV_BTNM_STYLE_BG, &style_btnm_bg);
lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_REL, &style_btnm_rel);
lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_PR, &style_btnm_pr);
lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL, &style_btnm_tgl_rel);
lv_btnm_set_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR, &style_btnm_tgl_pr);
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.