#include <reg52.h>
、
、
、
、
、
、
、
、
、
、
、
、
、
、
、
、
、
void main (void)
{
uchar reg_rddata;
LCD_Reset();
LCD_Initial();
LCD_CLR();
WriteDataToREG(0x00,0xcd);
SetXY(0x00,0x00);
Display_Chinese(tab1,160);
reg_rddata = ReadDataFromREG(0xa0);
reg_rddata |= 0x04; //致能触摸中断
WriteDataToREG(0xa0,reg_rddata);
IT0=0;
//EA=1;
//EX0=1;
while(1)
{
reg_rddata = ReadDataFromREG(0xa0);
if(reg_rddata & 0x40)
{
reg_rddata = ReadDataFromREG(0xa0);
reg_rddata &= 0xfb; //禁能触摸中断
WriteDataToREG(0xa0,reg_rddata);
get_touch(); //接收触摸键程序
}
reg_rddata = ReadDataFromREG(0xa0);
reg_rddata |= 0x04; //致能触摸中断
WriteDataToREG(0xa0,reg_rddata);
if(key_fg)
{
key_fg=0x00;
key_x2=key_x1;key_x1=touchx/100;
key_y2=key_y1;key_y1=touchy/100;
Delay_Nms(20);
if((key_x2!= key_x1)||(key_y2!=key_y1)) continue;
key= xytab[(key_y1-1)*7+key_x1-1];
switch(key) //判触摸地号11----77
{ case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37: {WriteDataToREG(0x10,0x2b); //显示图形1
WriteDataToREG(0x00,0xc5);
lcd_photo(tab4);
Delay_Nms (3000);break; }
case 41:
case 42:
case 43:
case 44:
case 45:
case 46: //下面是显示文字
case 47: { WriteDataToREG(0x10,0x2b); //2b写汉字,3d写英文(粗字),
WriteDataToREG(0x00,0xc5); //0xcd写文字,0xc5写图形
lcd_photo(tab5);
Delay_Nms (3000);break; } //
case 51: //下面可以增加
case 52:
case 53:
case 54:
case 55:
case 56:
case 57: {WriteDataToREG(0x10,0x2b); //2b写汉字,3d写英文(粗字),
WriteDataToREG(0x00,0xc5); //0xcd写文字,0xc5写图形
lcd_photo(tab6);
Delay_Nms (3000);break; }
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67: {WriteDataToREG(0x10,0x2b); //2b写汉字,3d写英文(粗字),
WriteDataToREG(0x00,0xc5); //0xcd写文字,0xc5写图形
lcd_photo(tab7);
Delay_Nms (3000);break; }
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77: {WriteDataToREG(0x10,0x2b); //2b写汉字,3d写英文(粗字),
WriteDataToREG(0x00,0xc5); //0xcd写文字,0xc5写图形
lcd_photo(tab8);
Delay_Nms (3000);break; } // 减键
}
} }
} |