2020-08-11 18:33:42 +02:00
|
|
|
#include <imgui.h>
|
|
|
|
#include <module.h>
|
|
|
|
#include <path.h>
|
2020-08-12 16:43:44 +02:00
|
|
|
#include <watcher.h>
|
2020-08-11 18:33:42 +02:00
|
|
|
|
|
|
|
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
|
|
|
|
|
|
|
mod::API_t* API;
|
|
|
|
|
|
|
|
struct RadioContext_t {
|
|
|
|
std::string name;
|
|
|
|
int demod = 1;
|
|
|
|
SigPath sigPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
MOD_EXPORT void* _INIT_(mod::API_t* _API, ImGuiContext* imctx, std::string _name) {
|
|
|
|
API = _API;
|
|
|
|
RadioContext_t* ctx = new RadioContext_t;
|
|
|
|
ctx->name = _name;
|
|
|
|
ctx->sigPath.init(_name, 200000, 1000, API->registerVFO(_name, mod::API_t::REF_CENTER, 0, 200000, 200000, 1000));
|
|
|
|
ctx->sigPath.start();
|
|
|
|
ImGui::SetCurrentContext(imctx);
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
2020-08-12 16:43:44 +02:00
|
|
|
MOD_EXPORT void _NEW_FRAME_(RadioContext_t* ctx) {
|
2020-08-20 18:29:23 +02:00
|
|
|
|
2020-08-12 16:43:44 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 18:33:42 +02:00
|
|
|
MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
|
|
|
ImGui::Columns(4, CONCAT("RadioModeColumns##_", ctx->name), false);
|
|
|
|
if (ImGui::RadioButton(CONCAT("NFM##_", ctx->name), ctx->demod == 0) && ctx->demod != 0) {
|
|
|
|
ctx->sigPath.setDemodulator(SigPath::DEMOD_NFM);
|
|
|
|
ctx->demod = 0;
|
2020-08-12 16:43:44 +02:00
|
|
|
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
|
|
|
if (ImGui::RadioButton(CONCAT("WFM##_", ctx->name), ctx->demod == 1) && ctx->demod != 1) {
|
|
|
|
ctx->sigPath.setDemodulator(SigPath::DEMOD_FM);
|
|
|
|
ctx->demod = 1;
|
2020-08-12 16:43:44 +02:00
|
|
|
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
|
|
|
ImGui::NextColumn();
|
|
|
|
if (ImGui::RadioButton(CONCAT("AM##_", ctx->name), ctx->demod == 2) && ctx->demod != 2) {
|
|
|
|
ctx->sigPath.setDemodulator(SigPath::DEMOD_AM);
|
|
|
|
ctx->demod = 2;
|
2020-08-12 16:43:44 +02:00
|
|
|
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
2020-08-20 18:29:23 +02:00
|
|
|
if (ImGui::RadioButton(CONCAT("DSB##_", ctx->name), ctx->demod == 3) && ctx->demod != 3) {
|
|
|
|
ctx->sigPath.setDemodulator(SigPath::DEMOD_DSB);
|
|
|
|
ctx->demod = 3;
|
|
|
|
API->setVFOReference(ctx->name, mod::API_t::REF_CENTER);
|
|
|
|
}
|
2020-08-11 18:33:42 +02:00
|
|
|
ImGui::NextColumn();
|
|
|
|
if (ImGui::RadioButton(CONCAT("USB##_", ctx->name), ctx->demod == 4) && ctx->demod != 4) {
|
|
|
|
ctx->sigPath.setDemodulator(SigPath::DEMOD_USB);
|
|
|
|
ctx->demod = 4;
|
2020-08-12 16:43:44 +02:00
|
|
|
API->setVFOReference(ctx->name, mod::API_t::REF_LOWER);
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
|
|
|
if (ImGui::RadioButton(CONCAT("CW##_", ctx->name), ctx->demod == 5) && ctx->demod != 5) { ctx->demod = 5; };
|
|
|
|
ImGui::NextColumn();
|
|
|
|
if (ImGui::RadioButton(CONCAT("LSB##_", ctx->name), ctx->demod == 6) && ctx->demod != 6) {
|
|
|
|
ctx->sigPath.setDemodulator(SigPath::DEMOD_LSB);
|
|
|
|
ctx->demod = 6;
|
2020-08-12 16:43:44 +02:00
|
|
|
API->setVFOReference(ctx->name, mod::API_t::REF_UPPER);
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
|
|
|
if (ImGui::RadioButton(CONCAT("RAW##_", ctx->name), ctx->demod == 7) && ctx->demod != 7) { ctx->demod = 7; };
|
|
|
|
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", ctx->name), false);
|
|
|
|
|
|
|
|
ImGui::EndGroup();
|
2020-08-12 16:43:44 +02:00
|
|
|
|
2020-08-20 18:29:23 +02:00
|
|
|
ImGui::Checkbox(CONCAT("Deemphasis##_", ctx->name), &ctx->sigPath.deemp.bypass);
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MOD_EXPORT void _HANDLE_EVENT_(RadioContext_t* ctx, int eventId) {
|
2020-08-20 18:29:23 +02:00
|
|
|
|
2020-08-11 18:33:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MOD_EXPORT void _STOP_(RadioContext_t* ctx) {
|
|
|
|
API->removeVFO(ctx->name);
|
|
|
|
delete ctx;
|
|
|
|
}
|