Skip to content

Commit

Permalink
Merge pull request #156 from nanhantianyi/fix
Browse files Browse the repository at this point in the history
New Feature: Add T Mode
  • Loading branch information
losehu authored Sep 15, 2024
2 parents 6c893e3 + 856b1d6 commit d73fe15
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 83 deletions.
2 changes: 1 addition & 1 deletion app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;

case KEY_8:
gTxVfo->FrequencyReverse = gTxVfo->FrequencyReverse == false;
gTxVfo->FrequencyReverse = ++gTxVfo->FrequencyReverse % 3;
gRequestSaveChannel = 1;
break;

Expand Down
88 changes: 43 additions & 45 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,9 @@ void MENU_ShowCurrentSetting(void) {
break;
#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS

case MENU_W_N:
gSubMenuSelection = gTxVfo->CHANNEL_BANDWIDTH;
break;
case MENU_W_N:
gSubMenuSelection = gTxVfo->CHANNEL_BANDWIDTH;
break;
#endif
case MENU_SCR:
gSubMenuSelection = gTxVfo->SCRAMBLING_TYPE;
Expand Down Expand Up @@ -1126,13 +1126,13 @@ void MENU_ShowCurrentSetting(void) {
gSubMenuSelection = gEeprom.DTMF_SIDE_TONE;
break;
#ifdef ENABLE_DTMF_CALLING
case MENU_D_RSP:
gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE;
break;
case MENU_D_RSP:
gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE;
break;

case MENU_D_HOLD:
gSubMenuSelection = gEeprom.DTMF_auto_reset_time;
break;
case MENU_D_HOLD:
gSubMenuSelection = gEeprom.DTMF_auto_reset_time;
break;
#endif
case MENU_D_PRE:
gSubMenuSelection = gEeprom.DTMF_PRELOAD_TIME / 10;
Expand All @@ -1148,21 +1148,21 @@ void MENU_ShowCurrentSetting(void) {
#ifdef ENABLE_DTMF_CALLING
#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS

case MENU_D_DCD:
gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE;
break;
case MENU_D_DCD:
gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE;
break;
#endif
case MENU_D_LIST:
gSubMenuSelection = gDTMF_chosen_contact + 1;
break;
case MENU_D_LIST:
gSubMenuSelection = gDTMF_chosen_contact + 1;
break;
#endif
case MENU_D_LIVE_DEC:
gSubMenuSelection = gSetting_live_DTMF_decoder;
break;
#if ENABLE_CHINESE_FULL == 4
case MENU_PONMSG:
gSubMenuSelection = gEeprom.POWER_ON_DISPLAY_MODE;
break;
case MENU_PONMSG:
gSubMenuSelection = gEeprom.POWER_ON_DISPLAY_MODE;
break;
#endif
case MENU_ROGER:
gSubMenuSelection = gEeprom.ROGER;
Expand All @@ -1173,9 +1173,9 @@ void MENU_ShowCurrentSetting(void) {
// break;

#ifdef ENABLE_AM_FIX
case MENU_AM_FIX:
gSubMenuSelection = gSetting_AM_fix;
break;
case MENU_AM_FIX:
gSubMenuSelection = gSetting_AM_fix;
break;
#endif

#ifdef ENABLE_AM_FIX_TEST1
Expand Down Expand Up @@ -1237,29 +1237,28 @@ void MENU_ShowCurrentSetting(void) {
break;

#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
case MENU_MLONG:
{
uint8_t * fun[]= {
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
&gEeprom.KEY_1_LONG_PRESS_ACTION,
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
&gEeprom.KEY_2_LONG_PRESS_ACTION,
&gEeprom.KEY_M_LONG_PRESS_ACTION};
uint8_t id = *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT];

for(int i = 0; i <gSubMenu_SIDEFUNCTIONS_size; i++) {
if(gSubMenu_SIDEFUNCTIONS[i].id==id) {
gSubMenuSelection = i;
break;
}

case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
case MENU_MLONG: {
uint8_t *fun[] = {
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
&gEeprom.KEY_1_LONG_PRESS_ACTION,
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
&gEeprom.KEY_2_LONG_PRESS_ACTION,
&gEeprom.KEY_M_LONG_PRESS_ACTION
};
uint8_t id = *fun[UI_MENU_GetCurrentMenuId() - MENU_F1SHRT];

for (int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) {
if (gSubMenu_SIDEFUNCTIONS[i].id == id) {
gSubMenuSelection = i;
break;
}
break;
}
break;
}
#endif

default:
Expand Down Expand Up @@ -1613,8 +1612,7 @@ void UPDATE_CHN()
{
uint8_t tmp[5];

EEPROM_ReadBuffer(
PINYIN_NOW_INDEX * 128 + 0X20000 + 16 + PINYIN_NUM_SELECT * 16 + 6, tmp, 5);
EEPROM_ReadBuffer(PINYIN_NOW_INDEX * 128 + 0X20000 + 16 + PINYIN_NUM_SELECT * 16 + 6, tmp, 5);
CHN_NOW_ADD = tmp[1] | tmp[2] << 8 | tmp[3] << 16 | tmp[4] << 24;
CHN_NOW_NUM = tmp[0];
CHN_NOW_PAGE = 0;
Expand Down Expand Up @@ -1957,7 +1955,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
#ifdef ENABLE_MDC1200
#ifdef ENABLE_MDC1200_EDIT
else if (UI_MENU_GetCurrentMenuId() == MENU_MDC_ID) {
if (UI_MENU_GetCurrentMenuId() == MENU_MDC_ID) {
if (bKeyPressed && edit_index < 4) {
char c = edit[edit_index] + Direction;
if (c < '0')c = 'F';
Expand Down
2 changes: 1 addition & 1 deletion app/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static void CMD_052F(const uint8_t *pBuffer) {
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gEeprom.RX_VFO = 0;
gEeprom.DTMF_SIDE_TONE = false;
gEeprom.VfoInfo[0].FrequencyReverse = false;
gEeprom.VfoInfo[0].FrequencyReverse = 0;
gEeprom.VfoInfo[0].pRX = &gEeprom.VfoInfo[0].freq_config_RX;
gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX;
gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
Expand Down
13 changes: 8 additions & 5 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
pInfo->STEP_SETTING = STEP_12_5kHz;
pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING];
pInfo->CHANNEL_SAVE = ChannelSave;
pInfo->FrequencyReverse = false;
pInfo->FrequencyReverse = 0;
pInfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
pInfo->freq_config_RX.Frequency = Frequency;
pInfo->freq_config_TX.Frequency = Frequency;
Expand Down Expand Up @@ -292,13 +292,13 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
pVfo->freq_config_TX.Code = tmp;

if (data[4] == 0xFF) {
pVfo->FrequencyReverse = false;
pVfo->FrequencyReverse = 0;
pVfo->CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE;
pVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
pVfo->BUSY_CHANNEL_LOCK = false;
} else {
const uint8_t d4 = data[4];
pVfo->FrequencyReverse = !!((d4 >> 0) & 1u);
pVfo->FrequencyReverse = d4 >> 5 & 1u ? d4 >> 6 & 3u : d4 & 1u;
pVfo->CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u);
pVfo->OUTPUT_POWER = ((d4 >> 2) & 3u);
pVfo->BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u);
Expand Down Expand Up @@ -363,12 +363,15 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
SETTINGS_FetchChannelName(pVfo->Name, channel);
}

if (!pVfo->FrequencyReverse) {
if (pVfo->FrequencyReverse == 0) {
pVfo->pRX = &pVfo->freq_config_RX;
pVfo->pTX = &pVfo->freq_config_TX;
} else {
} else if (pVfo->FrequencyReverse == 1) {
pVfo->pRX = &pVfo->freq_config_TX;
pVfo->pTX = &pVfo->freq_config_RX;
} else {
pVfo->pRX = &pVfo->freq_config_RX;
pVfo->pTX = &pVfo->freq_config_RX;
}

// if (!gSetting_350EN)
Expand Down
2 changes: 1 addition & 1 deletion radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ typedef struct VFO_Info_t
STEP_Setting_t STEP_SETTING;
uint8_t OUTPUT_POWER;
uint8_t TXP_CalculatedSetting;
bool FrequencyReverse;
uint8_t FrequencyReverse;

uint8_t SCRAMBLING_TYPE;
uint8_t CHANNEL_BANDWIDTH;
Expand Down
4 changes: 3 additions & 1 deletion settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
| (pVFO->BUSY_CHANNEL_LOCK << 4)
| (pVFO->OUTPUT_POWER << 2)
| (pVFO->CHANNEL_BANDWIDTH << 1)
| (pVFO->FrequencyReverse << 0);
| (pVFO->FrequencyReverse & 1u)
| (1u << 5)
| (pVFO->FrequencyReverse << 6);
State._8[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1)
#ifdef ENABLE_DTMF_CALLING
| ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0)
Expand Down
7 changes: 4 additions & 3 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,13 +817,14 @@ void UI_DisplayMain(void) {

// show the TX/RX reverse symbol
if (vfoInfo->FrequencyReverse) {
char *flag = vfoInfo->FrequencyReverse == 1 ? "R" : "T";
#if ENABLE_CHINESE_FULL != 4 || defined(ENABLE_ENGLISH)
UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1);//中文信道1
UI_PrintStringSmall(flag, LCD_WIDTH + 62, 0, line + 1);//中文信道1
#else
if (bFlagMr)
UI_PrintStringSmall("R", LCD_WIDTH + 24, 0, line - 1); //中文信道1
UI_PrintStringSmall(flag, LCD_WIDTH + 24, 0, line - 1); //中文信道1
else if (bFlagFreq)
UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1); //中文信道1
UI_PrintStringSmall(flag, LCD_WIDTH + 62, 0, line + 1); //中文信道1

#endif
}
Expand Down
52 changes: 26 additions & 26 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,12 @@ void UI_DisplayMenu(void) {
#endif

#ifdef ENABLE_PINYIN //拼音取消显示
if (!(UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && gIsInSubMenu && edit_index >= 0))
const bool isInPinyin = UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0;
if (!isInPinyin)
#endif
UI_PrintStringSmall(String, 2, 0, 6);
#ifdef ENABLE_PINYIN//拼音取消显示
if (!(UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0))
if (!isInPinyin)
#endif


Expand Down Expand Up @@ -921,34 +922,33 @@ void UI_DisplayMenu(void) {
break;
}
#ifdef ENABLE_MDC1200
case MENU_MDC_ID:
{
case MENU_MDC_ID: {
#ifdef ENABLE_MDC1200_EDIT
if(gIsInSubMenu){ // show the channel name being edited
UI_PrintStringSmall(edit, menu_item_x1, menu_item_x2, 3);
if (edit_index < 4)
UI_PrintStringSmall("^", menu_item_x1+(((menu_item_x2 - menu_item_x1) - (28)) + 1) / 2 + (7 * edit_index), 0, 4); // show the cursor
}else
{
if (gIsInSubMenu) {
// show the channel name being edited
UI_PrintStringSmall(edit, menu_item_x1, menu_item_x2, 3);
if (edit_index < 4)
UI_PrintStringSmall("^", menu_item_x1 + (((menu_item_x2 - menu_item_x1) - (28)) + 1) / 2 + (7 * edit_index), 0, 4); // show the cursor
} else {
#endif
sprintf(String, "%04X", gEeprom.MDC1200_ID); // %04X确保输出是4个字符长度的十六进制数
UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 3);//4
sprintf(String, "%04X", gEeprom.MDC1200_ID); // %04X确保输出是4个字符长度的十六进制数
UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 3); //4

#ifdef ENABLE_MDC1200_EDIT

edit_index = -1;
edit[0]=String[0];
edit[1]=String[1];
edit[2]=String[2];
edit[3]=String[3];
edit[4]='\0';
edit_index = -1;
edit[0] = String[0];
edit[1] = String[1];
edit[2] = String[2];
edit[3] = String[3];
edit[4] = '\0';
#endif
#ifdef ENABLE_MDC1200_EDIT
}
#endif
already_printed = true;
break;
}
#endif
already_printed = true;
break;
}
#endif
case MENU_MEM_NAME: { //输入法显示
//ok
Expand Down Expand Up @@ -1069,7 +1069,7 @@ void UI_DisplayMenu(void) {
// show_uint32(HAVE_PINYIN,1);
for (int j = 0; j < HAVE_PINYIN; ++j) {
EEPROM_ReadBuffer(
PINYIN_NOW_INDEX * 128 + 0X20000 + 16 + PINYIN_NUM_SELECT / 3 * 3 * 16 +
PINYIN_NOW_INDEX * 128 + 0X20000 + 16 + num * 3 * 16 +
j * 16, tmp, 6);
memcpy(&String[6 * j], tmp, 6);//0 1 2 3 4 5
}
Expand Down Expand Up @@ -1135,7 +1135,7 @@ void UI_DisplayMenu(void) {
tmp[0] ='5', tmp[4] = '6', tmp[8] = '7', tmp[12] = '8';
tmp[2] -= 32, tmp[6] -= 32, tmp[10] -= 32, tmp[14] -= 32;
}
UI_PrintStringSmall(tmp, 0, 127, 1);
UI_PrintStringSmall(tmp, 0, 127, 1);

}
}
Expand Down Expand Up @@ -1518,8 +1518,8 @@ void UI_DisplayMenu(void) {
#endif
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation) { // display confirmation
char *pPrintStr = (gAskForConfirmation == 1) ? "SURE?" : "WAIT!";
if ((UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME ||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation)
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME ||
UI_MENU_GetCurrentMenuId() == MENU_DEL_CH)
UI_PrintStringSmall(pPrintStr, menu_item_x1 - 12, menu_item_x2, 5);
else UI_PrintStringSmall(pPrintStr, menu_item_x1, menu_item_x2, 5);

Expand Down

0 comments on commit d73fe15

Please sign in to comment.