From db389372ada03f817ad19ec0927990dedc17ef63 Mon Sep 17 00:00:00 2001 From: Alexsey Date: Mon, 14 Dec 2020 19:34:44 +0500 Subject: [PATCH] Soapysdr: Improve sample rate information --- soapy_source/src/main.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/soapy_source/src/main.cpp b/soapy_source/src/main.cpp index 4ab5d84a..f3cff9a3 100644 --- a/soapy_source/src/main.cpp +++ b/soapy_source/src/main.cpp @@ -137,7 +137,14 @@ private: sampleRates = dev->listSampleRates(SOAPY_SDR_RX, channelId); txtSrList = ""; for (double sr : sampleRates) { - txtSrList += std::to_string((int)sr); + if (sr > 1.0e3 && sr <= 1.0e6) { + + txtSrList += std::to_string((sr / 1.0e3)) + " kHz"; + } else if (sr > 1.0e6) { + txtSrList += std::to_string((sr / 1.0e6)) + " MHz"; + } else { + txtSrList += std::to_string((int) sr); + } txtSrList += '\0'; } @@ -282,15 +289,15 @@ private: config.release(true); } - + ImGui::Text("Sample rate"); + ImGui::SameLine(); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); if (ImGui::Combo(CONCAT("##_sr_select_", _this->name), &_this->srId, _this->txtSrList.c_str())) { _this->selectSampleRate(_this->sampleRates[_this->srId]); _this->saveCurrent(); } - - ImGui::SameLine(); - float refreshBtnWdith = menuWidth - ImGui::GetCursorPosX(); - if (ImGui::Button(CONCAT("Refresh##_dev_select_", _this->name), ImVec2(refreshBtnWdith, 0))) { + ImGui::SetNextItemWidth(menuWidth); + if (ImGui::Button(CONCAT("Refresh##_dev_select_", _this->name))) { _this->refresh(); _this->selectDevice(config.conf["device"]); }