Skip to content

Commit

Permalink
Merge branch 'AlexandreRouma:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kostecky authored Apr 1, 2022
2 parents 1bdf888 + 8dbae4e commit eeaa50b
Show file tree
Hide file tree
Showing 21 changed files with 429 additions and 20 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {

externalNativeBuild {
cmake {
arguments "-DOPT_BACKEND_GLFW=OFF", "-DOPT_BACKEND_ANDROID=ON", "-DOPT_BUILD_SOAPY_SOURCE=OFF", "-DOPT_BUILD_ANDROID_AUDIO_SINK=ON", "-DOPT_BUILD_AUDIO_SINK=OFF", "-DOPT_BUILD_DISCORD_PRESENCE=OFF", "-DUSE_INTERNAL_LIBCORRECT=OFF"
arguments "-DOPT_BACKEND_GLFW=OFF", "-DOPT_BACKEND_ANDROID=ON", "-DOPT_BUILD_SOAPY_SOURCE=OFF", "-DOPT_BUILD_ANDROID_AUDIO_SINK=ON", "-DOPT_BUILD_AUDIO_SINK=OFF", "-DOPT_BUILD_DISCORD_PRESENCE=OFF", "-DOPT_BUILD_M17_DECODER=ON"
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions core/libcorrect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ if(COMPILER_SUPPORTS_WPEDANTIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")
# On android, keep optimisations and don't use asan
if (ANDROID)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O3")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")
endif()
else()
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
Expand Down
10 changes: 10 additions & 0 deletions core/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ int sdrpp_main(int argc, char* argv[]) {
defConfig["bandPlanPos"] = 0;
defConfig["centerTuning"] = false;
defConfig["colorMap"] = "Classic";
defConfig["fftHold"] = false;
defConfig["fftHoldSpeed"] = 60;
defConfig["fastFFT"] = false;
defConfig["fftHeight"] = 300;
defConfig["fftRate"] = 20;
Expand Down Expand Up @@ -221,6 +223,12 @@ int sdrpp_main(int argc, char* argv[]) {

defConfig["vfoColors"]["Radio"] = "#FFFFFF";

#ifdef __ANDROID__
defConfig["lockMenuOrder"] = true;
#else
defConfig["lockMenuOrder"] = false;
#endif

#if defined(_WIN32)
defConfig["modulesDirectory"] = "./modules";
defConfig["resourcesDirectory"] = "./res";
Expand Down Expand Up @@ -260,6 +268,8 @@ int sdrpp_main(int argc, char* argv[]) {
core::configManager.conf["modules"][modCount++] = "network_sink.so";
core::configManager.conf["modules"][modCount++] = "audio_sink.so";

core::configManager.conf["modules"][modCount++] = "m17_decoder.so";
core::configManager.conf["modules"][modCount++] = "meteor_demodulator.so";
core::configManager.conf["modules"][modCount++] = "radio.so";

core::configManager.conf["modules"][modCount++] = "frequency_manager.so";
Expand Down
1 change: 0 additions & 1 deletion core/src/core.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include <config.h>
#include <module.h>
#include <module.h>
#include <module_com.h>
#include "command_args.h"

Expand Down
1 change: 1 addition & 0 deletions core/src/gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ void MainWindow::draw() {
}

ImGui::Checkbox("WF Single Click", &gui::waterfall.VFOMoveSingleClick);
ImGui::Checkbox("Lock Menu Order", &gui::menu.locked);

ImGui::Spacing();
}
Expand Down
36 changes: 36 additions & 0 deletions core/src/gui/menus/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace displaymenu {
int fftRate = 20;
int uiScaleId = 0;
bool restartRequired = false;
bool fftHold = false;
int fftHoldSpeed = 60;

OptionList<float, float> uiScales;

Expand Down Expand Up @@ -50,6 +52,10 @@ namespace displaymenu {

int fftSizeId = 0;

void updateFFTHoldSpeed() {
gui::waterfall.setFFTHoldSpeed(fftHoldSpeed / (fftRate * 10.0f));
}

void init() {
showWaterfall = core::configManager.conf["showWaterfall"];
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
Expand Down Expand Up @@ -91,6 +97,13 @@ namespace displaymenu {
selectedWindow = std::clamp<int>((int)core::configManager.conf["fftWindow"], 0, _FFT_WINDOW_COUNT - 1);
gui::mainWindow.setFFTWindow(selectedWindow);

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
uiScales.define(1.0f, "100%", 1.0f);
uiScales.define(2.0f, "200%", 2.0f);
Expand Down Expand Up @@ -124,6 +137,28 @@ namespace displaymenu {
core::configManager.release(true);
}

if (ImGui::Checkbox("Lock Menu Order##_sdrpp", &gui::menu.locked)) {
core::configManager.acquire();
core::configManager.conf["lockMenuOrder"] = gui::menu.locked;
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::FillWidth();
if (ImGui::Combo("##sdrpp_ui_scale", &uiScaleId, uiScales.txt)) {
Expand All @@ -138,6 +173,7 @@ namespace displaymenu {
if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) {
fftRate = std::max<int>(1, fftRate);
sigpath::signalPath.setFFTRate(fftRate);
updateFFTHoldSpeed();
core::configManager.acquire();
core::configManager.conf["fftRate"] = fftRate;
core::configManager.release(true);
Expand Down
8 changes: 7 additions & 1 deletion core/src/gui/theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool ThemeManager::loadTheme(std::string path) {
if (param == "name" || param == "author") { continue; }

// 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) {
spdlog::error("Theme {0} contains invalid {1} field. Expected hex RGBA color", path, param);
return false;
Expand Down Expand Up @@ -152,6 +152,12 @@ bool ThemeManager::applyTheme(std::string name) {
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 (IMGUI_COL_IDS.find(param) != IMGUI_COL_IDS.end()) {
decodeRGBA(val, ret);
Expand Down
2 changes: 1 addition & 1 deletion core/src/gui/theme_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ThemeManager {
std::vector<std::string> getThemeNames();

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);

private:
Expand Down
6 changes: 5 additions & 1 deletion core/src/gui/widgets/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ bool Menu::draw(bool updateStates) {
clickedMenuName = opt.name;
}

if (menuClicked && ImGui::IsMouseDragging(ImGuiMouseButton_Left) && draggedMenuName.empty() && clickedMenuName == opt.name) {
bool menuDragged = (menuClicked && ImGui::IsMouseDragging(ImGuiMouseButton_Left) && draggedMenuName.empty() && clickedMenuName == opt.name);
if (menuDragged && !locked) {
draggedMenuName = opt.name;
draggedId = rawId - 1;
draggedOpt = opt;
continue;
}
else if (menuDragged) {
ImGui::SetTooltip("Menu Order Locked!");
}

// Draw menu header and menu content. There is a lot of boilerplate because the checkbox has to be drawn before the menu, TODO: fix
if (updateStates) { ImGui::SetNextItemOpen(opt.open); }
Expand Down
3 changes: 3 additions & 0 deletions core/src/gui/widgets/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ class Menu {

std::vector<MenuOption_t> order;

bool locked = false;

private:
bool isInOrderList(std::string name);


bool menuClicked = false;
std::string clickedMenuName = "";
std::string draggedMenuName = "";
Expand Down
44 changes: 43 additions & 1 deletion core/src/gui/widgets/waterfall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ namespace ImGui {
lastWidgetPos.y = 0;
lastWidgetSize.x = 0;
lastWidgetSize.y = 0;
latestFFT = new float[1];
latestFFT = new float[dataWidth];
latestFFTHold = new float[dataWidth];
waterfallFb = new uint32_t[1];

viewBandwidth = 1.0;
Expand All @@ -97,6 +98,7 @@ namespace ImGui {
char buf[100];

ImU32 trace = ImGui::GetColorU32(ImGuiCol_PlotLines);
ImU32 traceHold = ImGui::ColorConvertFloat4ToU32(gui::themeManager.fftHoldColor);
ImU32 shadow = ImGui::GetColorU32(ImGuiCol_PlotLines, 0.2);
ImU32 text = ImGui::GetColorU32(ImGuiCol_Text);
float textVOffset = 10.0f * style::uiScale;
Expand Down Expand Up @@ -143,6 +145,18 @@ namespace ImGui {
}
}

// Hold
if (fftHold && latestFFT != NULL && latestFFTHold != NULL && fftLines != 0) {
for (int i = 1; i < dataWidth; i++) {
double aPos = fftAreaMax.y - ((latestFFTHold[i - 1] - fftMin) * scaleFactor);
double bPos = fftAreaMax.y - ((latestFFTHold[i] - fftMin) * scaleFactor);
aPos = std::clamp<double>(aPos, fftAreaMin.y + 1, fftAreaMax.y);
bPos = std::clamp<double>(bPos, fftAreaMin.y + 1, fftAreaMax.y);
window->DrawList->AddLine(ImVec2(fftAreaMin.x + i - 1, roundf(aPos)),
ImVec2(fftAreaMin.x + i, roundf(bPos)), traceHold, 1.0);
}
}

FFTRedrawArgs args;
args.min = fftAreaMin;
args.max = fftAreaMax;
Expand Down Expand Up @@ -712,18 +726,26 @@ namespace ImGui {
// ==============
}

// Reallocate display FFT
if (latestFFT != NULL) {
delete[] latestFFT;
}
latestFFT = new float[dataWidth];

// Reallocate hold FFT
if (latestFFTHold != NULL) {
delete[] latestFFTHold;
}
latestFFTHold = new float[dataWidth];

if (waterfallVisible) {
delete[] waterfallFb;
waterfallFb = new uint32_t[dataWidth * waterfallHeight];
memset(waterfallFb, 0, dataWidth * waterfallHeight * sizeof(uint32_t));
}
for (int i = 0; i < dataWidth; i++) {
latestFFT[i] = -1000.0; // Hide everything
latestFFTHold[i] = -1000.0;
}

fftAreaMin = ImVec2(widgetPos.x + (50.0f * style::uiScale), widgetPos.y + (9.0f * style::uiScale));
Expand Down Expand Up @@ -863,6 +885,13 @@ namespace ImGui {
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, selectedVFOSNR);
}

// If FFT hold is enabled, update it
if (fftHold && latestFFT != NULL && latestFFTHold != NULL && fftLines != 0) {
for (int i = 1; i < dataWidth; i++) {
latestFFTHold[i] = std::max<float>(latestFFT[i], latestFFTHold[i] - fftHoldSpeed);
}
}

buf_mtx.unlock();
}

Expand Down Expand Up @@ -1074,6 +1103,19 @@ namespace ImGui {
bandPlanPos = pos;
}

void WaterFall::setFFTHold(bool hold) {
fftHold = hold;
if (fftHold && latestFFTHold) {
for (int i = 0; i < dataWidth; i++) {
latestFFTHold[i] = -1000.0;
}
}
}

void WaterFall::setFFTHoldSpeed(float speed) {
fftHoldSpeed = speed;
}

void WaterfallVFO::setOffset(double offset) {
generalOffset = offset;
if (reference == REF_CENTER) {
Expand Down
7 changes: 7 additions & 0 deletions core/src/gui/widgets/waterfall.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ namespace ImGui {

void setBandPlanPos(int pos);

void setFFTHold(bool hold);
void setFFTHoldSpeed(float speed);

bool centerFreqMoved = false;
bool vfoFreqChanged = false;
bool bandplanEnabled = false;
Expand Down Expand Up @@ -307,6 +310,7 @@ namespace ImGui {
int rawFFTSize;
float* rawFFTs = NULL;
float* latestFFT;
float* latestFFTHold;
int currentFFTLine = 0;
int fftLines = 0;

Expand All @@ -324,6 +328,9 @@ namespace ImGui {

int bandPlanPos = BANDPLAN_POS_BOTTOM;

bool fftHold = false;
float fftHoldSpeed = 0.3f;

// UI Select elements
bool fftResizeSelect = false;
bool freqScaleSelect = false;
Expand Down
12 changes: 10 additions & 2 deletions decoder_modules/m17_decoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ if (MSVC)
target_link_directories(m17_decoder PRIVATE "C:/Program Files/codec2/lib")

target_link_libraries(m17_decoder PRIVATE libcodec2)

else (MSVC)
elseif (ANDROID)
target_include_directories(m17_decoder PUBLIC
/mnt/android_sdr/codec2/src
/mnt/android_sdr/output/codec2/${ANDROID_ABI}/
)

target_link_libraries(m17_decoder PUBLIC
/mnt/android_sdr/output/codec2/${ANDROID_ABI}/libcodec2.so
)
else ()
find_package(PkgConfig)

pkg_check_modules(LIBCODEC2 REQUIRED codec2)
Expand Down
Loading

0 comments on commit eeaa50b

Please sign in to comment.