Add UI and check for CAN on RX

pull/189/head
Marco 2023-09-05 20:38:22 +02:00 zatwierdzone przez Silvano Seva
rodzic f425a4c740
commit 1a7d62fb42
10 zmienionych plików z 94 dodań i 53 usunięć

Wyświetl plik

@ -59,6 +59,7 @@ typedef struct
uint8_t vpLevel : 3, // Voice prompt level
vpPhoneticSpell : 1, // Phonetic spell enabled
_reserved : 4;
bool m17_can_rx; // Check M17 CAN on RX
}
__attribute__((packed)) settings_t;
@ -80,7 +81,8 @@ static const settings_t default_settings =
0, // M17 CAN
0, // Voice prompts off
0, // Phonetic spell off
0 // not used
0, // not used
false // Check M17 CAN on RX
};
#endif /* SETTINGS_H */

Wyświetl plik

@ -53,7 +53,8 @@ typedef struct
txTone : 15; /**< TX CTC/DCS tone */
uint8_t can : 4, /**< M17 Channel Access Number */
_unused : 4;
canRxEn : 1, /**< M17 Check CAN on RX */
_unused : 3;
char source_address[10]; /**< M17 call source address */
char destination_address[10]; /**< M17 call routing address */

Wyświetl plik

@ -136,7 +136,8 @@ enum settingsVoicePromptItems
enum settingsM17Items
{
M17_CALLSIGN = 0,
M17_CAN
M17_CAN,
M17_CAN_RX
};
/**

Wyświetl plik

@ -128,8 +128,9 @@ enum settingsGPSItems
enum m17Items
{
M_CALLSIGN = 0
,M_CAN
M_CALLSIGN = 0,
M_CAN,
M_CAN_RX
};
enum module17Items

Wyświetl plik

@ -97,8 +97,9 @@ void *ui_threadFunc(void *arg)
rtx_cfg.txToneEn = state.channel.fm.txToneEn;
rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone];
// Copy new M17 CAN, source and destination addresses
// Copy new M17 CAN, M17 CAN RX check,source and destination addresses
rtx_cfg.can = state.settings.m17_can;
rtx_cfg.canRxEn = state.settings.m17_can_rx;
strncpy(rtx_cfg.source_address, state.settings.callsign, 10);
strncpy(rtx_cfg.destination_address, state.m17_dest, 10);

Wyświetl plik

@ -238,8 +238,13 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
strncpy(status->M17_refl, exCall2.c_str(), 10);
}
// Check CAN on RX, if enabled.
// If check is disabled, force match to true.
bool canMatch = (streamType.fields.CAN == status->can)
|| (status->canRxEn == false);
// Extract audio data
if((type == M17FrameType::STREAM) && (pthSts == PATH_OPEN))
if((type == M17FrameType::STREAM) && (pthSts == PATH_OPEN) && (canMatch == true))
{
M17StreamFrame sf = decoder.getStreamFrame();
codec_pushFrame(sf.payload().data(), false);

Wyświetl plik

@ -166,7 +166,8 @@ const char *settings_gps_items[] =
const char * settings_m17_items[] =
{
"Callsign",
"CAN"
"CAN",
"CAN RX Check"
};
const char * settings_voice_items[] =
@ -1970,51 +1971,65 @@ void ui_updateFSM(bool *sync_rtx)
case SETTINGS_M17:
if(ui_state.edit_mode)
{
if(ui_state.menu_selected == M17_CALLSIGN)
switch (ui_state.menu_selected)
{
// Handle text input for M17 callsign
if(msg.keys & KEY_ENTER)
{
_ui_textInputConfirm(ui_state.new_callsign);
// Save selected callsign and disable input mode
strncpy(state.settings.callsign, ui_state.new_callsign, 10);
ui_state.edit_mode = false;
vp_announceBuffer(&currentLanguage->callsign,
false, true, state.settings.callsign);
}
else if(msg.keys & KEY_ESC)
{
// Discard selected callsign and disable input mode
ui_state.edit_mode = false;
vp_announceBuffer(&currentLanguage->callsign,
false, true, state.settings.callsign);
}
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN ||
msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT)
{
_ui_textInputDel(ui_state.new_callsign);
}
else if(input_isNumberPressed(msg))
{
_ui_textInputKeypad(ui_state.new_callsign, 9, msg, true);
}
else if (msg.long_press && (msg.keys & KEY_F1) && (state.settings.vpLevel > vpBeep))
{
vp_announceBuffer(&currentLanguage->callsign,
true, true, ui_state.new_callsign);
f1Handled=true;
}
}
else
{
if(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)
_ui_changeM17Can(-1);
else if(msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)
_ui_changeM17Can(+1);
else if(msg.keys & KEY_ENTER)
ui_state.edit_mode = !ui_state.edit_mode;
else if(msg.keys & KEY_ESC)
ui_state.edit_mode = false;
case M17_CALLSIGN:
// Handle text input for M17 callsign
if(msg.keys & KEY_ENTER)
{
_ui_textInputConfirm(ui_state.new_callsign);
// Save selected callsign and disable input mode
strncpy(state.settings.callsign, ui_state.new_callsign, 10);
ui_state.edit_mode = false;
vp_announceBuffer(&currentLanguage->callsign,
false, true, state.settings.callsign);
}
else if(msg.keys & KEY_ESC)
{
// Discard selected callsign and disable input mode
ui_state.edit_mode = false;
vp_announceBuffer(&currentLanguage->callsign,
false, true, state.settings.callsign);
}
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN ||
msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT)
{
_ui_textInputDel(ui_state.new_callsign);
}
else if(input_isNumberPressed(msg))
{
_ui_textInputKeypad(ui_state.new_callsign, 9, msg, true);
}
else if (msg.long_press && (msg.keys & KEY_F1) && (state.settings.vpLevel > vpBeep))
{
vp_announceBuffer(&currentLanguage->callsign,
true, true, ui_state.new_callsign);
f1Handled=true;
}
break;
case M17_CAN:
if(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)
_ui_changeM17Can(-1);
else if(msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)
_ui_changeM17Can(+1);
else if(msg.keys & KEY_ENTER)
ui_state.edit_mode = !ui_state.edit_mode;
else if(msg.keys & KEY_ESC)
ui_state.edit_mode = false;
break;
case M17_CAN_RX:
if(msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT ||
(ui_state.edit_mode &&
(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT ||
msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)))
{
state.settings.m17_can_rx =
!state.settings.m17_can_rx;
}
else if(msg.keys & KEY_ENTER)
ui_state.edit_mode = !ui_state.edit_mode;
else if(msg.keys & KEY_ESC)
ui_state.edit_mode = false;
}
}
else

Wyświetl plik

@ -353,6 +353,11 @@ int _ui_getM17ValueName(char *buf, uint8_t max_len, uint8_t index)
case M17_CAN:
snprintf(buf, max_len, "%d", last_state.settings.m17_can);
break;
case M17_CAN_RX:
snprintf(buf, max_len, "%s", (last_state.settings.m17_can_rx) ?
currentLanguage->on :
currentLanguage->off);
break;
}
return 0;

Wyświetl plik

@ -97,7 +97,8 @@ const char *display_items[] =
const char *m17_items[] =
{
"Callsign",
"CAN"
"CAN",
"CAN RX Check"
};
const char *module17_items[] =
@ -967,6 +968,9 @@ void ui_updateFSM(bool *sync_rtx)
case M_CAN:
_ui_changeCAN(-1);
break;
case M_CAN_RX:
state.settings.m17_can_rx = !state.settings.m17_can_rx;
break;
default:
state.ui_screen = SETTINGS_M17;
}
@ -978,6 +982,9 @@ void ui_updateFSM(bool *sync_rtx)
case M_CAN:
_ui_changeCAN(+1);
break;
case M_CAN_RX:
state.settings.m17_can_rx = !state.settings.m17_can_rx;
break;
default:
state.ui_screen = SETTINGS_M17;
}

Wyświetl plik

@ -210,6 +210,9 @@ int _ui_getM17ValueName(char *buf, uint8_t max_len, uint8_t index)
case M_CAN:
snprintf(buf, max_len, "%d", last_state.settings.m17_can);
break;
case M_CAN_RX:
snprintf(buf, max_len, "%s", (last_state.settings.m17_can_rx) ? "on" : "off");
break;
}
return 0;