Implement CTCSS available tones array

Now the CTCSS tones are taken from an array and indexed from that array.
A macro that sets the tone has been implemented.
replace/240e0f65159fed6f3b9445c8834e005228b66cc0 v0.1
Niccolò Izzo 2021-01-05 11:11:33 +01:00
rodzic 29e4e35199
commit adc48efb19
6 zmienionych plików z 75 dodań i 14 usunięć

Wyświetl plik

@ -41,12 +41,20 @@ enum admit_t
* Data structure containing all and only the information for analog FM channels,
* like CTC/DCS tones.
*/
#define MAX_TONE_INDEX 50
static const uint16_t ctcss_tone[MAX_TONE_INDEX] = {
670, 693, 719, 744, 770, 797, 825, 854, 885, 915, 948, 974, 1000, 1034,
1072, 1109, 1148, 1188, 1230, 1273, 1318, 1365, 1413, 1462, 1514, 1567,
1598, 1622, 1655, 1679, 1713, 1738, 1773, 1799, 1835, 1862, 1899, 1928,
1966, 1995, 2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541
};
typedef struct
{
uint16_t rxToneEn : 1, /**< RX CTC/DCS tone enable */
rxTone : 15; /**< RX CTC/DCS tone, squelch opens on match */
uint16_t txToneEn : 1, /**< TX CTC/DCS tone enable */
txTone : 15; /**< TX CTC/DCS tonem sent alongside voidce */
uint8_t rxToneEn : 1, /**< RX CTC/DCS tone enable */
rxTone : 7; /**< RX CTC/DCS tone index, squelch opens on match */
uint8_t txToneEn : 1, /**< TX CTC/DCS tone enable */
txTone : 7; /**< TX CTC/DCS tone index, sent alongside voice */
} fmInfo_t;
/**

Wyświetl plik

@ -44,9 +44,9 @@ void state_init()
state.channel.rx_frequency = 430000000;
state.channel.tx_frequency = 430000000;
state.channel.fm.rxToneEn = 0;
state.channel.fm.rxTone = 719;
state.channel.fm.rxTone = 2; // 71.9Hz
state.channel.fm.txToneEn = 1;
state.channel.fm.txTone = 719;
state.channel.fm.txTone = 2; // 71.9Hz
state.rtxStatus = RTX_OFF;
state.sqlLevel = 3;

Wyświetl plik

@ -119,9 +119,9 @@ static void ui_task(void *arg)
rtx_cfg.txPower = state.channel.power;
rtx_cfg.sqlLevel = state.channel.squelch;
rtx_cfg.rxToneEn = state.channel.fm.rxToneEn;
rtx_cfg.rxTone = state.channel.fm.rxTone;
rtx_cfg.rxTone = ctcss_tone[state.channel.fm.rxTone];
rtx_cfg.txToneEn = state.channel.fm.txToneEn;
rtx_cfg.txTone = state.channel.fm.txTone;
rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone];
OSMutexPost(&rtx_mutex, OS_OPT_POST_NONE, &os_err);
rtx_configure(&rtx_cfg);

Wyświetl plik

@ -707,8 +707,9 @@ bool _ui_drawMenuMacro(state_t* last_state) {
// First row
gfx_print(layout.line1_left, "1", layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413);
char code_str[9] = { 0 };
snprintf(code_str, 9, " %3.1f", last_state->channel.fm.txTone/10.0f);
char code_str[11] = { 0 };
snprintf(code_str, 11, " %6.1f",
ctcss_tone[last_state->channel.fm.txTone]/10.0f);
gfx_print(layout.line1_left, code_str, layout.top_font, TEXT_ALIGN_LEFT,
color_white);
gfx_print(layout.line1_left, "2 ", layout.top_font, TEXT_ALIGN_CENTER,
@ -1037,6 +1038,12 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
uint8_t tone_flags = tone_tx_enable << 1 | tone_rx_enable;
switch(input_number)
{
case 1:
state.channel.fm.txTone++;
state.channel.fm.txTone %= MAX_TONE_INDEX;
state.channel.fm.rxTone = state.channel.fm.txTone;
*sync_rtx = true;
break;
case 2:
tone_flags++;
tone_flags %= 4;

Wyświetl plik

@ -231,9 +231,32 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
if(channel->mode == FM)
{
channel->fm.rxToneEn = chData.ctcss_dcs_receive != 0;
channel->fm.rxTone = chData.ctcss_dcs_receive;
channel->fm.txToneEn = chData.ctcss_dcs_transmit != 0;
channel->fm.txTone = chData.ctcss_dcs_transmit;
// TODO: Implement binary search to speed up this lookup
if (channel->fm.rxToneEn)
{
for(int i = 0; i < MAX_TONE_INDEX; i++)
{
if (ctcss_tone[i] == chData.ctcss_dcs_receive)
{
channel->fm.rxTone = i;
break;
}
}
}
if (channel->fm.txToneEn)
{
for(int i = 0; i < MAX_TONE_INDEX; i++)
{
if (ctcss_tone[i] == chData.ctcss_dcs_transmit)
{
channel->fm.txTone = i;
break;
}
}
}
// TODO: Implement warning screen if tone was not found
}
else if(channel->mode == DMR)
{

Wyświetl plik

@ -264,9 +264,32 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
if(channel->mode == FM)
{
channel->fm.rxToneEn = chData.ctcss_dcs_receive != 0;
channel->fm.rxTone = chData.ctcss_dcs_receive;
channel->fm.txToneEn = chData.ctcss_dcs_transmit != 0;
channel->fm.txTone = chData.ctcss_dcs_transmit;
// TODO: Implement binary search to speed up this lookup
if (channel->fm.rxToneEn)
{
for(int i = 0; i < MAX_TONE_INDEX; i++)
{
if (ctcss_tone[i] == chData.ctcss_dcs_receive)
{
channel->fm.rxTone = i;
break;
}
}
}
if (channel->fm.txToneEn)
{
for(int i = 0; i < MAX_TONE_INDEX; i++)
{
if (ctcss_tone[i] == chData.ctcss_dcs_transmit)
{
channel->fm.txTone = i;
break;
}
}
}
// TODO: Implement warning screen if tone was not found
}
else if(channel->mode == DMR)
{