Easiest way to toggle button status (manually) in a button map?

I’m using physical buttons to control the virtual buttons in lvgl, so I’ve avoided using the event system lvgl provides so far. I have a button map, and so far the way I have toggled the button as pressed or unpressed is this:

if(myButtonShouldChangeState)
{
if(myButtonIsAlreadyPressed)
{
lv_btnm_set_pressed(btn_map, LV_BTNM_BTN_NONE);
}
else
{
lv_btnm_set_pressed(btn_map, button_index);
}
}

The problem with this is that it clears all the buttons statuses. Is there a way to set a button in a button map as unpressed similar to how I set it to pressed?

Also sorry for poorly formatted code. I don’t see a code format option on this forum =/

```c before your code and ``` after.

https://docs.littlevgl.com/en/html/object-types/btnm.html#control-buttons

I think you’ll want to use lv_btnm_[set/clear]_btn_ctrl(btn_map, LV_BTNM_CTRL_TGL_STATE). Only one button can be pressed or released at a time, but you can have as many buttons toggled as you want.

Got it. Thanks!