📄 液晶多级菜单实现方法_rar cxlcdnew_c.htm
字号:
//
for(i_DisponeTextChar=0;i_DisponeTextChar<8;i_DisponeTextChar++)
{
if((DispAttrib&0x01)==1)
{
k_DisponeTextChar=Echar[j_DisponeTextChar][i_DisponeTextChar];
}
else
{
k_DisponeTextChar=Echar[j_DisponeTextChar][i_DisponeTextChar]^0xff;
}
if((DispAttrib&0x80)>0)//上
{
k_DisponeTextChar|=0x01;
}
if((DispAttrib&0x40)>0)//下
{
k_DisponeTextChar|=0x80;
}
if((i_DisponeTextChar==0)&&((DispAttrib&0x20)>0))//左
{
k_DisponeTextChar|=0xff;
}
if( (i_DisponeTextChar==7) && ((DispAttrib&0x10)>0) )//右
{
k_DisponeTextChar|=0xff;
}
lcd_write_d(k_DisponeTextChar);
}
}
//
void DispTwoBoxHexChar(unsigned char Row,unsigned char Col,unsigned char c1,unsigned char DispAttrib)
{
i_DisponeTextChar=0xb0+Row-1;
lcd_write_c(i_DisponeTextChar);//set page 0
//
i_DisponeTextChar=(0x00+Col)*8+2;
j_DisponeTextChar=i_DisponeTextChar&0x0f;
lcd_write_c(j_DisponeTextChar);//Set Lower Column Address
//
j_DisponeTextChar=((i_DisponeTextChar&0xf0)>>4)+0x10;
lcd_write_c(j_DisponeTextChar);//Set Higher Column Address
//
lcd_write_c(0x40);//Set Display Start Line
//
cTemp_DisponeTextChar=(c1>>4)&0x0f;
if((cTemp_DisponeTextChar>=0)&&(cTemp_DisponeTextChar<=9))
{
cTemp_DisponeTextChar+=16;
}
else
if((cTemp_DisponeTextChar>=0x0a)&&(cTemp_DisponeTextChar<=0x0f))
{
cTemp_DisponeTextChar+=23;
}
//
for(i_DisponeTextChar=0;i_DisponeTextChar<8;i_DisponeTextChar++)
{
if((DispAttrib&0x01)==1)
{
k_DisponeTextChar=Echar[cTemp_DisponeTextChar][i_DisponeTextChar];
}
else
{
k_DisponeTextChar=Echar[cTemp_DisponeTextChar][i_DisponeTextChar]^0xff;
}
if((DispAttrib&0x80)>0)//上
{
k_DisponeTextChar|=0x01;
}
if((DispAttrib&0x40)>0)//下
{
k_DisponeTextChar|=0x80;
}
if((i_DisponeTextChar==0)&&((DispAttrib&0x20)>0))//左
{
k_DisponeTextChar|=0xff;
}
lcd_write_d(k_DisponeTextChar);
}
//
cTemp_DisponeTextChar=c1&0x0f;
if((cTemp_DisponeTextChar>=0)&&(cTemp_DisponeTextChar<=9))
{
cTemp_DisponeTextChar+=16;
}
else
if((cTemp_DisponeTextChar>=0x0a)&&(cTemp_DisponeTextChar<=0x0f))
{
cTemp_DisponeTextChar+=23;
}
//
for(i_DisponeTextChar=0;i_DisponeTextChar<8;i_DisponeTextChar++)
{
if((DispAttrib&0x01)==1)
{
k_DisponeTextChar=Echar[cTemp_DisponeTextChar][i_DisponeTextChar];
}
else
{
k_DisponeTextChar=Echar[cTemp_DisponeTextChar][i_DisponeTextChar]^0xff;
}
if((DispAttrib&0x80)>0)//上
{
k_DisponeTextChar|=0x01;
}
if((DispAttrib&0x40)>0)//下
{
k_DisponeTextChar|=0x80;
}
if( (i_DisponeTextChar==7) && ((DispAttrib&0x10)>0) )//右
{
k_DisponeTextChar|=0xff;
}
lcd_write_d(k_DisponeTextChar);
}
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//======================================================================
//# lcd_write_c #
//======================================================================
void lcd_write_c(unsigned char c1)
{
EA=0;
LCD_A0=0;//Command
LCD_WR=0;
LCD_CS=0;
//
P2=c1;P2=c1;
P2=c1;P2=c1;
P2=c1;P2=c1;
//
LCD_CS=1;
LCD_WR=1;
LCD_A0=1;//Data Byte
EA=1;
}
//======================================================================
//# lcd_write_d #
//======================================================================
void lcd_write_d(unsigned char c1)
{
EA=0;
LCD_A0=1;//Data Byte
LCD_WR=0;
LCD_CS=0;
//
P2=c1;P2=c1;
P2=c1;P2=c1;
P2=c1;P2=c1;
//
LCD_CS=1;
LCD_WR=1;
EA=1;
}
//
void DispFaceBmp()
{
//Disp The First Face Bmp
c1_FaceBmp=0;
i_FaceBmp=0;
j_FaceBmp=0;
k_FaceBmp=0;
//
lcd_write_c(0xb0+c1_FaceBmp);//set page 0
lcd_write_c(0x40);//Set Display Start Line
lcd_write_c(0x0a);//Set Lower Column Address
lcd_write_c(0x10);//Set Higher Column Address
//
for(i_FaceBmp=0;i_FaceBmp<112;i_FaceBmp++)
{
//
for(j_FaceBmp=0;j_FaceBmp<8;j_FaceBmp++)
{
//
lcd_write_d(FaceBmp[i_FaceBmp][j_FaceBmp]);//$>90
if(++k_FaceBmp>111)
{
k_FaceBmp=0;
c1_FaceBmp++;
lcd_write_c(0xb0+c1_FaceBmp);//set page 0
lcd_write_c(0x40);//Set Display Start Line
lcd_write_c(0x0a);//Set Lower Column Address
lcd_write_c(0x10);//Set Higher Column Address
}
}
//
}
DispOneBoxTextChar(4,7,'V',1);
DispOneBoxTextChar(4,8,'1',1);
DispOneBoxTextChar(4,9,'.',1);
DispOneBoxTextChar(4,10,'0',1);
DispOneBoxTextChar(4,11,'2',1);
DispOneBoxTextChar(4,12,'3',1);
}
//
void LcdInit()
{
LCD_RESET=0;//Hard Reset
DelayMs(10);//LCD_RESET=0;LCD_RESET=0;
LCD_RESET=1;
DelayMs(5);
lcd_write_c(0xe2);//15.Software Reset
lcd_write_c(0xa2);//8.Set LCD Bias
lcd_write_c(0xa9);//20.Set Bias Ratio,TC Value,Osc.Freq
lcd_write_c(0xca);//20-1.The Data Byte=8 Bits
lcd_write_c(0xa0);//7.Set Segment Re_map
lcd_write_c(0xc8);//13.Set Com OutputScan Direction
lcd_write_c(0x2f);//4.Set Power Control Register
lcd_write_c(0xa4);//9.Set Entire Display On/Off
lcd_write_c(0x24);//3.Set Internal Regulator Resistor Ratio
lcd_write_c(0x81);//6.Set Contrast Control Register
lcd_write_c(40);//6->1.value=0x00+value&0x3f,
lcd_write_c(0xa6);//10.Set Normal/Reverse Display
lcd_write_c(0xaf);//11.Set Display On/Off
lcd_write_c(0xb0);//12.Set Page Address
}
//
void MyInit()
{
//
TMOD=0x21;
//0010,0001B(GATE,C/T\,M1,M0,GATE,C/T\,M1,M0).
//T1,T0都不受/INT0和/INT1引脚控制,
//T1,T0都为定时器方式
//定时器1(方式2:自动重装的8位定时方式)用作波特率发生器.
//定时器0(方式1:作为16位定时器)
TF1=0;//清定时器1溢出位
TF0=0;//清定时器0溢出位
TL0=TL0data;
TH0=TH0data;
TL1=0xfd;
TH1=0xfd;
SM0=0;//8位UART,波特率可变.
SM1=1;//
SM2=0;//单机通讯
REN=1;//允许接收
TB8=1;//发送的第9位数据位=1
RB8=1;//接收到的仃止位为1**********
TI=0;//清串口发送请求
RI=0;//清串口接收请求
PCON=0;//SMOD(PCON.7)=0,波特率为振荡频率的1/64,且与T1有关
IP=0x10;//0001,000B 串行中断优先
//
IT0=1;//外中断0为下降沿触发
IE0=0;//清外中断0请求
//
IT1=1;//外中断1为下降沿触发
IE1=0;//清外中断1请求
//
PX0=0;//INT0中断优先级=低
PT0=0;//T0中断优先级=低
PX1=0;//INT1中断优先级=低
PT1=0;//T1中断优先级=低
PS=0;//串行中断优先级=低
//
EX0=1;//Enable Interrupt Ex0
ET0=1;//Enable Interrupt T0
EX1=0;//Disable Interrupt Ex1
ET1=0;//Disable Interrupt T1
ES=1;// Enable Interrupt Communication
EA=1;//Enable Interrupt All
TR1=1;//Run Time 1
TR0=1;//Run Time 0
//
}
//
void DispGraphChar(unsigned char Row,unsigned char Col,unsigned char xdata *cArray,unsigned char DispAttrib)
{
//unsigned char data * xdata p;
cGraphTemp1=0xb0+Row-1;
lcd_write_c(cGraphTemp1);//set page
//
cGraphTemp1=(0x00+Col)*8+2;
cGraphTemp2=cGraphTemp1&0x0f;
lcd_write_c(cGraphTemp2);//Set Lower Column Address
//
cGraphTemp2=((cGraphTemp1&0xf0)>>4)+0x10;
lcd_write_c(cGraphTemp2);//Set Higher Column Address
//
lcd_write_c(0x40);//Set Display Start Line
//
cpGraph=cArray;
//
for(cGraphTemp1=0;cGraphTemp1<8;cGraphTemp1++)
{
if(DispAttrib==1)
{
cGraphTemp2=*cpGraph;
}
else
{
cGraphTemp2=(*cpGraph)&0xff;
}
lcd_write_d(cGraphTemp2);
cpGraph++;
}
}
//
void ReadyForKey()
{
KEYROW1=0;
KEYROW2=0;
KEYROW3=0;
//KEYINT=1;
}
//
void DelayMs(unsigned int iMs)
{
unsigned int data i_DelayMs;
unsigned char data j_DelayMs;
for(i_DelayMs=0;i_DelayMs<iMs;i_DelayMs++)
{
for(j_DelayMs=0;j_DelayMs<224;j_DelayMs++)
{
_nop_();
}
}
}//
//Next Function
unsigned char code Echar[96][8]={
// (0) !(1) "(2) #(3) $(4) %(5) &(6) '(7)
// ((8) )(9) *(10) +(11) ,(12) -(13) .(14) /(15)
// 0(16) 1(17) 2(18) 3(19) 4(20) 5(21) 6(22) 7(23)
// 8(24) 9(25) :(26) ;(27) <(28) =(29) >(30) ?(31)
// @(32) A(33) B(34) C(35) D(36) E(37) F(38) G(39)
// H(40) I(41) J(42) K(43) L(44) M(45) N(46) O(47)
// P(48) Q(49) R(50) S(51) T(52) U(53) V(54) W(55)
// X(56) Y(57) Z(58) [(59) \(60) ](61) ^(62) _(63)
// `(64) a(65) b(66) c(67) d(68) e(69) f(70) g(71)
// h(72) i(73) j(74) k(75) l(76) m(77) n(78) o(79)
// p(80) q(81) r(82) s(83) t(84) u(85) v(86) w(87)
// x(88) y(89) z(90) {(91) |(92) }(93) ~(94) (95)
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x06,0x5F,0x5F,0x06,0x00,0x00},/*"!",1*/
{0x00,0x00,0x07,0x07,0x00,0x07,0x07,0x00},/*""",2*/
{0x00,0x14,0x7F,0x7F,0x14,0x7F,0x7F,0x14},/*"#",3*/
{0x00,0x24,0x2E,0x6B,0x6B,0x3A,0x12,0x00},/*"$",4*/
{0x00,0x46,0x66,0x30,0x18,0x0C,0x66,0x62},/*"%",5*/
{0x00,0x30,0x7A,0x4F,0x5D,0x37,0x7A,0x48},/*"&",6*/
{0x00,0x04,0x07,0x03,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x1C,0x3E,0x63,0x41,0x00,0x00},/*"(",8*/
{0x00,0x00,0x41,0x63,0x3E,0x1C,0x00,0x00},/*")",9*/
{0x00,0x08,0x2A,0x3E,0x1C,0x1C,0x3E,0x2A},/*"*",10*/
{0x00,0x08,0x08,0x3E,0x3E,0x08,0x08,0x00},/*"+",11*/
{0x00,0x00,0xA0,0xE0,0x60,0x00,0x00,0x00},/*",",12*/
{0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00},/*"-",13*/
{0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00},/*".",14*/
{0x00,0x60,0x30,0x18,0x0C,0x06,0x03,0x01},/*"/",15*/
{0x00,0x3E,0x7F,0x59,0x4D,0x7F,0x3E,0x00},/*"0",16*/
{0x00,0x42,0x42,0x7F,0x7F,0x40,0x40,0x00},/*"1",17*/
{0x00,0x62,0x73,0x59,0x49,0x6F,0x66,0x00},/*"2",18*/
{0x00,0x22,0x63,0x49,0x49,0x7F,0x36,0x00},/*"3",19*/
{0x00,0x18,0x1C,0x16,0x13,0x7F,0x7F,0x10},/*"4",20*/
{0x00,0x27,0x67,0x45,0x45,0x7D,0x39,0x00},/*"5",21*/
{0x00,0x3C,0x7E,0x4B,0x49,0x79,0x30,0x00},/*"6",22*/
{0x00,0x03,0x63,0x71,0x19,0x0F,0x07,0x00},/*"7",23*/
{0x00,0x36,0x7F,0x49,0x49,0x7F,0x36,0x00},/*"8",24*/
{0x00,0x06,0x4F,0x49,0x69,0x3F,0x1E,0x00},/*"9",25*/
{0x00,0x00,0x00,0x6C,0x6C,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0xA0,0xEC,0x6C,0x00,0x00,0x00},/*";",27*/
{0x00,0x08,0x1C,0x36,0x63,0x41,0x00,0x00},/*"<",28*/
{0x00,0x14,0x14,0x14,0x14,0x14,0x14,0x00},/*"=",29*/
{0x00,0x00,0x41,0x63,0x36,0x1C,0x08,0x00},/*">",30*/
{0x00,0x02,0x03,0x51,0x59,0x0F,0x06,0x00},/*"?",31*/
{0x00,0x3E,0x7F,0x41,0x5D,0x5D,0x1F,0x1E},/*"@",32*/
{0x00,0x7C,0x7E,0x13,0x13,0x7E,0x7C,0x00},/*"A",33*/
{0x00,0x41,0x7F,0x7F,0x49,0x49,0x7F,0x36},/*"B",34*/
{0x00,0x1C,0x3E,0x63,0x41,0x41,0x63,0x22},/*"C",35*/
{0x00,0x41,0x7F,0x7F,0x41,0x63,0x7F,0x1C},/*"D",36*/
{0x00,0x41,0x7F,0x7F,0x49,0x5D,0x41,0x63},/*"E",37*/
{0x00,0x41,0x7F,0x7F,0x49,0x1D,0x01,0x03},/*"F",38*/
{0x00,0x1C,0x3E,0x63,0x41,0x51,0x73,0x72},/*"G",39*/
{0x00,0x7F,0x7F,0x08,0x08,0x7F,0x7F,0x00},/*"H",40*/
{0x00,0x00,0x41,0x7F,0x7F,0x41,0x00,0x00},/*"I",41*/
{0x00,0x30,0x70,0x40,0x41,0x7F,0x3F,0x01},/*"J",42*/
{0x00,0x41,0x7F,0x7F,0x08,0x1C,0x77,0x63},/*"K",43*/
{0x00,0x41,0x7F,0x7F,0x41,0x40,0x60,0x70},/*"L",44*/
{0x00,0x7F,0x7F,0x06,0x0C,0x06,0x7F,0x7F},/*"M",45*/
{0x00,0x7F,0x7F,0x06,0x0C,0x18,0x7F,0x7F},/*"N",46*/
{0x00,0x1C,0x3E,0x63,0x41,0x63,0x3E,0x1C},/*"O",47*/
{0x00,0x41,0x7F,0x7F,0x49,0x09,0x0F,0x06},/*"P",48*/
{0x00,0x1E,0x3F,0x21,0x71,0x7F,0x5E,0x00},/*"Q",49*/
{0x00,0x41,0x7F,0x7F,0x19,0x39,0x6F,0x46},/*"R",50*/
{0x00,0x26,0x67,0x4D,0x59,0x7B,0x32,0x00},/*"S",51*/
{0x00,0x03,0x41,0x7F,0x7F,0x41,0x03,0x00},/*"T",52*/
{0x00,0x7F,0x7F,0x40,0x40,0x7F,0x7F,0x00},/*"U",53*/
{0x00,0x1F,0x3F,0x60,0x60,0x3F,0x1F,0x00},/*"V",54*/
{0x00,0x7F,0x7F,0x30,0x18,0x30,0x7F,0x7F},/*"W",55*/
{0x00,0x63,0x77,0x1C,0x08,0x1C,0x77,0x63},/*"X",56*/
{0x00,0x07,0x4F,0x78,0x78,0x4F,0x07,0x00},/*"Y",57*/
{0x00,0x67,0x73,0x59,0x4D,0x47,0x63,0x71},/*"Z",58*/
{0x00,0x00,0x7F,0x7F,0x41,0x41,0x00,0x00},/*"[",59*/
{0x00,0x01,0x03,0x06,0x0C,0x18,0x30,0x60},/*"\",60*/
{0x00,0x00,0x41,0x41,0x7F,0x7F,0x00,0x00},/*"]",61*/
{0x00,0x08,0x0C,0x06,0x03,0x06,0x0C,0x08},/*"^",62*/
{0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80},/*"_",63*/
{0x00,0x00,0x00,0x03,0x07,0x04,0x00,0x00},/*"`",64*/
{0x00,0x20,0x74,0x54,0x54,0x3C,0x78,0x40},/*"a",65*/
{0x00,0x41,0x3F,0x7F,0x44,0x44,0x7C,0x38},/*"b",66*/
{0x00,0x38,0x7C,0x44,0x44,0x6C,0x28,0x00},/*"c",67*/
{0x00,0x30,0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -