More work on the keyer.

This commit is contained in:
Jonathan Naylor 2020-04-15 22:41:30 +01:00
parent c103ac91b3
commit 4b0c3d88f3
3 changed files with 39 additions and 6 deletions

8
FM.cpp
View File

@ -89,7 +89,13 @@ void CFM::setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, u
m_callsignAtStart = callsignAtStart; m_callsignAtStart = callsignAtStart;
m_callsignAtEnd = callsignAtEnd; m_callsignAtEnd = callsignAtEnd;
m_holdoffTimer.setTimeout(holdoff, 0U); uint16_t holdoffTime = 0U;
uint16_t callsignTime = time * 60U;
if (holdoff > 0U)
holdoffTime = callsignTime / holdoff;
m_holdoffTimer.setTimeout(holdoffTime, 0U);
m_callsignTimer.setTimeout(callsignTime, 0U);
} }
void CFM::setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level) void CFM::setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level)

View File

@ -21,7 +21,7 @@
#include "FMKeyer.h" #include "FMKeyer.h"
const struct { const struct {
uint8_t c; char c;
uint32_t pattern; uint32_t pattern;
uint8_t length; uint8_t length;
} SYMBOL_LIST[] = { } SYMBOL_LIST[] = {
@ -78,17 +78,40 @@ const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02
CFMKeyer::CFMKeyer() : CFMKeyer::CFMKeyer() :
m_level(128 * 128), m_level(128 * 128),
m_wanted(false), m_wanted(false),
m_running(false) m_running(false),
m_poBuffer(),
m_poLen(0U)
{ {
} }
void CFMKeyer::setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t level) void CFMKeyer::setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t level)
{ {
m_level = q15_t(level * 128); m_level = q15_t(level * 128);
for (uint8_t i = 0U; text[i] != '\0'; i++) {
for (uint8_t j = 0U; SYMBOL_LIST[j].c != 0U; j++) {
if (SYMBOL_LIST[j].c == text[i]) {
uint32_t MASK = 0x80000000U;
for (uint8_t k = 0U; k < SYMBOL_LIST[j].length; k++, m_poLen++, MASK >>= 1) {
bool b = (SYMBOL_LIST[j].pattern & MASK) == MASK;
WRITE_BIT(m_poBuffer, m_poLen, b);
if (m_poLen >= 995U) {
m_poLen = 0U;
return;
}
}
break;
}
}
}
} }
void CFMKeyer::getAudio(q15_t* samples, uint8_t length) void CFMKeyer::getAudio(q15_t* samples, uint8_t length)
{ {
if (!m_wanted && !m_running)
return;
} }
void CFMKeyer::start() void CFMKeyer::start()
@ -98,6 +121,8 @@ void CFMKeyer::start()
void CFMKeyer::stop() void CFMKeyer::stop()
{ {
m_wanted = false;
m_running = false;
} }
bool CFMKeyer::isRunning() const bool CFMKeyer::isRunning() const

View File

@ -35,9 +35,11 @@ public:
bool isRunning() const; bool isRunning() const;
private: private:
q15_t m_level; q15_t m_level;
bool m_wanted; bool m_wanted;
bool m_running; bool m_running;
uint8_t m_poBuffer[1000U];
uint16_t m_poLen;
}; };
#endif #endif