M17 mode handler: calling demodulator update function when in RX mode

pull/68/head
Silvano Seva 2021-12-26 21:55:08 +01:00
rodzic d22948a096
commit 963fbdc141
4 zmienionych plików z 28 dodań i 17 usunięć

Wyświetl plik

@ -36,7 +36,8 @@
namespace M17
{
typedef struct {
typedef struct
{
int32_t index;
bool lsf;
} sync_t;

Wyświetl plik

@ -22,6 +22,7 @@
#define OPMODE_M17_H
#include <M17/M17Transmitter.h>
#include <M17/M17Demodulator.h>
#include <M17/M17Modulator.h>
#include <array>
#include "OpMode.h"
@ -105,6 +106,7 @@ private:
bool enterRx; ///< Flag for RX management.
M17::M17Modulator modulator; ///< M17 modulator.
M17::M17Demodulator demodulator; ///< M17 demodulator.
M17::M17Transmitter m17Tx; ///< M17 transmission manager.
};

Wyświetl plik

@ -24,12 +24,6 @@
#include <interfaces/audio_stream.h>
#include <math.h>
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
#include <toneGenerator_MDx.h>
#elif defined(PLATFORM_LINUX)
#include <stdio.h>
#endif
namespace M17
{
@ -82,7 +76,8 @@ void M17Demodulator::stopBasebandSampling()
inputStream_stop(basebandId);
}
void M17Demodulator::resetCorrelationStats() {
void M17Demodulator::resetCorrelationStats()
{
conv_ema = 0.0f;
conv_emvar = 20000000000.0f;
}
@ -104,21 +99,31 @@ float M17Demodulator::getCorrelationStddev()
return sqrt(conv_emvar);
}
void M17Demodulator::resetQuantizationStats() {
void M17Demodulator::resetQuantizationStats()
{
qnt_max = 0.0f;
}
void M17Demodulator::updateQuantizationStats(uint32_t offset)
{
auto value = baseband.data[offset];
if (value > qnt_max) {
if (value > qnt_max)
{
qnt_max = value;
} else
}
else
{
qnt_max *= qnt_maxmin_alpha;
if (value < qnt_min) {
}
if (value < qnt_min)
{
qnt_min = value;
} else
}
else
{
qnt_min *= qnt_maxmin_alpha;
}
}
float M17Demodulator::getQuantizationMax()

Wyświetl plik

@ -125,6 +125,7 @@ void OpMode_M17::enable()
pthread_create(&codecThread, &codecAttr, threadFunc, NULL);
modulator.init();
demodulator.init();
enterRx = true;
}
@ -138,6 +139,7 @@ void OpMode_M17::disable()
enterRx = false;
modulator.terminate();
demodulator.terminate();
}
void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
@ -148,6 +150,7 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
if(status->opStatus == RX)
{
// TODO: Implement M17 Rx
demodulator.update();
sleepFor(0u, 30u);
}
else if((status->opStatus == OFF) && enterRx)