mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Show DCS codes from 39 to 121; Code refactoring (16 B)
This commit is contained in:
1 parent
c1f8e945c9
commit
b83e4c2491
2 files changed
+52
-71
No files matched your search
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include "dcs.h"
|
#include "dcs.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
@@ -122,18 +123,18 @@ uint8_t DCS_GetCtcssCode(int Code)
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option)
|
static uint8_t DCS_GetApprovedIndex(uint8_t Option, size_t options_size, size_t extraidx_size, const uint8_t *extraidx)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int extra_pos = 0;
|
unsigned int extra_pos = 0;
|
||||||
uint8_t approved_index = 0;
|
uint8_t approved_index = 0;
|
||||||
|
|
||||||
if (Option >= ARRAY_SIZE(CTCSS_Options))
|
if (Option >= options_size)
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(CTCSS_Options); i++) {
|
for (i = 0; i < options_size; i++) {
|
||||||
const bool is_extra = extra_pos < ARRAY_SIZE(CTCSS_ExtraIdx) &&
|
const bool is_extra = extra_pos < extraidx_size &&
|
||||||
i == CTCSS_ExtraIdx[extra_pos];
|
i == extraidx[extra_pos];
|
||||||
|
|
||||||
if (is_extra) {
|
if (is_extra) {
|
||||||
extra_pos++;
|
extra_pos++;
|
||||||
@@ -149,29 +150,12 @@ uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option)
|
|||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t DCS_GetCtcssApprovedIndex(uint8_t Option)
|
||||||
|
{
|
||||||
|
return DCS_GetApprovedIndex(Option, ARRAY_SIZE(CTCSS_Options), ARRAY_SIZE(CTCSS_ExtraIdx), CTCSS_ExtraIdx);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t DCS_GetDcsApprovedIndex(uint8_t Option)
|
uint8_t DCS_GetDcsApprovedIndex(uint8_t Option)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
return DCS_GetApprovedIndex(Option, ARRAY_SIZE(DCS_Options), ARRAY_SIZE(DCS_ExtraIdx), DCS_ExtraIdx);
|
||||||
unsigned int extra_pos = 0;
|
|
||||||
uint8_t approved_index = 0;
|
|
||||||
|
|
||||||
if (Option >= ARRAY_SIZE(DCS_Options))
|
|
||||||
return 0xFF;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(DCS_Options); i++) {
|
|
||||||
const bool is_extra = extra_pos < ARRAY_SIZE(DCS_ExtraIdx) &&
|
|
||||||
i == DCS_ExtraIdx[extra_pos];
|
|
||||||
|
|
||||||
if (is_extra) {
|
|
||||||
extra_pos++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == Option)
|
|
||||||
return approved_index;
|
|
||||||
|
|
||||||
approved_index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0xFF;
|
|
||||||
}
|
}
|
||||||
+40
-43
@@ -593,6 +593,8 @@ void UI_DisplayMenu(void)
|
|||||||
char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char)
|
char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char)
|
||||||
char top_right_badge[16];
|
char top_right_badge[16];
|
||||||
|
|
||||||
|
const int m = UI_MENU_GetCurrentMenuId();
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
char Contact[16];
|
char Contact[16];
|
||||||
#endif
|
#endif
|
||||||
@@ -706,7 +708,7 @@ void UI_DisplayMenu(void)
|
|||||||
uint8_t gaugeMax = 0;
|
uint8_t gaugeMax = 0;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
switch (UI_MENU_GetCurrentMenuId())
|
switch (m)
|
||||||
{
|
{
|
||||||
case MENU_SQL:
|
case MENU_SQL:
|
||||||
sprintf(String, "%d", gSubMenuSelection);
|
sprintf(String, "%d", gSubMenuSelection);
|
||||||
@@ -1059,7 +1061,7 @@ void UI_DisplayMenu(void)
|
|||||||
case MENU_S_LIST:
|
case MENU_S_LIST:
|
||||||
if (gSubMenuSelection == MR_CHANNELS_LIST + 1)
|
if (gSubMenuSelection == MR_CHANNELS_LIST + 1)
|
||||||
strcpy(String, "ALL");
|
strcpy(String, "ALL");
|
||||||
else if (gSubMenuSelection == 0 && UI_MENU_GetCurrentMenuId() == MENU_LIST_CH)
|
else if (gSubMenuSelection == 0 && m == MENU_LIST_CH)
|
||||||
strcpy(String, "OFF");
|
strcpy(String, "OFF");
|
||||||
else {
|
else {
|
||||||
const char *name = gListName[gSubMenuSelection - 1];
|
const char *name = gListName[gSubMenuSelection - 1];
|
||||||
@@ -1466,16 +1468,16 @@ void UI_DisplayMenu(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_1 || UI_MENU_GetCurrentMenuId() == MENU_S_PRI_CH_2)
|
if (m == MENU_S_PRI_CH_1 || m == MENU_S_PRI_CH_2)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gCssBackgroundScan)
|
if ((m == MENU_R_CTCS || m == MENU_R_DCS) && gCssBackgroundScan)
|
||||||
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
|
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
|
||||||
|
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid) {
|
if (m == MENU_D_LIST && gIsDtmfContactValid) {
|
||||||
Contact[11] = 0;
|
Contact[11] = 0;
|
||||||
memcpy(&gDTMF_ID, Contact + 8, 4);
|
memcpy(&gDTMF_ID, Contact + 8, 4);
|
||||||
sprintf(String, "ID:%4s", gDTMF_ID);
|
sprintf(String, "ID:%4s", gDTMF_ID);
|
||||||
@@ -1483,51 +1485,46 @@ void UI_DisplayMenu(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS ||
|
if (m == MENU_R_CTCS ||
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_T_CTCS ||
|
m == MENU_T_CTCS) {
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_R_DCS ||
|
const uint8_t approved_index =
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_T_DCS
|
(gSubMenuSelection > 0) ? DCS_GetCtcssApprovedIndex(gSubMenuSelection - 1) : 0xFF;
|
||||||
#ifdef ENABLE_DTMF_CALLING
|
|
||||||
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS ||
|
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_T_CTCS) {
|
|
||||||
const uint8_t approved_index =
|
|
||||||
(gSubMenuSelection > 0) ? DCS_GetCtcssApprovedIndex(gSubMenuSelection - 1) : 0xFF;
|
|
||||||
|
|
||||||
if (gSubMenuSelection == 0)
|
if (gSubMenuSelection == 0)
|
||||||
sprintf(top_right_badge, "00/00");
|
sprintf(top_right_badge, "00/00");
|
||||||
else if (approved_index != 0xFF)
|
else if (approved_index != 0xFF)
|
||||||
sprintf(top_right_badge, "%02u/%02u", (unsigned)gSubMenuSelection, (unsigned)approved_index + 1);
|
sprintf(top_right_badge, "%02u/%02u", (unsigned)gSubMenuSelection, (unsigned)approved_index + 1);
|
||||||
else
|
else
|
||||||
sprintf(top_right_badge, "%02u/--", (unsigned)gSubMenuSelection);
|
sprintf(top_right_badge, "%02u/--", (unsigned)gSubMenuSelection);
|
||||||
} else if (UI_MENU_GetCurrentMenuId() == MENU_R_DCS ||
|
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_T_DCS) {
|
|
||||||
const bool is_normal_dcs =
|
|
||||||
gSubMenuSelection > 0 && gSubMenuSelection <= ARRAY_SIZE(DCS_Options);
|
|
||||||
const uint8_t approved_index =
|
|
||||||
is_normal_dcs ? DCS_GetDcsApprovedIndex(gSubMenuSelection - 1) : 0xFF;
|
|
||||||
|
|
||||||
if (gSubMenuSelection == 0)
|
|
||||||
sprintf(top_right_badge, "000/000");
|
|
||||||
else if (approved_index != 0xFF)
|
|
||||||
sprintf(top_right_badge, "%03u/%03u", (unsigned)gSubMenuSelection, (unsigned)approved_index + 1);
|
|
||||||
else
|
|
||||||
sprintf(top_right_badge, "%03u/---", (unsigned)gSubMenuSelection);
|
|
||||||
} else {
|
|
||||||
sprintf(top_right_badge, "%03d", gSubMenuSelection);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m == MENU_R_DCS ||
|
||||||
|
m == MENU_T_DCS) {
|
||||||
|
const uint8_t approved_index =
|
||||||
|
(gSubMenuSelection > 0) ? DCS_GetDcsApprovedIndex(gSubMenuSelection - 1) : 0xFF;
|
||||||
|
|
||||||
|
if (gSubMenuSelection == 0)
|
||||||
|
sprintf(top_right_badge, "000/000");
|
||||||
|
else if (approved_index != 0xFF)
|
||||||
|
sprintf(top_right_badge, "%03u/%03u", (unsigned)gSubMenuSelection, (unsigned)approved_index + 39);
|
||||||
|
else
|
||||||
|
sprintf(top_right_badge, "%03u/---", (unsigned)gSubMenuSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_DTMF_CALLING
|
||||||
|
if (m == MENU_D_LIST) {
|
||||||
|
sprintf(top_right_badge, "%03d", gSubMenuSelection);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (top_right_badge[0] != '\0') {
|
if (top_right_badge[0] != '\0') {
|
||||||
UI_MENU_DrawTopRightRoundedBadge(top_right_badge, 1, true, menu_item_x1, menu_item_x2);
|
UI_MENU_DrawTopRightRoundedBadge(top_right_badge, 1, true, menu_item_x1, menu_item_x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((UI_MENU_GetCurrentMenuId() == MENU_RESET ||
|
if ((m == MENU_RESET ||
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_MEM_CH ||
|
m == MENU_MEM_CH ||
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME ||
|
m == MENU_MEM_NAME ||
|
||||||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation)
|
m == MENU_DEL_CH) && gAskForConfirmation)
|
||||||
{ // display confirmation
|
{ // display confirmation
|
||||||
char *pPrintStr = (gAskForConfirmation == 1) ? "SURE?" : "WAIT!";
|
char *pPrintStr = (gAskForConfirmation == 1) ? "SURE?" : "WAIT!";
|
||||||
UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 5, 8);
|
UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 5, 8);
|
||||||
|
|||||||
Reference in new issue
Block a user