diff --git a/app/action.c b/app/action.c index 3c4a1df..159a18a 100644 --- a/app/action.c +++ b/app/action.c @@ -288,6 +288,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { case KEY_SIDE1: funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION; funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION; + break; case KEY_SIDE2: funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION; diff --git a/app/app.c b/app/app.c index 1f2a9cd..7a32151 100644 --- a/app/app.c +++ b/app/app.c @@ -1547,6 +1547,7 @@ if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_TX1750) { static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { + if (Key == KEY_EXIT && !BACKLIGHT_IsOn() && gEeprom.BACKLIGHT_TIME > 0) { // just turn the light on for now so the user can see what's what BACKLIGHT_TurnOn(); diff --git a/app/mdc1200.c b/app/mdc1200.c index ad5bad0..5eeedcc 100644 --- a/app/mdc1200.c +++ b/app/mdc1200.c @@ -6,10 +6,10 @@ #include "misc.h" #include #include "driver/eeprom.h" +#include "settings.h" char ham[7]={0}; uint8_t ham_flag=0; -uint8_t new_mdc_switch = 1; const uint8_t mdc1200_pre_amble[] = {0x00, 0x00, 0x00}; const uint8_t mdc1200_sync[5] = {0x07, 0x09, 0x2a, 0x44, 0x6f}; @@ -262,10 +262,10 @@ unsigned int MDC1200_encode_single_packet(void *data, const uint8_t op, const ui memcpy(p, mdc1200_sync, sizeof(mdc1200_sync)); p += sizeof(mdc1200_sync); - if (new_mdc_switch) { - char name[6] = {'B', 'G', '2', 'F', 'Z', 'V'}; - uint32_t code = HamToCode(name); - p[0] = code >> 24; + if (gEeprom.HAM_SWITCH) { + //char name[6] = {'B', 'G', '2', 'F', 'Z', 'V'}; + uint32_t code = gEeprom.HAM_ID;// HamToCode(name) + p[0] = (code >> 24)|0xa0; p[1] = 0xff & (code >> 16); p[2] = 0xff & (code >> 8); p[3] = 0xff & (code); @@ -275,7 +275,6 @@ unsigned int MDC1200_encode_single_packet(void *data, const uint8_t op, const ui p[2] = (unit_id >> 8) & 0x00ff; p[3] = (unit_id >> 0) & 0x00ff; } - new_mdc_switch=1-new_mdc_switch; crc = compute_crc(p, 4); p[4] = (crc >> 0) & 0x00ff; p[5] = (crc >> 8) & 0x00ff; @@ -444,7 +443,6 @@ uint16_t extractHex(const char *str) { char c = *str++; if (c >= '0' && c <= '9') { result = (result << 4) | (c - '0'); - } else if (c >= 'A' && c <= 'F') { result = (result << 4) | (c - 'A' + 10); } else { diff --git a/app/mdc1200.h b/app/mdc1200.h index 7a0e3c7..9c64153 100644 --- a/app/mdc1200.h +++ b/app/mdc1200.h @@ -120,5 +120,6 @@ uint16_t extractHex(const char *str); extern uint8_t contact_num; extern char ham[7]; extern uint8_t ham_flag; +void CodeToHam(char *ham, uint32_t code) ; #endif diff --git a/app/menu.c b/app/menu.c index da686b6..9843311 100644 --- a/app/menu.c +++ b/app/menu.c @@ -115,16 +115,16 @@ void PINYIN_SOLVE(uint32_t tmp) { } if (INPUT_STAGE) { - //需要选拼音 + //锟斤拷要选拼锟斤拷 if (PINYIN_SEARCH_FOUND) { if (PINYIN_SEARCH_INDEX != 255) { - //确实存在这个拼音组合 + //确实锟斤拷锟斤拷锟斤拷锟狡达拷锟斤拷锟斤拷 PINYIN_NOW_INDEX = PINYIN_SEARCH_INDEX; PINYIN_NOW_NUM = PINYIN_SEARCH_NUM; PINYIN_SEARCH_MODE = 1; } } else { - //没有这个拼音组合但是有备选 + //没锟斤拷锟斤拷锟狡达拷锟斤拷锟较碉拷锟斤拷锟叫憋拷选 // PINYIN_SEARCH_MODE = 2; // PINYIN_NOW_INDEX = PINYIN_SEARCH_INDEX; // PINYIN_NOW_NUM = PINYIN_SEARCH_NUM; @@ -582,7 +582,7 @@ void MENU_AcceptSetting(void) { return; #endif - case MENU_MEM_NAME: //输入法 + case MENU_MEM_NAME: //锟斤拷锟诫法 // trailing trim for (int i = MAX_EDIT_INDEX - 1; i >= 0; i--) { if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0x00 && edit[i] != 0xff) @@ -1277,12 +1277,12 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; uint8_t now_menu = UI_MENU_GetCurrentMenuId(); -#ifdef ENABLE_MDC1200_EDIT //输入法数字 +#ifdef ENABLE_MDC1200_EDIT //锟斤拷锟诫法锟斤拷锟斤拷 uint8_t end_index = now_menu == MENU_MEM_NAME ? MAX_EDIT_INDEX : 4; #else uint8_t end_index = MAX_EDIT_INDEX; #endif - if ((now_menu == MENU_MEM_NAME //输入法 + if ((now_menu == MENU_MEM_NAME //锟斤拷锟诫法 #ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200_EDIT || now_menu == MENU_MDC_ID @@ -1302,7 +1302,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { #endif #endif if (INPUT_MODE == 0) { - //拼音输入 + //拼锟斤拷锟斤拷锟斤拷 if (Key >= 2 && PINYIN_CODE_INDEX && INPUT_STAGE <= 1) { uint32_t tmp = PINYIN_CODE; PINYIN_CODE += Key * PINYIN_CODE_INDEX; @@ -1333,12 +1333,12 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { } } else if (INPUT_MODE == 1) { if (INPUT_STAGE == 0) { - if (Key >= KEY_2) { //选择字母按键 + if (Key >= KEY_2) { //选锟斤拷锟斤拷母锟斤拷锟斤拷 INPUT_STAGE = 1; INPUT_SELECT = Key; } } else { - if (Key >= 1 && Key <= 2 *num_size[INPUT_SELECT - 2]) {//选择字母 + if (Key >= 1 && Key <= 2 *num_size[INPUT_SELECT - 2]) {//选锟斤拷锟斤拷母 if (edit_chn[edit_index] == 1) edit[edit_index+1] = '_'; if (Key > num_size[INPUT_SELECT - 2]) edit[edit_index] = num_excel[INPUT_SELECT - 2][Key - 1 - num_size[INPUT_SELECT - 2]] - 32; @@ -1559,7 +1559,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { } #ifdef ENABLE_PINYIN -// if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gAskForConfirmation == 0) { //输入法exit +// if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gAskForConfirmation == 0) { //锟斤拷锟诫法exit // // // } @@ -1631,7 +1631,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { #ifdef ENABLE_PINYIN if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { if (edit_index == -1) { - //输入法参数初始化menu + //锟斤拷锟诫法锟斤拷锟斤拷锟斤拷始锟斤拷menu INPUT_MODE = 0; INPUT_SELECT = 0; INPUT_STAGE = 0; @@ -1686,9 +1686,9 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { #ifdef ENABLE_DTMF_CALLING || UI_MENU_GetCurrentMenuId() == MENU_ANI_ID #endif - #ifndef ENABLE_MDC1200_EDIT - || UI_MENU_GetCurrentMenuId() == MENU_MDC_ID -#endif +// #ifndef ENABLE_MDC1200_EDIT +// || UI_MENU_GetCurrentMenuId() == MENU_MDC_ID +//#endif ) return; // invalid gAskForConfirmation = 0; @@ -1729,7 +1729,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { #endif #endif - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { //输入法MENU + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { //锟斤拷锟诫法MENU if (edit_index < 0) { // enter channel name edit mode if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) return; @@ -1769,7 +1769,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { gAskForConfirmation = 0; } } -#ifdef ENABLE_PINYIN //退出输入模式 +#ifdef ENABLE_PINYIN //锟剿筹拷锟斤拷锟斤拷模式 // PINYIN_MODE=0; #endif @@ -1840,7 +1840,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) { return; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; -//输入法星模式切换 +//锟斤拷锟诫法锟斤拷模式锟叫伙拷 if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) { // currently editing the channel name if (edit_index < MAX_EDIT_INDEX) { @@ -1851,7 +1851,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) { gAskForConfirmation = 1; } -#else //输入法星模式切换 +#else //锟斤拷锟诫法锟斤拷模式锟叫伙拷 INPUT_MODE++; if (INPUT_MODE >= 3)INPUT_MODE = 0; if (INPUT_MODE == 0 && edit_index + 1 >= MAX_EDIT_INDEX) @@ -1896,15 +1896,26 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) uint8_t VFO; uint8_t Channel; bool bCheckScanList; - if (gIsInSubMenu && edit_index >= 0) { //输入法UP DOWN +#ifdef ENABLE_MDC1200 + #ifndef ENABLE_MDC1200_EDIT + if (UI_MENU_GetCurrentMenuId() == MENU_MDC_ID) { + if (bKeyPressed) { + gEeprom.HAM_SWITCH = 1-gEeprom.HAM_SWITCH; + gRequestDisplayScreen = DISPLAY_MENU; + } + return; + } + #endif +#endif + if (gIsInSubMenu && edit_index >= 0) { //锟斤拷锟诫法UP DOWN if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { // change the character if (bKeyPressed && edit_index < MAX_EDIT_INDEX) { -#ifdef ENABLE_PINYIN//拼音上下 +#ifdef ENABLE_PINYIN//拼锟斤拷锟斤拷锟斤拷 if (INPUT_MODE == 0) { if (INPUT_STAGE == 2) { - if (PINYIN_SEARCH_MODE == 1)//准确的组合 + if (PINYIN_SEARCH_MODE == 1)//准确锟斤拷锟斤拷锟 { if (Direction == 1) { if (CHN_NOW_PAGE) CHN_NOW_PAGE--; @@ -1958,6 +1969,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) } return; } + #ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200_EDIT if (UI_MENU_GetCurrentMenuId() == MENU_MDC_ID) { @@ -1976,6 +1988,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) } return; } + #endif #endif @@ -2089,7 +2102,7 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { MENU_Key_STAR(bKeyPressed, bKeyHeld); break; case KEY_F: - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && //输入法 + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && //锟斤拷锟诫法 edit_index >= 0) { // currently editing the channel name if (!bKeyHeld && bKeyPressed) { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; diff --git a/main.c b/main.c index bb34b34..3133bbd 100644 --- a/main.c +++ b/main.c @@ -297,7 +297,6 @@ void Main(void) { #endif while (1) { - APP_Update(); if (gNextTimeslice) { diff --git a/settings.c b/settings.c index 36e7442..82eef6b 100644 --- a/settings.c +++ b/settings.c @@ -114,12 +114,11 @@ void SETTINGS_InitEEPROM(void) // 0E90..0E97 EEPROM_ReadBuffer(0x0E90, Data, 8); gEeprom.BEEP_CONTROL = Data[0] & 1; + gEeprom.MDC1200_ID =((uint16_t) (Data[2] << 8))|((uint16_t)(Data[1] )); + gEeprom.HAM_ID = ((uint32_t)(Data[3]<<16))|((uint32_t)(Data[4]<<8))|((uint32_t)Data[6])|((uint32_t)((Data[5]>>3))<<24); + gEeprom.HAM_SWITCH = (Data[5]>>2)&1; - gEeprom.MDC1200_ID =((uint16_t) (Data[2] << 8))|((uint16_t)(Data[1] )); -// gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT; -// gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; -// gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; - gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; + gEeprom.SCAN_RESUME_MODE = ((Data[5]&0x03) < 3) ? Data[5] : SCAN_RESUME_CO; // gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false; #if ENABLE_CHINESE_FULL==4 gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_NONE; @@ -547,12 +546,10 @@ void SETTINGS_SaveSettings(void) State[1]=(uint8_t)(gEeprom.MDC1200_ID&(0x00ff)); State[2]=(uint8_t)((gEeprom.MDC1200_ID&(0xff00))>>8); - // State[1] = 0;//gEeprom.KEY_1_SHORT_PRESS_ACTION; - // State[2] = 0;//gEeprom.KEY_1_LONG_PRESS_ACTION; - State[3] = 0;//gEeprom.KEY_2_SHORT_PRESS_ACTION; - State[4] = 0;//gEeprom.KEY_2_LONG_PRESS_ACTION; - State[5] = gEeprom.SCAN_RESUME_MODE; - State[6] = 0;//gEeprom.AUTO_KEYPAD_LOCK; + State[3] = 0xff&(gEeprom.HAM_ID>>16);//gEeprom.KEY_2_SHORT_PRESS_ACTION; + State[4] =0xff&(gEeprom.HAM_ID>>8) ;//gEeprom.KEY_2_LONG_PRESS_ACTION; + State[5] = gEeprom.SCAN_RESUME_MODE|( 0xff&(((gEeprom.HAM_ID>>24))<<3))|(gEeprom.HAM_SWITCH<<2);// + State[6] = 0xff&(gEeprom.HAM_ID);//gEeprom.AUTO_KEYPAD_LOCK; #if ENABLE_CHINESE_FULL==4 State[7] = gEeprom.POWER_ON_DISPLAY_MODE; #endif diff --git a/settings.h b/settings.h index 08536e3..50aff23 100644 --- a/settings.h +++ b/settings.h @@ -270,6 +270,9 @@ typedef struct { uint8_t S9_LEVEL; #endif uint32_t MDC1200_ID; + uint32_t HAM_ID; + uint8_t HAM_SWITCH; + } EEPROM_Config_t; extern EEPROM_Config_t gEeprom; diff --git a/ui/main.c b/ui/main.c index b374387..197e828 100644 --- a/ui/main.c +++ b/ui/main.c @@ -906,10 +906,7 @@ void UI_DisplayMain(void) { //#else // sprintf(String, "MDC1200 ID %04X", mdc1200_unit_id); //#endif - UI_PrintStringSmall(String, print_col, 0, 3); - - } else #endif diff --git a/ui/menu.c b/ui/menu.c index ce19c1b..dbc4f07 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -923,6 +923,10 @@ void UI_DisplayMenu(void) { } #ifdef ENABLE_MDC1200 case MENU_MDC_ID: { + sprintf(String, "%s", CodeToHam(String,gEeprom.HAM_ID)); // %04X纭繚杈撳嚭鏄4涓瓧绗﹂暱搴︾殑鍗佸叚杩涘埗鏁 + UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 5); + + #ifdef ENABLE_MDC1200_EDIT if (gIsInSubMenu) { // show the channel name being edited @@ -931,11 +935,10 @@ void UI_DisplayMenu(void) { 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 - #ifdef ENABLE_MDC1200_EDIT - edit_index = -1; edit[0] = String[0]; edit[1] = String[1]; @@ -946,6 +949,11 @@ void UI_DisplayMenu(void) { #ifdef ENABLE_MDC1200_EDIT } #endif + if (gEeprom.HAM_SWITCH==0) + UI_PrintStringSmall("MDC", 105, 127, 1); + else + UI_PrintStringSmall("HAM", 105, 127, 1); + already_printed = true; break; }