2025-04-12 09:07:02 +02:00
|
|
|
#include "cyclo_test.h"
|
|
|
|
|
#include "common/dsp/filter/firdes.h"
|
2025-04-15 19:06:12 +01:00
|
|
|
#include "common/widgets/stepped_slider.h"
|
|
|
|
|
#include "dsp/device/options_displayer_warper.h"
|
|
|
|
|
#include "imgui/imgui.h"
|
|
|
|
|
#include <memory>
|
2025-04-12 09:07:02 +02:00
|
|
|
|
|
|
|
|
namespace satdump
|
|
|
|
|
{
|
2025-05-19 22:26:32 +02:00
|
|
|
namespace handlers
|
2025-04-12 09:07:02 +02:00
|
|
|
{
|
|
|
|
|
CycloHelperHandler::CycloHelperHandler()
|
|
|
|
|
{
|
|
|
|
|
file_source = std::make_shared<ndsp::FileSourceBlock>();
|
|
|
|
|
splitter = std::make_shared<ndsp::SplitterBlock<complex_t>>();
|
|
|
|
|
fft = std::make_shared<ndsp::FFTPanBlock>();
|
|
|
|
|
agc = std::make_shared<ndsp::AGCBlock<complex_t>>();
|
2025-04-15 19:06:12 +01:00
|
|
|
rrc = std::make_shared<ndsp::RRC_FIRBlock<complex_t>>();
|
2025-04-12 09:07:02 +02:00
|
|
|
splitter2 = std::make_shared<ndsp::SplitterBlock<complex_t>>();
|
|
|
|
|
fft2 = std::make_shared<ndsp::FFTPanBlock>();
|
|
|
|
|
costas = std::make_shared<ndsp::CostasBlock>();
|
|
|
|
|
recovery = std::make_shared<ndsp::MMClockRecoveryBlock<complex_t>>();
|
|
|
|
|
constell = std::make_shared<ndsp::ConstellationDisplayBlock>();
|
|
|
|
|
|
|
|
|
|
splitter->set_cfg("noutputs", 2);
|
|
|
|
|
splitter2->set_cfg("noutputs", 2);
|
|
|
|
|
|
|
|
|
|
splitter->link(file_source.get(), 0, 0, 4);
|
|
|
|
|
fft->link(splitter.get(), 0, 0, 4);
|
|
|
|
|
|
|
|
|
|
agc->link(splitter.get(), 1, 0, 4);
|
|
|
|
|
rrc->link(agc.get(), 0, 0, 4);
|
|
|
|
|
splitter2->link(rrc.get(), 0, 0, 4);
|
|
|
|
|
fft2->link(splitter2.get(), 0, 0, 4);
|
|
|
|
|
costas->link(splitter2.get(), 1, 0, 4);
|
|
|
|
|
recovery->link(costas.get(), 0, 0, 4);
|
|
|
|
|
constell->link(recovery.get(), 0, 0, 4);
|
|
|
|
|
|
2025-04-15 19:06:12 +01:00
|
|
|
file_source->set_cfg("file", "/home/alan/Pictures/MetOpB.wav");
|
2025-04-12 09:07:02 +02:00
|
|
|
file_source->set_cfg("type", "cs16");
|
|
|
|
|
fft->set_fft_settings(8192, 6e6, 30);
|
|
|
|
|
fft_plot = std::make_shared<widgets::FFTPlot>(fft->output_fft_buff, 8192, -200, 0);
|
|
|
|
|
|
|
|
|
|
fft2->set_fft_settings(8192, 6e6, 30);
|
|
|
|
|
fft_plot2 = std::make_shared<widgets::FFTPlot>(fft2->output_fft_buff, 8192, -200, 0);
|
|
|
|
|
|
2025-04-15 19:06:12 +01:00
|
|
|
agc_optdisp = std::make_unique<ndsp::OptDisplayerWarper>(agc);
|
|
|
|
|
rrc_optdisp = std::make_unique<ndsp::OptDisplayerWarper>(rrc);
|
|
|
|
|
|
2025-04-12 09:07:02 +02:00
|
|
|
// mod_type = MOD_QPSK;
|
|
|
|
|
applyParams();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-15 19:06:12 +01:00
|
|
|
CycloHelperHandler::~CycloHelperHandler() {}
|
2025-04-12 09:07:02 +02:00
|
|
|
|
|
|
|
|
void CycloHelperHandler::applyParams()
|
|
|
|
|
{
|
|
|
|
|
uint64_t samprate = samplerate.get();
|
|
|
|
|
uint64_t symrate = symbolrate.get();
|
|
|
|
|
|
|
|
|
|
if (mod_type == MOD_BPSK)
|
|
|
|
|
costas->set_cfg("order", 2);
|
|
|
|
|
else if (mod_type == MOD_QPSK)
|
|
|
|
|
costas->set_cfg("order", 4);
|
|
|
|
|
|
2025-04-15 19:06:12 +01:00
|
|
|
rrc->set_cfg("samplerate", samprate);
|
|
|
|
|
rrc->set_cfg("symbolrate", symrate);
|
2025-04-12 09:07:02 +02:00
|
|
|
|
|
|
|
|
recovery->set_cfg("omega", double(samprate) / double(symrate));
|
2025-04-15 19:06:12 +01:00
|
|
|
|
|
|
|
|
agc_optdisp->update();
|
|
|
|
|
rrc_optdisp->update();
|
2025-04-12 09:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CycloHelperHandler::drawMenu()
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::CollapsingHeader("Demodulator", ImGuiTreeNodeFlags_DefaultOpen))
|
|
|
|
|
{
|
2025-04-15 19:06:12 +01:00
|
|
|
bool upd = false;
|
|
|
|
|
|
|
|
|
|
upd |= samplerate.draw();
|
|
|
|
|
upd |= symbolrate.draw();
|
2025-04-12 09:07:02 +02:00
|
|
|
|
|
|
|
|
if (ImGui::RadioButton("BPSK", mod_type == MOD_BPSK))
|
2025-04-15 19:06:12 +01:00
|
|
|
{
|
2025-04-12 09:07:02 +02:00
|
|
|
mod_type = MOD_BPSK;
|
2025-04-15 19:06:12 +01:00
|
|
|
upd = true;
|
|
|
|
|
}
|
2025-04-12 09:07:02 +02:00
|
|
|
ImGui::SameLine();
|
|
|
|
|
if (ImGui::RadioButton("QPSK", mod_type == MOD_QPSK))
|
2025-04-15 19:06:12 +01:00
|
|
|
{
|
2025-04-12 09:07:02 +02:00
|
|
|
mod_type = MOD_QPSK;
|
2025-04-15 19:06:12 +01:00
|
|
|
upd = true;
|
|
|
|
|
}
|
2025-04-12 09:07:02 +02:00
|
|
|
|
2025-04-15 19:06:12 +01:00
|
|
|
// if (ImGui::Button("Set"))
|
|
|
|
|
if (upd)
|
2025-04-12 09:07:02 +02:00
|
|
|
applyParams();
|
|
|
|
|
|
2025-04-15 19:06:12 +01:00
|
|
|
if (!started)
|
2025-04-12 09:07:02 +02:00
|
|
|
{
|
2025-04-15 19:06:12 +01:00
|
|
|
if (ImGui::Button("Start"))
|
|
|
|
|
{
|
|
|
|
|
started = true;
|
|
|
|
|
|
|
|
|
|
file_source->start();
|
|
|
|
|
splitter->start();
|
|
|
|
|
fft->start();
|
|
|
|
|
agc->start();
|
|
|
|
|
rrc->start();
|
|
|
|
|
splitter2->start();
|
|
|
|
|
fft2->start();
|
|
|
|
|
costas->start();
|
|
|
|
|
recovery->start();
|
|
|
|
|
constell->start();
|
|
|
|
|
|
|
|
|
|
agc_optdisp->update();
|
|
|
|
|
rrc_optdisp->update();
|
|
|
|
|
}
|
2025-04-12 09:07:02 +02:00
|
|
|
}
|
2025-04-15 19:06:12 +01:00
|
|
|
else
|
2025-04-12 09:07:02 +02:00
|
|
|
{
|
2025-04-15 19:06:12 +01:00
|
|
|
if (ImGui::Button("Stop"))
|
|
|
|
|
{
|
|
|
|
|
started = false;
|
|
|
|
|
|
|
|
|
|
file_source->stop(true);
|
|
|
|
|
|
|
|
|
|
file_source->stop();
|
|
|
|
|
splitter->stop();
|
|
|
|
|
fft->stop();
|
|
|
|
|
agc->stop();
|
|
|
|
|
rrc->stop();
|
|
|
|
|
splitter2->stop();
|
|
|
|
|
fft2->stop();
|
|
|
|
|
costas->stop();
|
|
|
|
|
recovery->stop();
|
|
|
|
|
constell->stop();
|
|
|
|
|
|
|
|
|
|
agc_optdisp->update();
|
|
|
|
|
rrc_optdisp->update();
|
|
|
|
|
}
|
2025-04-12 09:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::Separator();
|
2025-04-15 19:06:12 +01:00
|
|
|
agc_optdisp->draw();
|
|
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
rrc_optdisp->draw();
|
2025-04-12 09:07:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CycloHelperHandler::drawContents(ImVec2 win_size)
|
|
|
|
|
{
|
|
|
|
|
fft_plot->draw({400, 400});
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
fft_plot2->draw({400, 400});
|
|
|
|
|
|
|
|
|
|
constell->constel.draw();
|
|
|
|
|
}
|
2025-05-19 22:26:32 +02:00
|
|
|
} // namespace handlers
|
2025-04-15 19:06:12 +01:00
|
|
|
} // namespace satdump
|