diff --git a/decoder_modules/pager_decoder/src/flex/decoder.h b/decoder_modules/pager_decoder/src/flex/decoder.h new file mode 100644 index 00000000..6f54e264 --- /dev/null +++ b/decoder_modules/pager_decoder/src/flex/decoder.h @@ -0,0 +1,96 @@ +#pragma once +#include "../decoder.h" +#include +#include +#include +#include +#include +#include "flex.h" + +class FLEXDecoder : public Decoder { + dsp::stream dummy1; + dsp::stream dummy2; +public: + FLEXDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, 1600) { + this->name = name; + this->vfo = vfo; + + // Define baudrate options + baudrates.define(1600, "1600 Baud", 1600); + baudrates.define(3200, "3200 Baud", 3200); + baudrates.define(6400, "6400 Baud", 6400); + + // Init DSP + vfo->setBandwidthLimits(12500, 12500, true); + vfo->setSampleRate(16000, 12500); + reshape.init(&dummy1, 1600.0, (1600 / 30.0) - 1600.0); + dataHandler.init(&dummy2, _dataHandler, this); + diagHandler.init(&reshape.out, _diagHandler, this); + } + + ~FLEXDecoder() { + stop(); + } + + void showMenu() { + ImGui::LeftLabel("Baudrate"); + ImGui::FillWidth(); + if (ImGui::Combo(("##pager_decoder_flex_br_" + name).c_str(), &brId, baudrates.txt)) { + // TODO + } + + ImGui::FillWidth(); + diag.draw(); + } + + void setVFO(VFOManager::VFO* vfo) { + this->vfo = vfo; + vfo->setBandwidthLimits(12500, 12500, true); + vfo->setSampleRate(24000, 12500); + // dsp.setInput(vfo->output); + } + + void start() { + flog::debug("FLEX start"); + // dsp.start(); + reshape.start(); + dataHandler.start(); + diagHandler.start(); + } + + void stop() { + flog::debug("FLEX stop"); + // dsp.stop(); + reshape.stop(); + dataHandler.stop(); + diagHandler.stop(); + } + +private: + static void _dataHandler(uint8_t* data, int count, void* ctx) { + FLEXDecoder* _this = (FLEXDecoder*)ctx; + // _this->decoder.process(data, count); + } + + static void _diagHandler(float* data, int count, void* ctx) { + FLEXDecoder* _this = (FLEXDecoder*)ctx; + float* buf = _this->diag.acquireBuffer(); + memcpy(buf, data, count * sizeof(float)); + _this->diag.releaseBuffer(); + } + + std::string name; + + VFOManager::VFO* vfo; + dsp::buffer::Reshaper reshape; + dsp::sink::Handler dataHandler; + dsp::sink::Handler diagHandler; + + flex::Decoder decoder; + + ImGui::SymbolDiagram diag; + + int brId = 0; + + OptionList baudrates; +}; \ No newline at end of file diff --git a/decoder_modules/pager_decoder/src/flex/flex.cpp b/decoder_modules/pager_decoder/src/flex/flex.cpp new file mode 100644 index 00000000..d21f723e --- /dev/null +++ b/decoder_modules/pager_decoder/src/flex/flex.cpp @@ -0,0 +1,5 @@ +#include "flex.h" + +namespace flex { + // TODO +} \ No newline at end of file diff --git a/decoder_modules/pager_decoder/src/flex/flex.h b/decoder_modules/pager_decoder/src/flex/flex.h new file mode 100644 index 00000000..2c37f171 --- /dev/null +++ b/decoder_modules/pager_decoder/src/flex/flex.h @@ -0,0 +1,11 @@ +#pragma once + +namespace flex { + class Decoder { + public: + // TODO + + private: + // TODO + }; +} \ No newline at end of file