pull/66/head
Ryzerth 2021-02-10 21:35:56 +01:00
rodzic 9e410e3856
commit 3541b8a0dd
7 zmienionych plików z 245 dodań i 11 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ option(OPT_BUILD_SPYSERVER_SOURCE "Build SpyServer Source Module (no dependencie
option(OPT_BUILD_SOAPY_SOURCE "Build SoapySDR Source Module (Depedencies: soapysdr)" ON)
option(OPT_BUILD_AIRSPYHF_SOURCE "Build Airspy HF+ Source Module (Depedencies: libairspyhf)" ON)
option(OPT_BUILD_AIRSPY_SOURCE "Build Airspy Source Module (Depedencies: libairspy)" ON)
option(OPT_BUILD_SDRPLAY_SOURCE "Build SDRplay Source Module (Depedencies: libsdrplay)" ON)
option(OPT_BUILD_PLUTOSDR_SOURCE "Build PlutoSDR Source Module (Depedencies: libiio, libad9361)" ON)
option(OPT_BUILD_HACKRF_SOURCE "Build HackRF Source Module (Depedencies: libhackrf)" ON)
option(OPT_BUILD_AUDIO_SINK "Build Audio Sink Module (Depedencies: portaudio)" ON)
@ -39,6 +40,10 @@ if (OPT_BUILD_AIRSPY_SOURCE)
add_subdirectory("airspy_source")
endif (OPT_BUILD_AIRSPY_SOURCE)
if (OPT_BUILD_SDRPLAY_SOURCE)
add_subdirectory("sdrplay_source")
endif (OPT_BUILD_SDRPLAY_SOURCE)
if (OPT_BUILD_PLUTOSDR_SOURCE)
add_subdirectory("plutosdr_source")
endif (OPT_BUILD_PLUTOSDR_SOURCE)

Wyświetl plik

@ -24,7 +24,8 @@ namespace sdrpp_credits {
const char* patrons[] = {
"SignalsEverywhere",
"Lee Donaghy"
"Lee Donaghy",
"Daniele D'Agnelli"
};
const int contributorCount = sizeof(contributors) / sizeof(char*);

Wyświetl plik

@ -186,12 +186,8 @@ namespace ImGui {
if (IS_IN_AREA(mPos, wfMin, wfMax)) {
for (auto const& [name, vfo] : vfos) {
ImVec2 nVfoRectMin(vfo->rectMin.x, wfMin.y);
ImVec2 nVfoRectMax(vfo->rectMax.x, wfMax.y);
ImVec2 nVfoLineMin(vfo->lineMin.x, wfMin.y);
ImVec2 nVfoLineMax(vfo->lineMin.x, wfMax.y);
window->DrawList->AddRectFilled(nVfoRectMin, nVfoRectMax, IM_COL32(255, 255, 255, 50));
window->DrawList->AddLine(nVfoLineMin, nVfoLineMax, (name == selectedVFO) ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255));
window->DrawList->AddRectFilled(vfo->wfRectMin, vfo->wfRectMax, IM_COL32(255, 255, 255, 50));
window->DrawList->AddLine(vfo->wfLineMin, vfo->wfLineMax, (name == selectedVFO) ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255));
}
}
}
@ -201,6 +197,10 @@ namespace ImGui {
if (vfo->redrawRequired) {
vfo->redrawRequired = false;
vfo->updateDrawingVars(viewBandwidth, dataWidth, viewOffset, widgetPos, fftHeight);
vfo->wfRectMin = ImVec2(vfo->rectMin.x, wfMin.y);
vfo->wfRectMax = ImVec2(vfo->rectMax.x, wfMax.y);
vfo->wfLineMin = ImVec2(vfo->lineMin.x, wfMin.y);
vfo->wfLineMax = ImVec2(vfo->lineMax.x, wfMax.y);
}
vfo->draw(window, name == selectedVFO);
}
@ -247,9 +247,7 @@ namespace ImGui {
if (name == selectedVFO) {
continue;
}
ImVec2 nVfoRectMin(_vfo->rectMin.x, wfMin.y);
ImVec2 nVfoRectMax(_vfo->rectMax.x, wfMax.y);
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, nVfoRectMin, nVfoRectMax)) {
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, _vfo->wfRectMin, _vfo->wfRectMax)) {
selectedVFO = name;
selectedVFOChanged = true;
return;
@ -257,7 +255,7 @@ namespace ImGui {
}
if (vfo != NULL) {
int refCenter = mousePos.x - (widgetPos.x + 50);
if (refCenter >= 0 && refCenter < dataWidth /* && ( (mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) || (IS_IN_AREA(mousePos, nVfoRectMin, nVfoRectMax)) ) */ ) {
if (refCenter >= 0 && refCenter < dataWidth) {
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
off += centerFreq;
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
@ -766,6 +764,10 @@ namespace ImGui {
void WaterFall::updateAllVFOs() {
for (auto const& [name, vfo] : vfos) {
vfo->updateDrawingVars(viewBandwidth, dataWidth, viewOffset, widgetPos, fftHeight);
vfo->wfRectMin = ImVec2(vfo->rectMin.x, wfMin.y);
vfo->wfRectMax = ImVec2(vfo->rectMax.x, wfMax.y);
vfo->wfLineMin = ImVec2(vfo->lineMin.x, wfMin.y);
vfo->wfLineMax = ImVec2(vfo->lineMax.x, wfMax.y);
}
}

Wyświetl plik

@ -38,6 +38,10 @@ namespace ImGui {
ImVec2 rectMax;
ImVec2 lineMin;
ImVec2 lineMax;
ImVec2 wfRectMin;
ImVec2 wfRectMax;
ImVec2 wfLineMin;
ImVec2 wfLineMax;
bool centerOffsetChanged = false;
bool lowerOffsetChanged = false;

Wyświetl plik

@ -221,6 +221,7 @@ I will soon publish a contributing.md listing the code style to use.
## Patrons
* [SignalsEverywhere](https://signalseverywhere.com/)
* [Lee Donaghy](https://github.com/github)
* [Daniele D'Agnelli](https://linkedin.com/in/dagnelli)
## Contributors
* [aosync](https://github.com/aosync)

Wyświetl plik

@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.13)
project(sdrplay_source)
if (MSVC)
set(CMAKE_CXX_FLAGS "-O2 /std:c++17 /EHsc")
else()
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpermissive")
endif (MSVC)
include_directories("src/")
file(GLOB SRC "src/*.cpp")
add_library(sdrplay_source SHARED ${SRC})
target_link_libraries(sdrplay_source PRIVATE sdrpp_core)
set_target_properties(sdrplay_source PROPERTIES PREFIX "")
if (MSVC)
# Lib path
target_link_directories(sdrpp_core PUBLIC "C:/Program Files/SDRplay/API/x64")
target_link_libraries(sdrplay_source PUBLIC sdrplay_api)
else (MSVC)
find_package(PkgConfig)
pkg_check_modules(LIBAIRSPYHF REQUIRED libairspy)
target_include_directories(sdrplay_source PUBLIC ${LIBAIRSPYHF_INCLUDE_DIRS})
target_link_directories(sdrplay_source PUBLIC ${LIBAIRSPYHF_LIBRARY_DIRS})
target_link_libraries(sdrplay_source PUBLIC ${LIBAIRSPYHF_LIBRARIES})
endif (MSVC)

Wyświetl plik

@ -0,0 +1,190 @@
#include <imgui.h>
#include <spdlog/spdlog.h>
#include <module.h>
#include <gui/gui.h>
#include <signal_path/signal_path.h>
#include <core.h>
#include <gui/style.h>
#include <config.h>
#include <options.h>
#include <libairspy/airspy.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str())
SDRPP_MOD_INFO {
/* Name: */ "sdrplay_source",
/* Description: */ "Airspy source module for SDR++",
/* Author: */ "Ryzerth",
/* Version: */ 0, 1, 0,
/* Max instances */ 1
};
ConfigManager config;
class SDRPlaySourceModule : public ModuleManager::Instance {
public:
SDRPlaySourceModule(std::string name) {
this->name = name;
sampleRate = 10000000.0;
handler.ctx = this;
handler.selectHandler = menuSelected;
handler.deselectHandler = menuDeselected;
handler.menuHandler = menuHandler;
handler.startHandler = start;
handler.stopHandler = stop;
handler.tuneHandler = tune;
handler.stream = &stream;
refresh();
if (sampleRateList.size() > 0) {
sampleRate = sampleRateList[0];
}
// Select device from config
// config.aquire();
// std::string devSerial = config.conf["device"];
// config.release();
// selectByString(devSerial);
// core::setInputSampleRate(sampleRate);
sigpath::sourceManager.registerSource("SDRplay", &handler);
}
~SDRPlaySourceModule() {
}
void enable() {
enabled = true;
}
void disable() {
enabled = false;
}
bool isEnabled() {
return enabled;
}
void refresh() {
devList.clear();
devListTxt = "";
// Fill in list here
}
private:
std::string getBandwdithScaled(double bw) {
char buf[1024];
if (bw >= 1000000.0) {
sprintf(buf, "%.1lfMHz", bw / 1000000.0);
}
else if (bw >= 1000.0) {
sprintf(buf, "%.1lfKHz", bw / 1000.0);
}
else {
sprintf(buf, "%.1lfHz", bw);
}
return std::string(buf);
}
static void menuSelected(void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
core::setInputSampleRate(_this->sampleRate);
spdlog::info("SDRPlaySourceModule '{0}': Menu Select!", _this->name);
}
static void menuDeselected(void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
spdlog::info("SDRPlaySourceModule '{0}': Menu Deselect!", _this->name);
}
static void start(void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
if (_this->running) {
return;
}
// Do start procedure here
_this->running = true;
spdlog::info("SDRPlaySourceModule '{0}': Start!", _this->name);
}
static void stop(void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
if (!_this->running) {
return;
}
_this->running = false;
_this->stream.stopWriter();
// Stop procedure here
_this->stream.clearWriteStop();
spdlog::info("SDRPlaySourceModule '{0}': Stop!", _this->name);
}
static void tune(double freq, void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
if (_this->running) {
// Tune here
}
_this->freq = freq;
spdlog::info("SDRPlaySourceModule '{0}': Tune: {1}!", _this->name, freq);
}
static void menuHandler(void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
float menuWidth = ImGui::GetContentRegionAvailWidth();
if (_this->running) { style::beginDisabled(); }
ImGui::SetNextItemWidth(menuWidth);
// Menu here
}
std::string name;
bool enabled = true;
dsp::stream<dsp::complex_t> stream;
double sampleRate;
SourceManager::SourceHandler handler;
bool running = false;
double freq;
int devId = 0;
int srId = 0;
std::vector<uint64_t> devList;
std::string devListTxt;
std::vector<uint32_t> sampleRateList;
std::string sampleRateListTxt;
};
MOD_EXPORT void _INIT_() {
json def = json({});
def["devices"] = json({});
def["device"] = "";
config.setPath(options::opts.root + "/sdrplay_config.json");
config.load(def);
config.enableAutoSave();
}
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
return new SDRPlaySourceModule(name);
}
MOD_EXPORT void _DELETE_INSTANCE_(ModuleManager::Instance* instance) {
delete (SDRPlaySourceModule*)instance;
}
MOD_EXPORT void _END_() {
config.disableAutoSave();
config.save();
}