Add changes by G4KLX

This commit is contained in:
phl0 2019-01-30 09:25:33 +01:00
parent 461182bf60
commit 5456f403a1
No known key found for this signature in database
GPG Key ID: 48EA1E640798CA9A
2 changed files with 23 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Florian Wolters DF2ET * Copyright (C) 2019 by Florian Wolters DF2ET
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,7 +29,6 @@ const q15_t sine600Hz[] = {
}; };
CCalPOCSAG::CCalPOCSAG() : CCalPOCSAG::CCalPOCSAG() :
m_transmit(false),
m_state(POCSAGCAL_IDLE), m_state(POCSAGCAL_IDLE),
m_audioSeq(0U) m_audioSeq(0U)
{ {
@ -37,24 +36,26 @@ m_audioSeq(0U)
void CCalPOCSAG::process() void CCalPOCSAG::process()
{ {
pocsagTX.process(); if (m_state == POCSAGCAL_IDLE)
uint16_t space = pocsagTX.getSpace();
if (space < 1U)
return; return;
switch (m_state) { uint16_t space = io.getSpace();
case POCSAGCAL_TX: if (space == 0U)
pocsagTX.writeData((uint8_t) &sine600Hz[m_audioSeq], 40U); return;
m_audioSeq++;
if(!m_transmit) q15_t samples[200U];
m_state = POCSAGCAL_IDLE; unt16_t length = 0U;
break;
default: if (space > 200U)
m_state = POCSAGCAL_IDLE; space = 200U;
for (uint16_t i = 0U; i < space; i++, length++)
samples[i] = sine600Hz[m_audioSeq++];
if (m_audioSeq >= 40U)
m_audioSeq = 0U; m_audioSeq = 0U;
break;
} }
io.write(MODE_POCSAG, samples, length);
} }
uint8_t CCalPOCSAG::write(const uint8_t* data, uint8_t length) uint8_t CCalPOCSAG::write(const uint8_t* data, uint8_t length)
@ -62,11 +63,14 @@ uint8_t CCalPOCSAG::write(const uint8_t* data, uint8_t length)
if (length != 1U) if (length != 1U)
return 4U; return 4U;
m_transmit = data[0U] == 1U; bool on = data[0U] == 1U;
if(m_transmit && m_state == POCSAGCAL_IDLE) if (on && m_state == POCSAGCAL_IDLE) {
m_state = POCSAGCAL_TX; m_state = POCSAGCAL_TX;
m_audioSeq = 0U;
} else if (!on && m_state == POCSAGCAL_TX) {
m_state = POCSAGCAL_IDLE;
}
return 0U; return 0U;
} }

View File

@ -35,10 +35,8 @@ public:
uint8_t write(const uint8_t* data, uint8_t length); uint8_t write(const uint8_t* data, uint8_t length);
private: private:
bool m_transmit;
POCSAGCAL m_state; POCSAGCAL m_state;
uint8_t m_audioSeq; uint8_t m_audioSeq;
}; };
#endif #endif