Added FFT hold feature

This commit is contained in:
AlexandreRouma 2022-03-31 20:16:21 +02:00
parent 83da29e80b
commit 747b6bfbc6
8 changed files with 50 additions and 6 deletions

View File

@ -108,6 +108,8 @@ int sdrpp_main(int argc, char* argv[]) {
defConfig["bandPlanPos"] = 0; defConfig["bandPlanPos"] = 0;
defConfig["centerTuning"] = false; defConfig["centerTuning"] = false;
defConfig["colorMap"] = "Classic"; defConfig["colorMap"] = "Classic";
defConfig["fftHold"] = false;
defConfig["fftHoldSpeed"] = 60;
defConfig["fastFFT"] = false; defConfig["fastFFT"] = false;
defConfig["fftHeight"] = 300; defConfig["fftHeight"] = 300;
defConfig["fftRate"] = 20; defConfig["fftRate"] = 20;

View File

@ -21,6 +21,8 @@ namespace displaymenu {
int fftRate = 20; int fftRate = 20;
int uiScaleId = 0; int uiScaleId = 0;
bool restartRequired = false; bool restartRequired = false;
bool fftHold = false;
int fftHoldSpeed = 60;
OptionList<float, float> uiScales; OptionList<float, float> uiScales;
@ -50,6 +52,10 @@ namespace displaymenu {
int fftSizeId = 0; int fftSizeId = 0;
void updateFFTHoldSpeed() {
gui::waterfall.setFFTHoldSpeed(fftHoldSpeed / (fftRate * 10.0f));
}
void init() { void init() {
showWaterfall = core::configManager.conf["showWaterfall"]; showWaterfall = core::configManager.conf["showWaterfall"];
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall(); showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
@ -93,6 +99,11 @@ namespace displaymenu {
gui::menu.locked = core::configManager.conf["lockMenuOrder"]; gui::menu.locked = core::configManager.conf["lockMenuOrder"];
fftHold = core::configManager.conf["fftHold"];
fftHoldSpeed = core::configManager.conf["fftHoldSpeed"];
gui::waterfall.setFFTHold(fftHold);
updateFFTHoldSpeed();
// Define and load UI scales // Define and load UI scales
uiScales.define(1.0f, "100%", 1.0f); uiScales.define(1.0f, "100%", 1.0f);
uiScales.define(2.0f, "200%", 2.0f); uiScales.define(2.0f, "200%", 2.0f);
@ -132,6 +143,22 @@ namespace displaymenu {
core::configManager.release(true); core::configManager.release(true);
} }
if (ImGui::Checkbox("FFT Hold##_sdrpp", &fftHold)) {
gui::waterfall.setFFTHold(fftHold);
core::configManager.acquire();
core::configManager.conf["fftHold"] = fftHold;
core::configManager.release(true);
}
ImGui::LeftLabel("FFT Hold Speed");
ImGui::FillWidth();
if (ImGui::InputInt("##sdrpp_fft_hold_speed", &fftHoldSpeed)) {
updateFFTHoldSpeed();
core::configManager.acquire();
core::configManager.conf["fftHoldSpeed"] = fftHoldSpeed;
core::configManager.release(true);
}
ImGui::LeftLabel("High-DPI Scaling"); ImGui::LeftLabel("High-DPI Scaling");
ImGui::FillWidth(); ImGui::FillWidth();
if (ImGui::Combo("##sdrpp_ui_scale", &uiScaleId, uiScales.txt)) { if (ImGui::Combo("##sdrpp_ui_scale", &uiScaleId, uiScales.txt)) {
@ -146,6 +173,7 @@ namespace displaymenu {
if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) { if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) {
fftRate = std::max<int>(1, fftRate); fftRate = std::max<int>(1, fftRate);
sigpath::signalPath.setFFTRate(fftRate); sigpath::signalPath.setFFTRate(fftRate);
updateFFTHoldSpeed();
core::configManager.acquire(); core::configManager.acquire();
core::configManager.conf["fftRate"] = fftRate; core::configManager.conf["fftRate"] = fftRate;
core::configManager.release(true); core::configManager.release(true);

View File

@ -84,7 +84,7 @@ bool ThemeManager::loadTheme(std::string path) {
if (param == "name" || param == "author") { continue; } if (param == "name" || param == "author") { continue; }
// Exception for non-imgu colors // Exception for non-imgu colors
if (param == "WaterfallBackground" || param == "ClearColor") { if (param == "WaterfallBackground" || param == "ClearColor" || param == "FFTHoldColor") {
if (val[0] != '#' || !std::all_of(val.begin() + 1, val.end(), ::isxdigit) || val.length() != 9) { if (val[0] != '#' || !std::all_of(val.begin() + 1, val.end(), ::isxdigit) || val.length() != 9) {
spdlog::error("Theme {0} contains invalid {1} field. Expected hex RGBA color", path, param); spdlog::error("Theme {0} contains invalid {1} field. Expected hex RGBA color", path, param);
return false; return false;
@ -152,6 +152,12 @@ bool ThemeManager::applyTheme(std::string name) {
continue; continue;
} }
if (param == "FFTHoldColor") {
decodeRGBA(val, ret);
fftHoldColor = ImVec4((float)ret[0] / 255.0f, (float)ret[1] / 255.0f, (float)ret[2] / 255.0f, (float)ret[3] / 255.0f);
continue;
}
// If param is a color, check that it's a valid RGBA hex value // If param is a color, check that it's a valid RGBA hex value
if (IMGUI_COL_IDS.find(param) != IMGUI_COL_IDS.end()) { if (IMGUI_COL_IDS.find(param) != IMGUI_COL_IDS.end()) {
decodeRGBA(val, ret); decodeRGBA(val, ret);

View File

@ -21,7 +21,7 @@ public:
std::vector<std::string> getThemeNames(); std::vector<std::string> getThemeNames();
ImVec4 waterfallBg = ImVec4(0.0f, 0.0f, 0.0f, 1.0f); ImVec4 waterfallBg = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
; ImVec4 fftHoldColor = ImVec4(0.0f, 1.0f, 0.75f, 1.0f);
ImVec4 clearColor = ImVec4(0.0666f, 0.0666f, 0.0666f, 1.0f); ImVec4 clearColor = ImVec4(0.0666f, 0.0666f, 0.0666f, 1.0f);
private: private:

View File

@ -76,8 +76,8 @@ namespace ImGui {
lastWidgetPos.y = 0; lastWidgetPos.y = 0;
lastWidgetSize.x = 0; lastWidgetSize.x = 0;
lastWidgetSize.y = 0; lastWidgetSize.y = 0;
latestFFT = new float[1]; latestFFT = new float[dataWidth];
latestFFTHold = new float[1]; latestFFTHold = new float[dataWidth];
waterfallFb = new uint32_t[1]; waterfallFb = new uint32_t[1];
viewBandwidth = 1.0; viewBandwidth = 1.0;
@ -98,7 +98,7 @@ namespace ImGui {
char buf[100]; char buf[100];
ImU32 trace = ImGui::GetColorU32(ImGuiCol_PlotLines); ImU32 trace = ImGui::GetColorU32(ImGuiCol_PlotLines);
ImU32 traceHold = ImGui::ColorConvertFloat4ToU32(ImVec4(1.0, 1.0, 0.0, 1.0)); ImU32 traceHold = ImGui::ColorConvertFloat4ToU32(gui::themeManager.fftHoldColor);
ImU32 shadow = ImGui::GetColorU32(ImGuiCol_PlotLines, 0.2); ImU32 shadow = ImGui::GetColorU32(ImGuiCol_PlotLines, 0.2);
ImU32 text = ImGui::GetColorU32(ImGuiCol_Text); ImU32 text = ImGui::GetColorU32(ImGuiCol_Text);
float textVOffset = 10.0f * style::uiScale; float textVOffset = 10.0f * style::uiScale;
@ -888,7 +888,7 @@ namespace ImGui {
// If FFT hold is enabled, update it // If FFT hold is enabled, update it
if (fftHold && latestFFT != NULL && latestFFTHold != NULL && fftLines != 0) { if (fftHold && latestFFT != NULL && latestFFTHold != NULL && fftLines != 0) {
for (int i = 1; i < dataWidth; i++) { for (int i = 1; i < dataWidth; i++) {
latestFFTHold[i] = std::max<float>(latestFFT[i], latestFFTHold[i] - 0.3f); latestFFTHold[i] = std::max<float>(latestFFT[i], latestFFTHold[i] - fftHoldSpeed);
} }
} }
@ -1112,6 +1112,10 @@ namespace ImGui {
} }
} }
void WaterFall::setFFTHoldSpeed(float speed) {
fftHoldSpeed = speed;
}
void WaterfallVFO::setOffset(double offset) { void WaterfallVFO::setOffset(double offset) {
generalOffset = offset; generalOffset = offset;
if (reference == REF_CENTER) { if (reference == REF_CENTER) {

View File

@ -177,6 +177,7 @@ namespace ImGui {
void setBandPlanPos(int pos); void setBandPlanPos(int pos);
void setFFTHold(bool hold); void setFFTHold(bool hold);
void setFFTHoldSpeed(float speed);
bool centerFreqMoved = false; bool centerFreqMoved = false;
bool vfoFreqChanged = false; bool vfoFreqChanged = false;
@ -328,6 +329,7 @@ namespace ImGui {
int bandPlanPos = BANDPLAN_POS_BOTTOM; int bandPlanPos = BANDPLAN_POS_BOTTOM;
bool fftHold = false; bool fftHold = false;
float fftHoldSpeed = 0.3f;
// UI Select elements // UI Select elements
bool fftResizeSelect = false; bool fftResizeSelect = false;

View File

@ -9,6 +9,7 @@
"CheckMark": "#3D84E0FF", "CheckMark": "#3D84E0FF",
"ChildBg": "#FFFFFF00", "ChildBg": "#FFFFFF00",
"DragDropTarget": "#FFFF00E5", "DragDropTarget": "#FFFF00E5",
"FFTHoldColor": "#FFFF00FF",
"FrameBg": "#33353889", "FrameBg": "#33353889",
"FrameBgActive": "#33353889", "FrameBgActive": "#33353889",
"FrameBgHovered": "#33353889", "FrameBgHovered": "#33353889",

View File

@ -9,6 +9,7 @@
"CheckMark": "#3D84E0FF", "CheckMark": "#3D84E0FF",
"ChildBg": "#00000000", "ChildBg": "#00000000",
"DragDropTarget": "#0000FFE5", "DragDropTarget": "#0000FFE5",
"FFTHoldColor": "#C08000FF",
"FrameBg": "#ACA7A389", "FrameBg": "#ACA7A389",
"FrameBgActive": "#ACA7A389", "FrameBgActive": "#ACA7A389",
"FrameBgHovered": "#ACA7A389", "FrameBgHovered": "#ACA7A389",