Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Keil-Project/CW训练器工程-自动键版本/FLASH/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef union



System_Setting_Info_TypeDef System_Setting_Info_default={"10",0,"BD4XUW",SendSpeed_Slow,5,};
System_Setting_Info_TypeDef System_Setting_Info_default={"10",0,"BD4XUW",SendSpeed_Slow,0x36,};
System_Setting_Info_TypeDef System_Setting_Info;

//// �������������ת����ʽ����
Expand All @@ -24,7 +24,16 @@ u8 MakeValid_SendSpeed(u8 data)

u8 MakeValid_Volume(u8 data)
{
return (data>=9) ? 5 : data ;
u8 speaker = data&0x0F;
if (speaker > 9) {
speaker = 6;
}
u8 ear_phone = data >> 4;
if (ear_phone > 9) {
ear_phone = 3;
}

return speaker + (ear_phone << 4);
}

void BSP_Flash_Read_Info(void)
Expand All @@ -38,14 +47,16 @@ void BSP_Flash_Read_Info(void)
}
// �������м��ز���
GLOBAL_SendSpeed = MakeValid_SendSpeed(System_Setting_Info.user_speed);
VolumeList_index = MakeValid_Volume(System_Setting_Info.user_volume);
u8 volume = MakeValid_Volume(System_Setting_Info.user_volume);
VolumeList_index[0] = volume&0x0F;
VolumeList_index[1] = volume>>4;
}

void Update_System_Setting(void)
{
// ���뵱ǰ����
System_Setting_Info.user_speed = GLOBAL_SendSpeed;
System_Setting_Info.user_volume = VolumeList_index;
System_Setting_Info.user_volume = VolumeList_index[0] + (VolumeList_index[1] << 4);
}
void BSP_Flash_Write_Info(void)
{
Expand Down
34 changes: 19 additions & 15 deletions Keil-Project/CW训练器工程-自动键版本/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@


// ������ֵ�б�
const float VolumeList[9]={0.0003,0.001,0.003,0.1,0.2,0.4,0.6,0.8,1};
const float VolumeList[2][10]={{0,0.01,0.03,0.05,0.1,0.2,0.4,0.6,0.8,1},{0,0.0003,0.001,0.003,0.01,0.02,0.04,0.06,0.08,0.1}};

// �����Ķ���־λ
u8 VolumeChange_Flag = 0;
// �����޸ı�־λ
Expand Down Expand Up @@ -58,11 +59,11 @@ void HardWare_Init(void)
TIM1_TASK_Init(1000-1,72-1);
delay_ms(10);
// Flash��д��ʼ��

BSP_Flash_Read_Info();
// DAC��ʼ��
DAC_MUSIC_Init();
// ���Ҳ����Լ���������
EarPhone_WAVE(WAV_DATA3,VolumeList[VolumeList_index]);
EarPhone_WAVE(WAV_DATA3,VolumeList[EarPhone_MODE_FLAG][VolumeList_index[EarPhone_MODE_FLAG]]);
VolumeModified_Flag = 1;
// ��ʼ�������������
srand((unsigned int)Battery_Voltage+TIM1->CNT);
Expand All @@ -77,7 +78,6 @@ int main( void )
HardWare_Init();

OLED_Refresh_Gram();
BSP_Flash_Read_Info();

{/*����ʱ���趨*/
switch(GLOBAL_SendSpeed)
Expand Down Expand Up @@ -112,7 +112,7 @@ int main( void )
//BSP_Flash_Write_Info();

{ // �޸�����������
EarPhone_WAVE(WAV_DATA3,VolumeList[VolumeList_index]);
EarPhone_WAVE(WAV_DATA3,VolumeList[EarPhone_MODE_FLAG][VolumeList_index[EarPhone_MODE_FLAG]]);
DAC_SetFreq(1000);
TIM_Cmd(TIM3, ENABLE);
AMP_SD = 0;
Expand All @@ -122,7 +122,7 @@ int main( void )
// �������
key_value = Button_Scan();
// ǿ�ƴ��ң�����û������
srand((unsigned int)Battery_Voltage+TIM1->CNT);
//srand((unsigned int)Battery_Voltage+TIM1->CNT);

if (key_value == BUTTON_DEC_PRES)//�л��ķ��ٶ�
{
Expand Down Expand Up @@ -210,9 +210,9 @@ int main( void )
if (VolumeModified_Flag == 0)
{
// ��������
EarPhone_WAVE(WAV_DATA3,VolumeList[VolumeList_index]);
EarPhone_WAVE(WAV_DATA3,VolumeList[EarPhone_MODE_FLAG][VolumeList_index[EarPhone_MODE_FLAG]]);
VolumeModified_Flag = 1;
UI_VolumeDisplay(VolumeList_index);
UI_VolumeDisplay(VolumeList_index[EarPhone_MODE_FLAG]);
OLED_Refresh_Gram();
TIM_Cmd(TIM3, ENABLE);
delay_ms(300);
Expand All @@ -223,13 +223,13 @@ int main( void )
{
if (DKEY_A == 0)//����+
{
VolumeList_index = (VolumeList_index >= 8)?8:VolumeList_index +1;
VolumeList_index[EarPhone_MODE_FLAG] = (VolumeList_index[EarPhone_MODE_FLAG] >= 9)?9:VolumeList_index[EarPhone_MODE_FLAG] +1;
VolumeChange_Flag = 1;
VolumeModified_Flag = 0;
}
else if (DKEY_B == 0)//����-
{
VolumeList_index = (VolumeList_index == 0)?0:VolumeList_index -1;
VolumeList_index[EarPhone_MODE_FLAG] = (VolumeList_index[EarPhone_MODE_FLAG] == 0)?0:VolumeList_index[EarPhone_MODE_FLAG] -1;
VolumeChange_Flag = 1;
VolumeModified_Flag = 0;
}
Expand Down Expand Up @@ -303,20 +303,24 @@ int main( void )
UI_EarPhoneCheck();
// �Զ�������
UI_AutoSaveSetting();
//���������Զ����� ���״ν���ִ�
//����/���������л
if ((EarphoneEnd_Voltage > 4050)&&(EarPhone_MODE_FLAG == 0))
{
EarPhone_MODE_FLAG = 1;
VolumeList_index = (VolumeList_index>2) ? 2 : VolumeList_index;
EarPhone_WAVE(WAV_DATA3,VolumeList[VolumeList_index]);
UI_VolumeDisplay(VolumeList_index);
EarPhone_WAVE(WAV_DATA3,VolumeList[EarPhone_MODE_FLAG][VolumeList_index[EarPhone_MODE_FLAG]]);
UI_VolumeDisplay(VolumeList_index[EarPhone_MODE_FLAG]);
OLED_Refresh_Gram();
delay_ms(250);
VolumeModified_Flag = 0;
}
else if (EarphoneEnd_Voltage < 4000)
else if ((EarphoneEnd_Voltage < 4000)&&(EarPhone_MODE_FLAG == 1))
{
EarPhone_MODE_FLAG = 0;
EarPhone_WAVE(WAV_DATA3,VolumeList[EarPhone_MODE_FLAG][VolumeList_index[EarPhone_MODE_FLAG]]);
UI_VolumeDisplay(VolumeList_index[EarPhone_MODE_FLAG]);
OLED_Refresh_Gram();
delay_ms(250);
VolumeModified_Flag = 0;
}
// �����Դ�
OLED_Refresh_Gram();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ u8 DIT_PRESS_GLOBAL = 0;
u8 DAH_PRESS_GLOBAL = 0;

// ��������
u8 VolumeList_index = 5;
u8 VolumeList_index[2] = {6,3};

u8 GLOBAL_SendSpeed = 1;
u8 GLOBAL_WorkMode = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern u8 GLOBAL_SendSpeed;
extern u8 GLOBAL_WorkMode;
extern u8 GLOBAL_FLAG_WORKING;
extern u8 GLOBAL_FLAG_NewLetter;
extern u8 VolumeList_index;
extern u8 VolumeList_index[2];
// ����ķ������ä��������ģʽȫ�ֱ���
extern char GLOBAL_CorrectLetter;
extern float GLOBAL_ratio_correct;
Expand Down
Loading