Add tone enable flags into channel data structure

This commit is contained in:
Niccolò Izzo 2021-01-05 09:11:07 +01:00
parent 04a8e2025e
commit bbcd6483a2
6 changed files with 30 additions and 18 deletions

View File

@ -43,8 +43,10 @@ enum admit_t
*/ */
typedef struct typedef struct
{ {
uint16_t ctcDcs_rx; /**< RX CTCSS or DCS code, squelch opens on match */ uint16_t rxToneEn : 1, /**< RX CTC/DCS tone enable */
uint16_t ctcDcs_tx; /**< TX CTCSS or DCS code, sent alongside voice */ 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 */
} fmInfo_t; } fmInfo_t;
/** /**

View File

@ -43,8 +43,10 @@ void state_init()
state.channel.power = 1.0; state.channel.power = 1.0;
state.channel.rx_frequency = 430000000; state.channel.rx_frequency = 430000000;
state.channel.tx_frequency = 430000000; state.channel.tx_frequency = 430000000;
state.channel.fm.ctcDcs_rx = 0; state.channel.fm.rxToneEn = 0;
state.channel.fm.ctcDcs_tx = 719; state.channel.fm.rxTone = 719;
state.channel.fm.txToneEn = 1;
state.channel.fm.txTone = 719;
state.rtxStatus = RTX_OFF; state.rtxStatus = RTX_OFF;
state.sqlLevel = 3; state.sqlLevel = 3;

View File

@ -118,8 +118,10 @@ static void ui_task(void *arg)
rtx_cfg.txFrequency = state.channel.tx_frequency; rtx_cfg.txFrequency = state.channel.tx_frequency;
rtx_cfg.txPower = state.channel.power; rtx_cfg.txPower = state.channel.power;
rtx_cfg.sqlLevel = state.channel.squelch; rtx_cfg.sqlLevel = state.channel.squelch;
rtx_cfg.rxTone = state.channel.fm.ctcDcs_rx; rtx_cfg.rxToneEn = state.channel.fm.rxToneEn;
rtx_cfg.txTone = state.channel.fm.ctcDcs_tx; rtx_cfg.rxTone = state.channel.fm.rxTone;
rtx_cfg.txToneEn = state.channel.fm.txToneEn;
rtx_cfg.txTone = state.channel.fm.txTone;
OSMutexPost(&rtx_mutex, OS_OPT_POST_NONE, &os_err); OSMutexPost(&rtx_mutex, OS_OPT_POST_NONE, &os_err);
rtx_configure(&rtx_cfg); rtx_configure(&rtx_cfg);

View File

@ -708,20 +708,22 @@ bool _ui_drawMenuMacro(state_t* last_state) {
gfx_print(layout.line1_left, "1", layout.top_font, TEXT_ALIGN_LEFT, gfx_print(layout.line1_left, "1", layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413); yellow_fab413);
char code_str[9] = { 0 }; char code_str[9] = { 0 };
snprintf(code_str, 9, " %3.1f", last_state->channel.fm.ctcDcs_tx/10.0f); snprintf(code_str, 9, " %3.1f", last_state->channel.fm.txTone/10.0f);
gfx_print(layout.line1_left, code_str, layout.top_font, TEXT_ALIGN_LEFT, gfx_print(layout.line1_left, code_str, layout.top_font, TEXT_ALIGN_LEFT,
color_white); color_white);
gfx_print(layout.line1_left, "2 ", layout.top_font, TEXT_ALIGN_CENTER, gfx_print(layout.line1_left, "2 ", layout.top_font, TEXT_ALIGN_CENTER,
yellow_fab413); yellow_fab413);
char encdec_str[9] = { 0 }; char encdec_str[9] = { 0 };
if (last_state->channel.fm.ctcDcs_tx != 0 && last_state->channel.fm.ctcDcs_rx != 0) bool tone_tx_enable = last_state->channel.fm.txToneEn;
snprintf(encdec_str, 9, " E+D", last_state->channel.fm.ctcDcs_tx/10); bool tone_rx_enable = last_state->channel.fm.rxToneEn;
else if (last_state->channel.fm.ctcDcs_tx != 0 && last_state->channel.fm.ctcDcs_rx == 0) if (tone_tx_enable && tone_rx_enable)
snprintf(encdec_str, 9, " E ", last_state->channel.fm.ctcDcs_tx/10); snprintf(encdec_str, 9, " E+D");
else if (last_state->channel.fm.ctcDcs_tx == 0 && last_state->channel.fm.ctcDcs_rx != 0) else if (tone_tx_enable && !tone_rx_enable)
snprintf(encdec_str, 9, " D ", last_state->channel.fm.ctcDcs_tx/10); snprintf(encdec_str, 9, " E ");
else if (!tone_tx_enable && tone_rx_enable)
snprintf(encdec_str, 9, " D ");
else else
snprintf(encdec_str, 9, " ", last_state->channel.fm.ctcDcs_tx/10); snprintf(encdec_str, 9, " ");
gfx_print(layout.line1_left, encdec_str, layout.top_font, TEXT_ALIGN_CENTER, gfx_print(layout.line1_left, encdec_str, layout.top_font, TEXT_ALIGN_CENTER,
color_white); color_white);
gfx_print(layout.line1_right, "3 ", layout.top_font, TEXT_ALIGN_RIGHT, gfx_print(layout.line1_right, "3 ", layout.top_font, TEXT_ALIGN_RIGHT,

View File

@ -230,8 +230,10 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
/* Load mode-specific parameters */ /* Load mode-specific parameters */
if(channel->mode == FM) if(channel->mode == FM)
{ {
channel->fm.ctcDcs_rx = chData.ctcss_dcs_receive; channel->fm.rxToneEn = chData.ctcss_dcs_receive != 0;
channel->fm.ctcDcs_tx = chData.ctcss_dcs_transmit; channel->fm.rxTone = chData.ctcss_dcs_receive;
channel->fm.txToneEn = chData.ctcss_dcs_transmit != 0;
channel->fm.txTone = chData.ctcss_dcs_transmit;
} }
else if(channel->mode == DMR) else if(channel->mode == DMR)
{ {

View File

@ -263,8 +263,10 @@ int nvm_readChannelData(channel_t *channel, uint16_t pos)
/* Load mode-specific parameters */ /* Load mode-specific parameters */
if(channel->mode == FM) if(channel->mode == FM)
{ {
channel->fm.ctcDcs_rx = chData.ctcss_dcs_receive; channel->fm.rxToneEn = chData.ctcss_dcs_receive != 0;
channel->fm.ctcDcs_tx = chData.ctcss_dcs_transmit; channel->fm.rxTone = chData.ctcss_dcs_receive;
channel->fm.txToneEn = chData.ctcss_dcs_transmit != 0;
channel->fm.txTone = chData.ctcss_dcs_transmit;
} }
else if(channel->mode == DMR) else if(channel->mode == DMR)
{ {