Code clean up + added inter module communication

This commit is contained in:
Ryzerth
2021-04-22 04:15:23 +02:00
parent 2c83d79836
commit 72cbf741b3
8 changed files with 169 additions and 20 deletions

View File

@ -15,6 +15,7 @@
#include <raw_demod.h>
#include <cw_demod.h>
#include <options.h>
#include <radio_interface.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str())
@ -63,6 +64,8 @@ public:
stream.start();
gui::menu.registerEntry(name, menuHandler, this, this);
core::modComManager.registerInterface("radio", name, moduleInterfaceHandler, this);
}
~RadioModule() {
@ -155,6 +158,13 @@ private:
}
}
static void moduleInterfaceHandler(int code, void* in, void* out, void* ctx) {
RadioModule* _this = (RadioModule*)ctx;
if (code == RADIO_IFACE_CMD_GET_MODE) {
*(int*)out = _this->demodId;
}
}
void selectDemod(Demodulator* demod) {
if (currentDemod != NULL) { currentDemod->stop(); }
currentDemod = demod;

View File

@ -0,0 +1,16 @@
#pragma once
enum {
RADIO_IFACE_CMD_GET_MODE
};
enum {
RADIO_IFACE_MODE_NFM,
RADIO_IFACE_MODE_WFM,
RADIO_IFACE_MODE_AM,
RADIO_IFACE_MODE_DSB,
RADIO_IFACE_MODE_USB,
RADIO_IFACE_MODE_CW,
RADIO_IFACE_MODE_LSB,
RADIO_IFACE_MODE_RAW
};