diff --git a/Makefile b/Makefile index ceeeef5..50efe3b 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ ENABLE_AUDIO_BAR_DEFAULT ?=0 ENABLE_EEPROM_4M ?=1 ENABLE_CHINESE_FULL = 4 ENABLE_DOCK = 1 +ENABLE_CUSTOM_SIDEFUNCTIONS ?= 1 +ENABLE_SIDEFUNCTIONS_SEND ?= 0 # ---- DEBUGGING ---- ENABLE_AM_FIX_SHOW_DATA ?= 0 @@ -302,6 +304,15 @@ ifeq ($(ENABLE_DOCK),1) CFLAGS += -DENABLE_DOCK endif +ifeq ($(ENABLE_CHINESE_FULL),4) +ifeq ($(ENABLE_CUSTOM_SIDEFUNCTIONS),1) + CFLAGS += -DENABLE_CUSTOM_SIDEFUNCTIONS +endif +ifeq ($(ENABLE_SIDEFUNCTIONS_SEND),1) + CFLAGS += -DENABLE_SIDEFUNCTIONS_SEND +endif +endif + ifeq ($(ENABLE_TIMER),1) CFLAGS += -DENABLE_TIMER endif diff --git a/README.md b/README.md index 604f250..ca248a7 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ ENABLE_AGC_SHOW_DATA := 0 显示ACG参数 ENABLE_AUDIO_BAR_DEFAULT ?=0 默认语音条样式 ENABLE_EEPROM_4M ?=1 两个2Mb Eeprom堆叠方案 ENABLE_CHINESE_FULL =4 编译固件版本选项 +ENABLE_CUSTOM_SIDEFUNCTIONS ?= 1 自定义侧键功能(仅扩容设备支持) +ENABLE_SIDEFUNCTIONS_SEND ?= 0 自定义侧键功能(侧键发射功能) ``` # 打赏 diff --git a/app/action.c b/app/action.c index 6b36c08..8701b05 100644 --- a/app/action.c +++ b/app/action.c @@ -100,7 +100,10 @@ void (*action_opt_table[])(void) = { [ACTION_OPT_D_DCD] = &ACTION_D_DCD, [ACTION_OPT_WIDTH] = &ACTION_WIDTH, - +#ifdef ENABLE_SIDEFUNCTIONS_SEND + [ACTION_OPT_SEND_A] = &ACTION_SEND_A, + [ACTION_OPT_SEND_B] = &ACTION_SEND_B +#endif }; static_assert(ARRAY_SIZE(action_opt_table) == ACTION_OPT_LEN); @@ -276,6 +279,24 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) enum ACTION_OPT_t funcShort = ACTION_OPT_NONE; enum ACTION_OPT_t funcLong = ACTION_OPT_NONE; + +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + switch(Key) { + 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; + funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION; + break; + case KEY_MENU: + funcLong = gEeprom.KEY_M_LONG_PRESS_ACTION; + break; + default: + break; + } +#else switch(Key) { case KEY_SIDE1: funcShort = ACTION_OPT_MONITOR;//gEeprom.KEY_1_SHORT_PRESS_ACTION; @@ -291,6 +312,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) default: break; } +#endif if (!bKeyHeld && bKeyPressed) // button pushed { @@ -305,6 +327,16 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (bKeyHeld || bKeyPressed) // held { funcShort = funcLong; + +#ifdef ENABLE_SIDEFUNCTIONS_SEND + if(funcShort == ACTION_OPT_SEND_A || funcShort == ACTION_OPT_SEND_B){ + gFlagLastVfo = gEeprom.TX_VFO; + gEeprom.TX_VFO = funcShort == ACTION_OPT_SEND_A ? 0 : 1; + gFlagReconfigureVfos = true; + gFlagStopTX = true; + GENERIC_Key_PTT(bKeyPressed); + } +#endif if (!bKeyPressed) //ignore release if held return; @@ -527,3 +559,8 @@ void ACTION_D_DCD(void) gTxVfo->DTMF_DECODING_ENABLE = !gTxVfo->DTMF_DECODING_ENABLE; DTMF_clear_RX(); } + +#ifdef ENABLE_SIDEFUNCTIONS_SEND +void ACTION_SEND_A(void){return;} +void ACTION_SEND_B(void){return;} +#endif \ No newline at end of file diff --git a/app/action.h b/app/action.h index 01417b3..07819fb 100644 --- a/app/action.h +++ b/app/action.h @@ -43,5 +43,9 @@ void ACTION_WIDTH(void); void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); +#ifdef ENABLE_SIDEFUNCTIONS_SEND +void ACTION_SEND_A(void); +void ACTION_SEND_B(void); +#endif #endif diff --git a/app/app.c b/app/app.c index ce4b3bc..a745942 100644 --- a/app/app.c +++ b/app/app.c @@ -1594,6 +1594,19 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) GUI_SelectNextDisplay(DISPLAY_MAIN); } + +#ifdef ENABLE_SIDEFUNCTIONS_SEND + if (gFlagStopTX) + { + gFlagStopTX = false; + RADIO_SetupRegisters(true); + GUI_SelectNextDisplay(DISPLAY_MAIN); + gEeprom.TX_VFO = gFlagLastVfo; + gFlagReconfigureVfos = true; + gUpdateDisplay = true; + return; + } +#endif } else // key pressed or held { diff --git a/app/menu.c b/app/menu.c index 1eda5de..5776014 100644 --- a/app/menu.c +++ b/app/menu.c @@ -364,14 +364,16 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) { *pMax = 1; break; -// case MENU_F1SHRT: -// case MENU_F1LONG: -// case MENU_F2SHRT: -// case MENU_F2LONG: -// case MENU_MLONG: -// *pMin = 0; -// *pMax = gSubMenu_SIDEFUNCTIONS_size-1; -// break; +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + case MENU_F1SHRT: + case MENU_F1LONG: + case MENU_F2SHRT: + case MENU_F2LONG: + case MENU_MLONG: + *pMin = 0; + *pMax = gSubMenu_SIDEFUNCTIONS_size-1; + break; +#endif default: return -1; @@ -802,21 +804,23 @@ void MENU_AcceptSetting(void) { gEeprom.BATTERY_TYPE = gSubMenuSelection; 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}; -// *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id; -// } -// 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}; + *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id; + } + break; +#endif } @@ -1156,29 +1160,31 @@ void MENU_ShowCurrentSetting(void) { gSubMenuSelection = gEeprom.BATTERY_TYPE; 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; -// } +#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; + } + + } + break; + } +#endif default: return; diff --git a/chinese.h b/chinese.h index 1edacbb..1aa2b5c 100644 --- a/chinese.h +++ b/chinese.h @@ -277,5 +277,28 @@ #define 图片 "\x86\x4C\x80\x92" #define 信息 "\x89\x89\x8C\x8C" +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS +#define 侧键一短按 "\x86\x80\x94\x8E\x80\x01\x92\x23\x88\x24" +#define 侧键一长按 "\x86\x80\x94\x8E\x80\x01\x80\x8E\x88\x24" +#define 侧键二短按 "\x86\x80\x94\x8E\x80\x03\x92\x23\x88\x24" +#define 侧键二长按 "\x86\x80\x94\x8E\x80\x03\x80\x8E\x88\x24" +#define M键长按 "\x4D\x94\x8E\x80\x8E\x88\x24" +#define 手电筒 "\x80\x86\x81\x1C\x92\x44" +#define 设置发射功率 "\x82\xCB\x94\x6D\x81\x9A\x8C\x89\x80\xEA\x8F\xEC" +#define 监听 "\x8B\xCE\x83\xD3" +#define 声控发射 "\x83\x45\x8E\x29\x81\x9A\x8C\x89" +#define FM收音机 "\x46\x4D\x82\xDD\x8A\x01\x81\xD9" +#define 锁定按键 "\x92\x0C\x87\x56\x88\x24\x94\x8E" +#define 切换信道 "\x80\x7A\x8B\x2F\x89\x89\x92\xC8" +#define 频率信道模式 "\x94\x10\x8F\xEC\x2F\x89\x89\x92\xC8\x95\xE1\x81\xAA" +#define 切换调制模式 "\x80\x7A\x8B\x2F\x8D\xA0\x86\x58\x95\xE1\x81\xAA" +#define DTMF解码 "\x44\x54\x4D\x46\x94\xEA\x85\xCF" +#define 切换宽窄带 "\x80\x7A\x8B\x2F\x8D\x75\x8D\x7D\x88\x3B" +#ifdef ENABLE_SIDEFUNCTIONS_SEND +#define 主频率发射 "\x81\x64\x94\x10\x8F\xEC\x81\x9A\x8C\x89" +#define 次频率发射 "\x82\x96\x94\x10\x8F\xEC\x81\x9A\x8C\x89" +#endif +#endif + #endif #endif //UV_K5_FIRMWARE_CUSTOM_0_17_CHINESE_H diff --git a/misc.c b/misc.c index 5153683..e694155 100644 --- a/misc.c +++ b/misc.c @@ -179,6 +179,10 @@ bool gFlagPrepareTX; bool gFlagAcceptSetting; bool gFlagRefreshSetting; +#ifdef ENABLE_SIDEFUNCTIONS_SEND +bool gFlagStopTX; +bool gFlagLastVfo; +#endif bool gFlagSaveVfo; bool gFlagSaveSettings; bool gFlagSaveChannel; diff --git a/misc.h b/misc.h index 0f100de..d40f323 100644 --- a/misc.h +++ b/misc.h @@ -259,6 +259,10 @@ extern bool gFlagPrepareTX; extern bool gFlagAcceptSetting; // accept menu setting extern bool gFlagRefreshSetting; // refresh menu display +#ifdef ENABLE_SIDEFUNCTIONS_SEND +extern bool gFlagStopTX; +extern bool gFlagLastVfo; +#endif extern bool gFlagSaveVfo; extern bool gFlagSaveSettings; extern bool gFlagSaveChannel; diff --git a/settings.c b/settings.c index 563a1f9..1ed80ce 100644 --- a/settings.c +++ b/settings.c @@ -123,6 +123,17 @@ void SETTINGS_InitEEPROM(void) #if ENABLE_CHINESE_FULL==4 gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_NONE; #endif + +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + // 1FF8..1FFF + EEPROM_ReadBuffer(0x1FF8, Data, 8); + gEeprom.KEY_M_LONG_PRESS_ACTION = (Data[0] < ACTION_OPT_LEN) ? Data[0] : ACTION_OPT_SWITCH_DEMODUL; + gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR; + gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_D_DCD; + gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_WIDTH; + gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_FLASHLIGHT; +#endif + // 0E98..0E9F EEPROM_ReadBuffer(0x0E98, Data, 8); memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4); @@ -543,6 +554,18 @@ void SETTINGS_SaveSettings(void) #endif EEPROM_WriteBuffer(0x0E90, State,8); +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + State[0] = gEeprom.KEY_M_LONG_PRESS_ACTION; + State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION; + State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION; + State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION; + State[4] = gEeprom.KEY_2_LONG_PRESS_ACTION; + State[5] = 0; + State[6] = 0; + State[7] = 0; + EEPROM_WriteBuffer(0x1FF8, State, 8); +#endif + memset(Password, 0xFF, sizeof(Password)); #ifdef ENABLE_PWRON_PASSWORD Password[0] = gEeprom.POWER_ON_PASSWORD; diff --git a/settings.h b/settings.h index 4bdacbf..c5b3908 100644 --- a/settings.h +++ b/settings.h @@ -94,8 +94,13 @@ enum ACTION_OPT_t { ACTION_OPT_BLMIN_TMP_OFF, //BackLight Minimum Temporay OFF ACTION_OPT_D_DCD, ACTION_OPT_WIDTH, +#ifdef ENABLE_SIDEFUNCTIONS_SEND + ACTION_OPT_SEND_A, + ACTION_OPT_SEND_B, +#endif ACTION_OPT_LEN }; + #ifdef ENABLE_VOICE enum VOICE_Prompt_t { @@ -196,10 +201,12 @@ typedef struct { #endif ROGER_Mode_t ROGER; uint8_t REPEATER_TAIL_TONE_ELIMINATION; -// uint8_t KEY_1_SHORT_PRESS_ACTION; -// uint8_t KEY_1_LONG_PRESS_ACTION; -// uint8_t KEY_2_SHORT_PRESS_ACTION; -// uint8_t KEY_2_LONG_PRESS_ACTION; +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + uint8_t KEY_1_SHORT_PRESS_ACTION; + uint8_t KEY_1_LONG_PRESS_ACTION; + uint8_t KEY_2_SHORT_PRESS_ACTION; + uint8_t KEY_2_LONG_PRESS_ACTION; +#endif uint8_t MIC_SENSITIVITY; uint8_t MIC_SENSITIVITY_TUNING; uint8_t CHAN_1_CALL; @@ -249,7 +256,9 @@ typedef struct { uint8_t field78_0x96; uint8_t field79_0x97; -// uint8_t KEY_M_LONG_PRESS_ACTION; +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + uint8_t KEY_M_LONG_PRESS_ACTION; +#endif // uint8_t BACKLIGHT_MIN; #ifdef ENABLE_BLMIN_TMP_OFF BLMIN_STAT_t BACKLIGHT_MIN_STAT; diff --git a/ui/menu.c b/ui/menu.c index a7d91fa..a346708 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -85,6 +85,14 @@ const t_menu_item MenuList[] = {/*"RP STE",*/ VOICE_ID_INVALID, MENU_RP_STE, 过中继尾音消除}, {/*"1 Call",*/ VOICE_ID_INVALID, MENU_1_CALL, 按键即呼}, +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + {/*"F1Shrt",*/ VOICE_ID_INVALID, MENU_F1SHRT ,侧键一短按}, + {/*"F1Long",*/ VOICE_ID_INVALID, MENU_F1LONG ,侧键一长按}, + {/*"F2Shrt",*/ VOICE_ID_INVALID, MENU_F2SHRT ,侧键二短按}, + {/*"F2Long",*/ VOICE_ID_INVALID, MENU_F2LONG ,侧键二长按}, + {/*"M Long",*/ VOICE_ID_INVALID, MENU_MLONG ,M键长按}, +#endif + #ifdef ENABLE_DTMF_CALLING {/*"ANI ID",*/ VOICE_ID_ANI_CODE, MENU_ANI_ID ,DTMF_ID}, #endif @@ -420,6 +428,43 @@ const char gSubMenu_SCRAMBLER[][7] = "3500Hz" }; +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS +const t_sidefunction SIDEFUNCTIONS[] = + { + {关闭, ACTION_OPT_NONE}, + {手电筒, ACTION_OPT_FLASHLIGHT}, + {设置发射功率, ACTION_OPT_POWER}, + {监听, ACTION_OPT_MONITOR}, + {扫描, ACTION_OPT_SCAN}, +#ifdef ENABLE_VOX + {声控发射, ACTION_OPT_VOX}, +#endif +#ifdef ENABLE_ALARM + {"ALARM", ACTION_OPT_ALARM}, +#endif +#ifdef ENABLE_FMRADIO + {FM收音机, ACTION_OPT_FM}, +#endif +#ifdef ENABLE_TX1750 + {"1750HZ", ACTION_OPT_1750}, +#endif + {锁定按键, ACTION_OPT_KEYLOCK}, + {切换信道, ACTION_OPT_A_B}, + {频率信道模式, ACTION_OPT_VFO_MR}, + {切换调制模式, ACTION_OPT_SWITCH_DEMODUL}, + {DTMF解码, ACTION_OPT_D_DCD}, + {切换宽窄带, ACTION_OPT_WIDTH}, +#ifdef ENABLE_SIDEFUNCTIONS_SEND + {主频率发射, ACTION_OPT_SEND_A}, + {次频率发射, ACTION_OPT_SEND_B}, +#endif +#ifdef ENABLE_BLMIN_TMP_OFF + {"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF +#endif + }; +const t_sidefunction *gSubMenu_SIDEFUNCTIONS = SIDEFUNCTIONS; +const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS); +#endif bool gIsInSubMenu; uint8_t gMenuCursor; @@ -1008,13 +1053,15 @@ void UI_DisplayMenu(void) { break; -// case MENU_F1SHRT: -// case MENU_F1LONG: -// case MENU_F2SHRT: -// case MENU_F2LONG: -// case MENU_MLONG: -// strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name); -// break; +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + case MENU_F1SHRT: + case MENU_F1LONG: + case MENU_F2SHRT: + case MENU_F2LONG: + case MENU_MLONG: + strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name); + break; +#endif } diff --git a/ui/menu.h b/ui/menu.h index 880d39f..cbabb51 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -135,11 +135,13 @@ MENU_PONMSG, MENU_F_CALI, // reference xtal calibration #endif MENU_BATCAL, // battery voltage calibration -// MENU_F1SHRT, -// MENU_F1LONG, -// MENU_F2SHRT, -// MENU_F2LONG, - //MENU_MLONG, +#ifdef ENABLE_CUSTOM_SIDEFUNCTIONS + MENU_F1SHRT, + MENU_F1LONG, + MENU_F2SHRT, + MENU_F2LONG, + MENU_MLONG, +#endif MENU_BATTYP };