Skip to content

Commit

Permalink
KDC1200
Browse files Browse the repository at this point in the history
  • Loading branch information
losehu committed Nov 22, 2024
1 parent 1902f46 commit 7bd9940
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 46 deletions.
1 change: 1 addition & 0 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 5 additions & 7 deletions app/mdc1200.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "misc.h"
#include <string.h>
#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};

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions app/mdc1200.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
57 changes: 35 additions & 22 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
//
//
// }
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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--;
Expand Down Expand Up @@ -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) {
Expand All @@ -1976,6 +1988,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
return;
}

#endif
#endif

Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ void Main(void) {
#endif

while (1) {

APP_Update();

if (gNextTimeslice) {
Expand Down
19 changes: 8 additions & 11 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand All @@ -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;
}
Expand Down

0 comments on commit 7bd9940

Please sign in to comment.