单片机中按键模板_第1页
单片机中按键模板_第2页
单片机中按键模板_第3页
免费预览已结束,剩余21页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、单片机中按键模板void AMP_KEY_PROCESS(void)unsigned int xdata IN_CYCLE_TIME=0;unsigned int xdata OUT_CYCLE_TIME=0;需设定项的unsigned char xdata RUN_CHANGE_ID=0; /IDunsigned char xdata ST_CHANGE_ID =0; bit data ID_CHANGE_FLAG=1; KEY_SWITCH:if(AMP_STANDBY_FLAG) goto ST_KEY_START;RUN_KEY_START:if(UP=0)Delay_mS(10);i

2、f(UP=0) while(UP=0)/判断UP是长按还是短按IN_CYCLE_TIME+; System_Display_Time(); if(IN_CYCLE_TIME=50)/如果UP是长按,则系统音量连续+1Delay_mS(10);while(UP=0)TDA7313_VOL_SET(1);System_Display_Volume();Delay_mS(100);System_Display_Time();IN_CYCLE_TIME=0;goto RUN_KEY_START;IN_CYCLE_TIME=0;TDA7313_VOL_SET(1); /如果UP是短按,则系统音量单次+1

3、System_Display_Volume();AT24C02_Write_Data(AMP_VOL_DATA_BK,AMP_VOL_DATA);if(DOWN=0)Delay_mS(10);if(DOWN=0)while(DOWN=0)/判断UP是长按还是短按IN_CYCLE_TIME+;System_Display_Time();if(IN_CYCLE_TIME=50)/如果UP是长按,则系统音量连续+1Delay_mS(10);while(DOWN=0)TDA7313_VOL_SET(0);System_Display_Volume();Delay_mS(100);System_Disp

4、lay_Time();IN_CYCLE_TIME=0;goto RUN_KEY_START;IN_CYCLE_TIME=0;TDA7313_VOL_SET(0); /如果UP是短按,则系统音量单次+1System_Display_Volume();AT24C02_Write_Data(AMP_VOL_DATA_BK,AMP_VOL_DATA);if(LEFT=0)Delay_mS(10);if(LEFT=0)while(LEFT=0)/判断LEFT是长按还是短按IN_CYCLE_TIME+;System_Display_Time();if(IN_CYCLE_TIME=50)/如果UP是长按,则

5、系统音量连续+1IN_CYCLE_TIME=0;AMP_MUTE_FLAG=AMP_MUTE_FLAG;AMP_MUTE_CHANGE_FLAG=1;TDA7313_MUTE_SET(AMP_MUTE_FLAG); if(AMP_MUTE_FLAG=1) System_Display_Mute();elseLCD_Display_ColorBox(56,149,119,212,0XFFE0);System_Display_Volume();while(LEFT=0) System_Display_Time();AT24C02_Write_Data(AMP_MUTE_FLAG_BK,AMP_MU

6、TE_FLAG);goto RUN_KEY_START;IN_CYCLE_TIME=0;TDA7313_HP_VOL_SET(0);/如果UP是短按,则系统音量单次+1System_Display_HP_Volume();AT24C02_Write_Data(AMP_HP_VOL_DATA_BK,AMP_HP_VOL_DATA);if(RIGHT=0)Delay_mS(10);if(RIGHT=0)while(RIGHT=0)/判断UP是长按还是短按IN_CYCLE_TIME+;System_Display_Time();if(IN_CYCLE_TIME=50)/如果UP是长按,则系统音量连续

7、+1 IN_CYCLE_TIME=0;AMP_LOUD_FLAG=AMP_LOUD_FLAG;/如果UP是短按,则系统音量单次+1TDA7313_LOUD_SET(AMP_LOUD_FLAG); System_Display_Loud();while(RIGHT=0) System_Display_Time();AT24C02_Write_Data(AMP_LOUD_FLAG_BK,AMP_LOUD_FLAG); goto RUN_KEY_START;IN_CYCLE_TIME=0;TDA7313_HP_VOL_SET(1);/如果UP是短按,则系统音量单次+1System_Display_H

8、P_Volume();AT24C02_Write_Data(AMP_HP_VOL_DATA_BK,AMP_HP_VOL_DATA); if(MENU=0)Delay_mS(10);if(MENU=0)while(MENU=0)/判断MEN是长按还是短按IN_CYCLE_TIME+;System_Display_Time();if(IN_CYCLE_TIME=500)IN_CYCLE_TIME=0;AMP_MODE_CHANGE_FLAG=1;AMP_POWER=AMP_POWER;/如果MEN长按,AMP进入SLEEP氐功耗状态AMP_STANDBY_FLAG=AMP_STANDBY_FLAG

9、;while(MENU=0); System_Display_Time();goto KEY_END;IN_CYCLE_TIME=0;while(1)RUN_MENU_LOOP:OUT_CYCLE_TIME+;System_Display_Time();if(OUT_CYCLE_TIME=1000)OUT_CYCLE_TIME=0;0);LCD_Display_String_ASCII8_16(2,0,"CH GAIN:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(3,0,"CHLOUD:",0xF800,0

10、x07E0);LCD_Display_String_ASCII8_16(4,0,"BALANCE:",0xF800,0x07E 0);LCD_Display_String_ASCII8_16(5,0,"B A S S:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(6,0,"TREBLE :",0xF800,0x07E 0);LCD_Display_String_ASCII8_16(7,0,"HP VOL:",0xF800,0x07E0);LCD_Display_Stri

11、ng_ASCII8_16(8,0,"3DSOUND:",0xF800,0x07E 0);LCD_Display_String_ASCII8_16(9,0,"AUTOOFF:",0xF800,0x07E0);goto KEY_SWITCH;if(ID_CHANGE_FLAG=1)ID_CHANGE_FLAG=0;switch(RUN_CHANGE_ID)case 0: /Line 1 channel high light0);LCD_Display_String_ASCII8_16(2,0,"CH GAIN:",0xF800,0x07E

12、0);LCD_Display_String_ASCII8_16(1,0,"CHANNEL:",0xF800,0x001F);break;case 1:LCD_Display_String_ASCII8_16(1,0,"CHANNEL:",0xF800,0x07E 0);LCD_Display_String_ASCII8_16(4,0,"BALANCE:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(2,0,"CHGAIN:",0xF800,0x001F);break;ca

13、se 2:LCD_Display_String_ASCII8_16(2,0,"CH GAIN:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(5,0,"B A S S:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(4,0,"BALANCE:",0xF800,0x001F); break;case 3:LCD_Display_String_ASCII8_16(4,0,"BALANCE:",0xF800,0x07E 0);LCD_

14、Display_String_ASCII8_16(6,0,"TREBLE :",0xF800,0x07E0);LCD_Display_String_ASCII8_16(5,0,"B A S S:",0xF800,0x001F);break;case 4:LCD_Display_String_ASCII8_16(5,0,"B A S S:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(8,0,"3DSOUND:",0xF800,0x07E 0);LCD_Display_St

15、ring_ASCII8_16(6,0,"TREBLE :",0xF800,0x001F);break;case 5:0);LCD_Display_String_ASCII8_16(9,0,"AUTOOFF:",0xF800,0x07E 0);LCD_Display_String_ASCII8_16(8,0,"3DSOUND:",0xF800,0x001F);break;case 6:LCD_Display_String_ASCII8_16(8,0,"3DSOUND:",0xF800,0x07E 0);LCD_Dis

16、play_String_ASCII8_16(1,0,"CHANNEL:",0xF800,0x07E 0);LCD_Display_String_ASCII8_16(9,0,"AUTOOFF:",0xF800,0x001F);break;default: break;if(MENU=0)Delay_mS(10);if(MENU=0)while(MENU=0)IN_CYCLE_TIME+;System_Display_Time();if(IN_CYCLE_TIME=500)IN_CYCLE_TIME=0;AMP_MODE_CHANGE_FLAG=1;AMP_

17、POWER=AMP_POWER;AMP_STANDBY_FLAG=AMP_STANDBY_FLAG; while(MENU=0);System_Display_Time();goto KEY_END;IN_CYCLE_TIME=0;OUT_CYCLE_TIME=0;LCD_Display_String_ASCII8_16(1,0,"CHANNEL:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(2,0,"CHGAIN:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(3

18、,0,"CHLOUD:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(4,0,"BALANCE:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(5,0,"B A SS:",0xF800,0x07E0);0);LCD_Display_String_ASCII8_16(7,0,"HPVOL:",0xF800,0x07E0);LCD_Display_String_ASCII8_16(8,0,"3DSOUND:",0

19、xF800,0x07E0);LCD_Display_String_ASCII8_16(9,0,"AUTOOFF:",0xF800,0x07E0);goto RUN_KEY_START;if(RIGHT=0)Delay_mS(10);if(RIGHT=0)while(RIGHT=0) System_Display_Time();switch(RUN_CHANGE_ID)case 0:/change input channelTDA7313_CHANNEL_SET(1);AT24C02_Write_Data(AMP_CHANNEL_DATA_BK,AMP_CHANNEL_DAT

20、A)System_Display_Channel();case 1:/change input channelgainTDA7313_CHGAIN_SET(1);AT24C02_Write_Data(AMP_CHGAIN_DATA_BK,CHGAIN_DATA);System_Display_Chgain();break;case 2:/change AMP BALANCETDA7313_BALANCE_SET(1);AT24C02_Write_Data(AMP_BALANCE_DATA_BK,AMP_BALANCE_DATA)System_Display_Balance();break;ca

21、se 3:/change AMP BASS TDA7313_BASS_SET(1);AT24C02_Write_Data(AMP_BASS_DATA_BK,AMP_BASS_DATA);System_Display_Bass();case 4:/change AMP TREBLETDA7313_TRE_SET(1);AT24C02_Write_Data(AMP_TRE_DATA_BK,AMP_TRE_DATA);System_Display_Treble();break;case 5:/change AMP HeadphonevolumeVIRTUAL_3D_SET(1);System_Dis

22、play_3D();break;case 6: /change AMPauto power off timeif(AUTO_OFF_FLAG=0)AUTO_OFF_FLAG=1;AUTO_OFF_TIME=0;AUTO_OFF_TIME=AUTO_OFF_TIME+10; if(AUTO_OFF_TIME=130) AUTO_OFF_TIME=120;System_Display_Autooff();default: break;IN_CYCLE_TIME=0;OUT_CYCLE_TIME=0;goto RUN_MENU_LOOP;if(LEFT=0)Delay_mS(10);if(LEFT=

23、0)while(LEFT=0) System_Display_Time();switch(RUN_CHANGE_ID)case 0:/change input channelTDA7313_CHANNEL_SET(0);AT24C02_Write_Data(AMP_CHANNEL_DATA_BK,AMP_CHANNEL_DATA)5System_Display_Channel();break;case 1:/change input channelgainTDA7313_CHGAIN_SET(0);AT24C02_Write_Data(AMP_CHGAIN_DATA_BK,CHGAIN_DAT

24、A);System_Display_Chgain(); break;case 2: /change AMP balance TDA7313_BALANCE_SET(0);AT24C02_Write_Data(AMP_BALANCE_DATA_BK,AMP_BALANCE_DATA)System_Display_Balance(); break;case 3: /change AMP BASS TDA7313_BASS_SET(0);AT24C02_Write_Data(AMP_BASS_DATA_BK,AMP_BASS_DATA);System_Display_Bass(); break;ca

25、se 4:/change AMP TREBLETDA7313_TRE_SET(0);AT24C02_Write_Data(AMP_TRE_DATA_BK,AMP_TRE_DATA);System_Display_Treble();volumeVIRTUAL_3D_SET(0);System_Display_3D();break;case 6: /change AMP auto power offtimeif(AUTO_OFF_FLAG=1)AUTO_OFF_TIME=AUTO_OFF_TIME-10;if(AUTO_OFF_TIME>130)&&(AUTO_OFF_TIM

26、E<=255)AUTO_OFF_TIME=0;AUTO_OFF_FLAG=0;System_Display_Autooff();break;default: break;IN_CYCLE_TIME=0;OUT_CYCLE_TIME=0;goto RUN_MENU_LOOP;if(UP=0)Delay_mS(10);if(UP=0) while(UP=0) System_Display_Time(); ID_CHANGE_FLAG=1;RUN_CHANGE_ID-; if(RUN_CHANGE_ID=255) RUN_CHANGE_ID=0; IN_CYCLE_TIME=0; OUT_CY

27、CLE_TIME=0; goto RUN_MENU_LOOP;if(DOWN=0)Delay_mS(10);if(DOWN=0)while(DOWN=0) System_Display_Time();ID_CHANGE_FLAG=1;RUN_CHANGE_ID+;if(RUN_CHANGE_ID=7) RUN_CHANGE_ID=6;IN_CYCLE_TIME=0; OUT_CYCLE_TIME=0; goto RUN_MENU_LOOP;goto KEY_END;ST_KEY_START:if(UP=0)Delay_mS(10);if(UP=0)while(UP=0) System_Disp

28、lay_Time();if(ALARM_COUNT2!=0)TR0=0;TH0=-50000/256;TL0=-50000%256;ALARM_COUNT1=0;ALARM_COUNT2=0;if(MENU=0)Delay_mS(10);if(MENU=0)while(MENU=0)/判断MEN是长按还是短按IN_CYCLE_TIME+;System_Display_Time(); if(IN_CYCLE_TIME=500) IN_CYCLE_TIME=0;AMP_MODE_CHANGE_FLAG=1;AMP_POWER=AMP_POWER; / 如果MEN长按,AMP进入SLEEP氐功耗状态

29、AMP_STANDBY_FLAG=AMP_STANDBY_FLAG;while(MENU=0); System_Display_Time();goto KEY_END;IN_CYCLE_TIME=0;while(1)ST_MENU_LOOP:OUT_CYCLE_TIME+;if(OUT_CYCLE_TIME=1000)OUT_CYCLE_TIME=0;goto KEY_SWITCH;/switch()if(MENU=0)Delay_mS(10);if(MENU=0)while(MENU=0)IN_CYCLE_TIME+;System_Display_Time();if(IN_CYCLE_TIM

30、E=500)IN_CYCLE_TIME=0;AMP_MODE_CHANGE_FLAG=1;AMP_POWER=AMP_POWER;AMP_STANDBY_FLAG=AMP_STANDBY_FLAG; while(MENU=0);System_Display_Time();goto KEY_END;IN_CYCLE_TIME=0;OUT_CYCLE_TIME=0;goto KEY_SWITCH;if(UP=0)Delay_mS(10);if(UP=0)while(UP=0) System_Display_Time();switch(ST_CHANGE_ID)case 0: /change input channelTDA7313_CHANNEL_SET(1);break;case 1: /change input channelgainTDA7313_CHGAIN_SET(1);break;case 2: /change AMP BASSTDA7313_BASS_SET(1);break;case 3: /change AMP TREBLETDA7313_TRE_SET(1);break;case 4: /change AMP HeadphonevolumeTDA7313_HP_VOL_SET(1); break;case 5: /change AMPauto

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论