mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-24 18:08:27 +01:00
new stuff idk
This commit is contained in:
parent
9e410e3856
commit
3541b8a0dd
@ -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_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_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_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_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_HACKRF_SOURCE "Build HackRF Source Module (Depedencies: libhackrf)" ON)
|
||||||
option(OPT_BUILD_AUDIO_SINK "Build Audio Sink Module (Depedencies: portaudio)" 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")
|
add_subdirectory("airspy_source")
|
||||||
endif (OPT_BUILD_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)
|
if (OPT_BUILD_PLUTOSDR_SOURCE)
|
||||||
add_subdirectory("plutosdr_source")
|
add_subdirectory("plutosdr_source")
|
||||||
endif (OPT_BUILD_PLUTOSDR_SOURCE)
|
endif (OPT_BUILD_PLUTOSDR_SOURCE)
|
||||||
|
@ -24,7 +24,8 @@ namespace sdrpp_credits {
|
|||||||
|
|
||||||
const char* patrons[] = {
|
const char* patrons[] = {
|
||||||
"SignalsEverywhere",
|
"SignalsEverywhere",
|
||||||
"Lee Donaghy"
|
"Lee Donaghy",
|
||||||
|
"Daniele D'Agnelli"
|
||||||
};
|
};
|
||||||
|
|
||||||
const int contributorCount = sizeof(contributors) / sizeof(char*);
|
const int contributorCount = sizeof(contributors) / sizeof(char*);
|
||||||
|
@ -186,12 +186,8 @@ namespace ImGui {
|
|||||||
|
|
||||||
if (IS_IN_AREA(mPos, wfMin, wfMax)) {
|
if (IS_IN_AREA(mPos, wfMin, wfMax)) {
|
||||||
for (auto const& [name, vfo] : vfos) {
|
for (auto const& [name, vfo] : vfos) {
|
||||||
ImVec2 nVfoRectMin(vfo->rectMin.x, wfMin.y);
|
window->DrawList->AddRectFilled(vfo->wfRectMin, vfo->wfRectMax, IM_COL32(255, 255, 255, 50));
|
||||||
ImVec2 nVfoRectMax(vfo->rectMax.x, wfMax.y);
|
window->DrawList->AddLine(vfo->wfLineMin, vfo->wfLineMax, (name == selectedVFO) ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,6 +197,10 @@ namespace ImGui {
|
|||||||
if (vfo->redrawRequired) {
|
if (vfo->redrawRequired) {
|
||||||
vfo->redrawRequired = false;
|
vfo->redrawRequired = false;
|
||||||
vfo->updateDrawingVars(viewBandwidth, dataWidth, viewOffset, widgetPos, fftHeight);
|
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);
|
vfo->draw(window, name == selectedVFO);
|
||||||
}
|
}
|
||||||
@ -247,9 +247,7 @@ namespace ImGui {
|
|||||||
if (name == selectedVFO) {
|
if (name == selectedVFO) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ImVec2 nVfoRectMin(_vfo->rectMin.x, wfMin.y);
|
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, _vfo->wfRectMin, _vfo->wfRectMax)) {
|
||||||
ImVec2 nVfoRectMax(_vfo->rectMax.x, wfMax.y);
|
|
||||||
if (IS_IN_AREA(mousePos, _vfo->rectMin, _vfo->rectMax) || IS_IN_AREA(mousePos, nVfoRectMin, nVfoRectMax)) {
|
|
||||||
selectedVFO = name;
|
selectedVFO = name;
|
||||||
selectedVFOChanged = true;
|
selectedVFOChanged = true;
|
||||||
return;
|
return;
|
||||||
@ -257,7 +255,7 @@ namespace ImGui {
|
|||||||
}
|
}
|
||||||
if (vfo != NULL) {
|
if (vfo != NULL) {
|
||||||
int refCenter = mousePos.x - (widgetPos.x + 50);
|
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;
|
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
|
||||||
off += centerFreq;
|
off += centerFreq;
|
||||||
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
|
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
|
||||||
@ -766,6 +764,10 @@ namespace ImGui {
|
|||||||
void WaterFall::updateAllVFOs() {
|
void WaterFall::updateAllVFOs() {
|
||||||
for (auto const& [name, vfo] : vfos) {
|
for (auto const& [name, vfo] : vfos) {
|
||||||
vfo->updateDrawingVars(viewBandwidth, dataWidth, viewOffset, widgetPos, fftHeight);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,10 @@ namespace ImGui {
|
|||||||
ImVec2 rectMax;
|
ImVec2 rectMax;
|
||||||
ImVec2 lineMin;
|
ImVec2 lineMin;
|
||||||
ImVec2 lineMax;
|
ImVec2 lineMax;
|
||||||
|
ImVec2 wfRectMin;
|
||||||
|
ImVec2 wfRectMax;
|
||||||
|
ImVec2 wfLineMin;
|
||||||
|
ImVec2 wfLineMax;
|
||||||
|
|
||||||
bool centerOffsetChanged = false;
|
bool centerOffsetChanged = false;
|
||||||
bool lowerOffsetChanged = false;
|
bool lowerOffsetChanged = false;
|
||||||
|
@ -221,6 +221,7 @@ I will soon publish a contributing.md listing the code style to use.
|
|||||||
## Patrons
|
## Patrons
|
||||||
* [SignalsEverywhere](https://signalseverywhere.com/)
|
* [SignalsEverywhere](https://signalseverywhere.com/)
|
||||||
* [Lee Donaghy](https://github.com/github)
|
* [Lee Donaghy](https://github.com/github)
|
||||||
|
* [Daniele D'Agnelli](https://linkedin.com/in/dagnelli)
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
* [aosync](https://github.com/aosync)
|
* [aosync](https://github.com/aosync)
|
||||||
|
31
sdrplay_source/CMakeLists.txt
Normal file
31
sdrplay_source/CMakeLists.txt
Normal file
@ -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)
|
190
sdrplay_source/src/main.cpp
Normal file
190
sdrplay_source/src/main.cpp
Normal file
@ -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();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user