📄 a.c
字号:
/*****************************************************
Project :
Version :
Date : 2007-5-31
Author : Cheung
Company : hhuc
Comments:
Chip type : ATmega16L
Program type : Application
Clock frequency : 1.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
*****************************************************/
#include<mega16.h>
#include<stdlib.h> //标准库和内存分配函数,数字转换字符
#include<delay.h>
#include<hongwai.h>
#include<type.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18 ;PORTB
#endasm
#include<lcd.h>
/*uint arr[16]; //捕捉中断之间的时间值;
uchar times; //捕捉中断次数;
uchar index; //数组索引;
uchar ir_code; //接受红外编码;
uchar ok_flag; //解码完毕标示;
uchar head; //引导码标志;
*/
uchar hex[3]; //十六进制解码
uchar code[5]; //用于液晶显示所用的存储数据数组应设置长点!
flash uchar showhex[]="The Code Is:0x";
flash uchar showdec[]="Dec Code:";
void dec_to_hex(uchar dec) //十进制转换十六进制显示
{
uchar temp[2],i;
temp[0]=dec/16;
temp[1]=dec%16;
for(i=0;i<2;i++){
switch(temp[i]){
case 0:temp[i]='0';break;
case 1:temp[i]='1';break;
case 2:temp[i]='2';break;
case 3:temp[i]='3';break;
case 4:temp[i]='4';break;
case 5:temp[i]='5';break;
case 6:temp[i]='6';break;
case 7:temp[i]='7';break;
case 8:temp[i]='8';break;
case 9:temp[i]='9';break;
case 10:temp[i]='A';break;
case 11:temp[i]='B';break;
case 12:temp[i]='C';break;
case 13:temp[i]='D';break;
case 14:temp[i]='E';break;
case 15:temp[i]='F';break;
}
hex[i]=temp[i];
}
}
void main()
{
// port_initial();
time1_initial();
delay_us(200);
lcd_init(16);
delay_us(200);
#asm("sei") // Global enable interrupts
while(1)
{
if(ok_flag)
{
get_code();
dec_to_hex(ir_code);
ok_flag=0;
lcd_clear();
itoa(ir_code,code);
}
lcd_gotoxy(0,0);
lcd_putsf(showhex);
lcd_gotoxy(14,0);
lcd_puts(hex);
lcd_gotoxy(3,1);
lcd_putsf(showdec);
lcd_gotoxy(13,1);
lcd_puts(code);
delay_us(500);
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -