| 89 | } |
| 90 | |
| 91 | void View::createPeerListItem(const bluetooth::PeerRecord& record, bool isPaired, size_t index) { |
| 92 | const auto percentage = mapRssiToPercentage(record.rssi); |
| 93 | const auto label = record.name.empty() |
| 94 | ? std::format("Unknown ({:02x}{:02x}{:02x}{:02x}{:02x}{:02x}) {}%", |
| 95 | record.addr[0], record.addr[1], record.addr[2], |
| 96 | record.addr[3], record.addr[4], record.addr[5], |
| 97 | percentage) |
| 98 | : std::format("{} {}%", record.name, percentage); |
| 99 | |
| 100 | auto* button = lv_list_add_button(peers_list, nullptr, label.c_str()); |
| 101 | |
| 102 | auto* item_data = new PeerListItemData { index, isPaired }; |
| 103 | lv_obj_set_user_data(button, item_data); |
| 104 | lv_obj_add_event_cb(button, onConnect, LV_EVENT_SHORT_CLICKED, item_data); |
| 105 | lv_obj_add_event_cb(button, [](lv_event_t* e) { |
| 106 | delete static_cast<PeerListItemData*>(lv_obj_get_user_data(lv_event_get_current_target_obj(e))); |
| 107 | }, LV_EVENT_DELETE, nullptr); |
| 108 | } |
| 109 | |
| 110 | // region Secondary updates |
| 111 |
nothing calls this directly
no test coverage detected