Trying to fix no tx, WIP

This commit is contained in:
Geoffrey Merck 2020-05-11 22:32:24 +02:00
parent b4a125a759
commit 042c26b3bb
2 changed files with 31 additions and 23 deletions

51
FM.cpp
View File

@ -62,7 +62,7 @@ m_inputExtRB(2400U) // 100ms of Audio
insertDelay(100U);
}
void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
void CFM::samples(bool cos, q15_t* samples, uint8_t length)
{
if (m_useCOS) {
if (m_cosInvert)
@ -147,35 +147,37 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
currentSample += m_ctcssTX.getAudio();
m_outputRFRB.put(currentSample);
//samples[i] = currentSample;
}
// XXX This relays audio correctly, no t, process need to be commented
// if (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF || m_state == FS_RELAYING_EXT || m_state == FS_KERCHUNK_EXT)
// io.write(STATE_FM, samples, i);
}
void CFM::process()
{
q15_t sample;
while (io.getSpace() >= 3U && m_outputRFRB.get(sample))
io.write(STATE_FM, &sample, 1U);
uint16_t space = io.getSpace() - 2U;
uint16_t length = m_outputRFRB.getData();
if (space > 2 && length >= FM_TX_BLOCK_SIZE ) {
// if (io.getSpace() > 2 && (m_outputRFRB.getData() >= FM_TX_BLOCK_SIZE || m_state != STATE_FM)) {//if we just left FM mode, so write all what is left in buffer, regardless of the amoutn of data
// uint16_t length = m_outputRFRB.getData();
// uint16_t space = io.getSpace() - 2;
if(length > FM_TX_BLOCK_SIZE)
length = FM_TX_BLOCK_SIZE;
if(space > FM_TX_BLOCK_SIZE)
space = FM_TX_BLOCK_SIZE;
if(length > space)
length = space;
// if(length > FM_TX_BLOCK_SIZE)
// length = FM_TX_BLOCK_SIZE;
// if(space > FM_TX_BLOCK_SIZE)
// space = FM_TX_BLOCK_SIZE;
// if(length > space)
// length = space;
q15_t samples[FM_TX_BLOCK_SIZE];
for(uint16_t i = 0U; i < length; i++) {
q15_t sample = 0;
m_outputRFRB.get(sample);
samples[i] = sample;
}
// q15_t samples[FM_TX_BLOCK_SIZE];
// for(uint16_t i = 0; i < length; i++) {
// q15_t sample = 0;
// m_outputRFRB.get(sample);
// samples[i] = sample;
// }
// io.write(STATE_FM, samples, length);
// }
io.write(STATE_FM, samples, length);
}
// //Write audio to serial
// if (m_downsampler.getData() >= 127 || m_state != STATE_FM) {//if we just left FM mode, so write all what is left in buffer, regardless of the amoutn of data
@ -325,6 +327,11 @@ void CFM::stateMachine(bool validRFSignal, bool validExtSignal)
default:
break;
}
if (m_state == FS_LISTENING) {
m_outputRFRB.reset();
m_downsampler.reset();
}
}
void CFM::clock(uint8_t length)

3
FM.h
View File

@ -51,7 +51,7 @@ class CFM {
public:
CFM();
void samples(bool cos, const q15_t* samples, uint8_t length);
void samples(bool cos, q15_t* samples, uint8_t length);
void process();
@ -117,6 +117,7 @@ private:
void clock(uint8_t length);
void sendCallsign();
void sendBeeps();
void beginRelaying();
void insertDelay(uint16_t ms);