Changing cell background colour v7

Description

Trying to change cell background colour

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

imx6ul board with 7" touchscreen

What LVGL version are you using?

V7

What do you want to achieve?

I am trying to change the colour of cells in a table, making the first row a different colour to the rest
No matter what colour I assign to cell_style1 and cell_style2, the cell colour is always the same as the background colour. Change padding has a visible effect on the appropriate cells so I assume I am setting the type correctly. Can’t understand why the colour is not changing though, it always seems to be whatever colour the LV_TABLE_PART_BG is set too. Perhaps I am mistaken, but I would imagine setting a cell background colour would override the LV_TABLE_PART_BG background colour.

What have you tried so far?

   static lv_style_t cell_style;
   static lv_style_t cell_style1;
   static lv_style_t cell_style2;

   lv_style_init(&cell_style);
   lv_style_set_pad_top(&cell_style, LV_STATE_DEFAULT, 0);
   lv_style_set_pad_bottom(&cell_style, LV_STATE_DEFAULT, 0);
   lv_style_set_pad_left(&cell_style, LV_STATE_DEFAULT, 0);
   lv_style_set_pad_right(&cell_style, LV_STATE_DEFAULT, 0);
   lv_style_set_bg_color(&cell_style, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x00, 0x00, 0x60));
   
   lv_obj_t *lv_style_init(&cell_style1);
   lv_style_set_pad_top(&cell_style1, LV_STATE_DEFAULT, 4);
   lv_style_set_pad_bottom(&cell_style1, LV_STATE_DEFAULT, 4);
   lv_style_set_pad_left(&cell_style1, LV_STATE_DEFAULT, 12);
   lv_style_set_pad_right(&cell_style1, LV_STATE_DEFAULT, 12);
   lv_style_set_margin_top(&cell_style1, LV_STATE_DEFAULT, 0);
   lv_style_set_margin_bottom(&cell_style1, LV_STATE_DEFAULT, 0);
   lv_style_set_margin_left(&cell_style1, LV_STATE_DEFAULT, 0);
   lv_style_set_margin_right(&cell_style1, LV_STATE_DEFAULT, 0);
   lv_style_set_bg_color(&cell_style1, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x00, 0x60, 0x00));

   lv_obj_t *lv_style_init(&cell_style2);
   lv_style_set_pad_top(&cell_style2, LV_STATE_DEFAULT, 8);
   lv_style_set_pad_bottom(&cell_style2, LV_STATE_DEFAULT, 8);
   lv_style_set_pad_left(&cell_style2, LV_STATE_DEFAULT, 8);
   lv_style_set_pad_right(&cell_style2, LV_STATE_DEFAULT, 8);
   lv_style_set_margin_top(&cell_style2, LV_STATE_DEFAULT, 0);
   lv_style_set_margin_bottom(&cell_style2, LV_STATE_DEFAULT, 0);
   lv_style_set_margin_left(&cell_style2, LV_STATE_DEFAULT, 0);
   lv_style_set_margin_right(&cell_style2, LV_STATE_DEFAULT, 0);
   lv_style_set_bg_color(&cell_style2, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x60, 0x00, 0x00));
   
   
   
   /*Create a table - parent is a page object*/
   lv_obj_t *def_table = lv_table_create(parent, NULL);
   lv_obj_add_style(def_table, LV_TABLE_PART_BG, &cell_style);
   lv_obj_add_style(def_table, LV_TABLE_PART_CELL1, &cell_style1);
   lv_obj_add_style(def_table, LV_TABLE_PART_CELL2, &cell_style2);

   lv_obj_set_drag_parent(def_table, true);
   lv_table_set_col_width(def_table,0,335);
   lv_table_set_col_width(def_table,1,180);

   lv_table_set_col_cnt(def_table, 2);
   lv_table_set_row_cnt(def_table, 11);
   lv_obj_align(def_table, parent, LV_ALIGN_IN_TOP_MID, 0, 8);

   /*Make the cells of the first row center aligned */
   lv_table_set_cell_type(def_table, 0, 0, 2);
   lv_table_set_cell_type(def_table, 0, 1, 2);
   lv_table_set_cell_align(def_table, 0, 0, LV_LABEL_ALIGN_CENTER);
   lv_table_set_cell_align(def_table, 0, 1, LV_LABEL_ALIGN_CENTER);

   lv_table_set_cell_value(def_table, 0, 0, "key");
   lv_table_set_cell_value(def_table, 0, 1, "value");

   for(int i=0; i<10; i++) {
      lv_table_set_cell_type(def_table, i+1, 0, 1);
      lv_table_set_cell_value(def_table, i+1, 0, def_txt[i]);

      lv_table_set_cell_type(def_table, i+1, 1, 1);
      lv_table_set_cell_align(def_table, i+1, 1, LV_LABEL_ALIGN_RIGHT);
   }
   

I believe this looks to the compiler like a function declaration, so lv_style_init isn’t going to get called. I think the lv_obj_t * doesn’t belong here.

sorry yes you are right, I copied out my code to simplify the post, made a mistake there. not sure how that lv_obj_t* crept in from. It isn’t in the full code.

I have also just pulled the latest code from git as there have been some changes, however the colour is still not changing