mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-04-05 14:37:02 +00:00
Make Use COS As Lockout a run-time parameter and allow for different access modes.
This commit is contained in:
parent
ccdbe126e0
commit
20013e3adc
6 changed files with 75 additions and 54 deletions
87
FM.cpp
87
FM.cpp
|
|
@ -20,6 +20,14 @@
|
|||
#include "Globals.h"
|
||||
#include "FM.h"
|
||||
|
||||
/*
|
||||
* Access Mode values are:
|
||||
* 0 - Carrier access with COS
|
||||
* 1 - CTCSS only access without COS
|
||||
* 2 - CTCSS only access with COS
|
||||
* 3 - CTCSS only access with COS to start, then carrier access with COS
|
||||
*/
|
||||
|
||||
CFM::CFM() :
|
||||
m_callsign(),
|
||||
m_rfAck(),
|
||||
|
|
@ -41,7 +49,7 @@ m_filterStage1( 724, 1448, 724, 32768, -37895, 21352),//3rd order Cheby Fil
|
|||
m_filterStage2(32768, 0,-32768, 32768, -50339, 19052),
|
||||
m_filterStage3(32768, -65536, 32768, 32768, -64075, 31460),
|
||||
m_blanking(),
|
||||
m_useCOS(true),
|
||||
m_accessMode(1U),
|
||||
m_cosInvert(false),
|
||||
m_rfAudioBoost(1U),
|
||||
m_downsampler(128U),//Size might need adjustement
|
||||
|
|
@ -54,12 +62,8 @@ m_outputRB(2400U) // 100ms of audio
|
|||
|
||||
void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
||||
{
|
||||
if (m_useCOS) {
|
||||
if (m_cosInvert)
|
||||
cos = !cos;
|
||||
} else {
|
||||
cos = true;
|
||||
}
|
||||
if (m_cosInvert)
|
||||
cos = !cos;
|
||||
|
||||
clock(length);
|
||||
|
||||
|
|
@ -70,33 +74,48 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
|||
|
||||
uint8_t ctcssState = m_ctcssRX.process(currentSample);
|
||||
|
||||
if (!m_useCOS) {
|
||||
// Delay the audio by 100ms to better match the CTCSS detector output
|
||||
m_inputRB.put(currentSample);
|
||||
m_inputRB.get(currentSample);
|
||||
switch (m_accessMode) {
|
||||
case 0U:
|
||||
stateMachine(cos);
|
||||
break;
|
||||
|
||||
case 1U:
|
||||
// Delay the audio by 100ms to better match the CTCSS detector output
|
||||
m_inputRB.put(currentSample);
|
||||
m_inputRB.get(currentSample);
|
||||
|
||||
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
// Not enough samples to determine if you have CTCSS, just carry on
|
||||
} else {
|
||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||
stateMachine(validCTCSS);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2U:
|
||||
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
// Not enough samples to determine if you have CTCSS, just carry on
|
||||
} else {
|
||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||
stateMachine(validCTCSS && cos);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
// Not enough samples to determine if you have CTCSS, just carry on
|
||||
} else if (CTCSS_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
// We had enough samples for CTCSS and we are in some other mode than FM
|
||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||
stateMachine(validCTCSS && cos);
|
||||
} else {
|
||||
stateMachine(cos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
//Not enough samples to determine if you have CTCSS, just carry on
|
||||
if (m_modemState != STATE_FM)
|
||||
continue;
|
||||
} else if (CTCSS_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
//we had enough samples for CTCSS and we are in some other mode than FM
|
||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||
stateMachine(validCTCSS && cos);
|
||||
if (m_modemState != STATE_FM)
|
||||
continue;
|
||||
} else if (CTCSS_READY(ctcssState) && m_modemState == STATE_FM) {
|
||||
//We had enough samples for CTCSS and we are in FM mode, trigger the state machine
|
||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||
stateMachine(validCTCSS && cos);
|
||||
if (m_modemState != STATE_FM)
|
||||
break;
|
||||
} else if (CTCSS_NOT_READY(ctcssState) && m_modemState == STATE_FM && i == length - 1) {
|
||||
//Not enough samples for CTCSS but we already are in FM, trigger the state machine
|
||||
//but do not trigger the state machine on every single sample, save CPU!
|
||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||
stateMachine(validCTCSS && cos);
|
||||
}
|
||||
|
||||
// Only let audio through when relaying audio
|
||||
if (m_state == FS_RELAYING || m_state == FS_KERCHUNK) {
|
||||
|
|
@ -183,10 +202,10 @@ uint8_t CFM::setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_
|
|||
return m_rfAck.setParams(rfAck, speed, frequency, level, level);
|
||||
}
|
||||
|
||||
uint8_t CFM::setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssHighThreshold, uint8_t ctcssLowThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, bool cosInvert, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel)
|
||||
uint8_t CFM::setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssHighThreshold, uint8_t ctcssLowThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, uint8_t accessMode, bool cosInvert, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel)
|
||||
{
|
||||
m_useCOS = useCOS;
|
||||
m_cosInvert = cosInvert;
|
||||
m_accessMode = accessMode;
|
||||
m_cosInvert = cosInvert;
|
||||
|
||||
m_rfAudioBoost = q15_t(rfAudioBoost);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue