diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c index 7b6f94869..7fe8b62a5 100644 --- a/app/src/display/widgets/output_status.c +++ b/app/src/display/widgets/output_status.c @@ -22,12 +22,14 @@ static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); struct output_status_state { struct zmk_endpoint_instance selected_endpoint; + int active_profile_index; bool active_profile_connected; bool active_profile_bonded; }; static struct output_status_state get_state(const zmk_event_t *_eh) { return (struct output_status_state){.selected_endpoint = zmk_endpoints_selected(), + .active_profile_index = zmk_ble_active_profile_index(), .active_profile_connected = zmk_ble_active_profile_is_connected(), .active_profile_bonded = !zmk_ble_active_profile_is_open()}; @@ -35,29 +37,38 @@ static struct output_status_state get_state(const zmk_event_t *_eh) { } static void set_status_symbol(lv_obj_t *label, struct output_status_state state) { +#if defined(CONFIG_ZMK_BLE) char text[20] = {}; + const char *transport_symbol = "?"; switch (state.selected_endpoint.transport) { case ZMK_TRANSPORT_USB: - strcat(text, LV_SYMBOL_USB); + transport_symbol = LV_SYMBOL_USB; break; case ZMK_TRANSPORT_BLE: - if (state.active_profile_bonded) { - if (state.active_profile_connected) { - snprintf(text, sizeof(text), LV_SYMBOL_WIFI " %i " LV_SYMBOL_OK, - state.selected_endpoint.ble.profile_index + 1); - } else { - snprintf(text, sizeof(text), LV_SYMBOL_WIFI " %i " LV_SYMBOL_CLOSE, - state.selected_endpoint.ble.profile_index + 1); - } - } else { - snprintf(text, sizeof(text), LV_SYMBOL_WIFI " %i " LV_SYMBOL_SETTINGS, - state.selected_endpoint.ble.profile_index + 1); - } + transport_symbol = LV_SYMBOL_WIFI; break; } + const char *connection_symbol = LV_SYMBOL_SETTINGS; + if (state.active_profile_bonded) { + if (state.active_profile_connected) { + connection_symbol = LV_SYMBOL_OK; + } else { + connection_symbol = LV_SYMBOL_CLOSE; + } + } + + // Display active transport (USB/BLE), active BLE profile index (1-based) and connection status + // of active BLE profile + snprintf(text, sizeof(text), "%s %i %s", transport_symbol, state.active_profile_index + 1, + connection_symbol); + lv_label_set_text(label, text); +#else // !defined(CONFIG_ZMK_BLE) + // If BLE is not enabled, just show USB symbol + lv_label_set_text(label, LV_SYMBOL_USB); +#endif } static void output_status_update_cb(struct output_status_state state) {