mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 04:17:50 +02:00
Fixed FIR bug with the pluto module
This commit is contained in:
@ -21,6 +21,7 @@ if (MSVC)
|
||||
target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/")
|
||||
|
||||
target_link_libraries(plutosdr_source PUBLIC libiio)
|
||||
target_link_libraries(plutosdr_source PUBLIC libad9361)
|
||||
else (MSVC)
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <core.h>
|
||||
#include <gui/style.h>
|
||||
#include <iio.h>
|
||||
#include <ad9361.h>
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
@ -84,11 +85,16 @@ private:
|
||||
}
|
||||
|
||||
// Configure pluto
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", _this->freq); // Freq
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "sampling_frequency", _this->sampleRate); // Sample rate
|
||||
iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "gain_control_mode", "manual"); // manual gain
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "hardwaregain", _this->gain); // gain
|
||||
iio_channel_attr_write_bool(iio_device_find_channel(_this->phy, "altvoltage1", true), "powerdown", true);
|
||||
iio_channel_attr_write_bool(iio_device_find_channel(_this->phy, "altvoltage0", true), "powerdown", false);
|
||||
|
||||
iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "rf_port_select", "A_BALANCED");
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", round(_this->freq)); // Freq
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "sampling_frequency", round(_this->sampleRate)); // Sample rate
|
||||
iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "gain_control_mode", gainModes[_this->gainMode]); // manual gain
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "hardwaregain", round(_this->gain)); // gain
|
||||
ad9361_set_bb_rate(_this->phy, round(_this->sampleRate));
|
||||
|
||||
_this->running = true;
|
||||
_this->workerThread = std::thread(worker, _this);
|
||||
spdlog::info("PlutoSDRSourceModule '{0}': Start!", _this->name);
|
||||
@ -115,11 +121,11 @@ private:
|
||||
|
||||
static void tune(double freq, void* ctx) {
|
||||
PlutoSDRSourceModule* _this = (PlutoSDRSourceModule*)ctx;
|
||||
_this->freq = freq;
|
||||
if (_this->running) {
|
||||
// SET PLUTO FREQ HERE
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", _this->freq);
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", round(_this->freq));
|
||||
}
|
||||
_this->freq = freq;
|
||||
spdlog::info("PlutoSDRSourceModule '{0}': Tune: {1}!", _this->name, freq);
|
||||
}
|
||||
|
||||
@ -130,25 +136,37 @@ private:
|
||||
ImGui::Text("IP");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
ImGui::InputText("", &_this->ip[3], 16);
|
||||
ImGui::InputText(CONCAT("##_pluto_ip_", _this->name), &_this->ip[3], 16);
|
||||
|
||||
// SELECT PLUTO HERE
|
||||
ImGui::Text("Samplerate");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (_this->running) { style::beginDisabled(); }
|
||||
if (ImGui::InputFloat(CONCAT("##_samplerate_select_", _this->name), &_this->sampleRate, 1, 1000, 0)) {
|
||||
core::setInputSampleRate(_this->sampleRate);
|
||||
}
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
|
||||
ImGui::Text("Gain Mode");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("", &_this->gainMode, gainModesTxt)) {
|
||||
|
||||
if (ImGui::Combo(CONCAT("##_gainmode_select_", _this->name), &_this->gainMode, gainModesTxt)) {
|
||||
if (_this->running) {
|
||||
iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "gain_control_mode", gainModes[_this->gainMode]);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("PGA Gain");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (_this->gainMode) { style::beginDisabled(); }
|
||||
if (ImGui::SliderFloat(CONCAT("##_gain_select_", _this->name), &_this->gain, 0, 76)) {
|
||||
if (_this->running) {
|
||||
// SET PLUTO GAIN HERE
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false),"hardwaregain", _this->gain);
|
||||
iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false),"hardwaregain", round(_this->gain));
|
||||
}
|
||||
}
|
||||
if (_this->gainMode) { style::endDisabled(); }
|
||||
}
|
||||
|
||||
static void worker(void* ctx) {
|
||||
@ -190,13 +208,14 @@ private:
|
||||
|
||||
std::string name;
|
||||
dsp::stream<dsp::complex_t> stream;
|
||||
double sampleRate;
|
||||
float sampleRate;
|
||||
SourceManager::SourceHandler handler;
|
||||
std::thread workerThread;
|
||||
struct iio_context *ctx = NULL;
|
||||
struct iio_device *phy = NULL;
|
||||
struct iio_device *dev = NULL;
|
||||
bool running = false;
|
||||
bool ipMode = true;
|
||||
double freq;
|
||||
char ip[1024] = "ip:192.168.2.1";
|
||||
int port = 1234;
|
||||
|
Reference in New Issue
Block a user