How to set color of buttons in a button matrix

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

Button matrix colors

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

Code::Blocks

What LVGL version are you using?

lvgl by kisvegabor version 9.2

What do you want to achieve?

I know that buttons in a matrix all have the same color, but how do I set that color?

What have you tried so far?

Trawled through LVGL documentation, searched this forum, searched the web, but
I cannot find an answer that makes sense or works.

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.

I have inserted my code below as instructed, but it does not look right.
My apologies if I have got this wrong.
Anyway, the code below runs OK, but I’d like to know what I need to put in
the commented line that starts // lv_obj_set_style_???

The code block(s) should be formatted like:

/*
lv_obj_t * buttons[15];
lv_obj_t * my_matrix;

// ************ Button Matrix *************

my_matrix = lv_buttonmatrix_create(lv_screen_active());

  lv_buttonmatrix_set_map   (my_matrix, btnm_map);
  lv_obj_remove_style_all   (my_matrix);
  lv_obj_set_size           (my_matrix,370,250);
  lv_obj_set_style_bg_color (my_matrix,Black, 0);

  // lv_obj_set_style_??????  What needs to go here to set colour of the buttons?

  lv_obj_add_event_cb (my_matrix, my_matrix_event, LV_EVENT_ALL, NULL);
*/

## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.

buttonmatrix have LV_PART_MAIN and LV_PART_ITEMS, you can use lv_obj_set_style_bg_color(my_matrix, lv_color_make(0,0,0), LV_PART_ITEMS);

Button matrix (lv_btnmatrix) — LVGL documentation

if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_BLUE, 3);

Thank you both for replies.
Both methods work; quite simple when you know how.
That is my problem – I find the LVGL “language” really very difficult to follow, and even for something as simple as above after much searching I cannot find an answer.
So I guess it’s a case of asking on the forum.

Anyway, griping over, problem solved, thanks again.