📄 menu.c
字号:
/*
ZLG7290演示程序
*/
#include "I2C.h"
#include "ZLG7290.h"
#include "KSzong.h"
#include "zixing.h"
#include<stdio.h>
sbit p00=P0^0;
unsigned char idata p=0;
unsigned char idata f=0;
void EMI_Init()
{
SFRPAGE = EMI0_PAGE;
EMI0CF = 0x37;
}
void Oscillator_Init()
{
SFRPAGE = CONFIG_PAGE;
OSCICN = 0x83;
}
void Port_IO_Init()
{
SFRPAGE = CONFIG_PAGE;
// P4MDOUT = 0xE0;
// XBR1 = 0x04;
XBR2 = 0x40;
}
void Init_Device(void)
{ Port_IO_Init();
Oscillator_Init();
EMI_Init();
}
//定义键盘p12=0表示有键按下
/*
函数:SystemInit()
功能:系统初始化
*/
void systemInit()
{
WDTCN=0xde;
WDTCN=0xad;
Init_Device( );
I2C_Init();
// Delay_x10ms(300);
LCD_Initial();
LCD_CLR(Right);
LCD_CLR(Left);}
void display1( )
{ unsigned char idata m=1;
if(f==0){ m=0;
LCD_Play(2,16,1,fa[m],1) ;
LCD_Play(2,32,1,song[m],1) ;
LCD_Play(2,48,1,mo[m],1) ;
LCD_Play(2,0,1,shi[m],2) ;
m=1;}
else { LCD_Play(2,16,1,fa[m],1) ;
LCD_Play(2,32,1,song[m],1) ;
LCD_Play(2,48,1,mo[m],1) ;
LCD_Play(2,0,1,shi[m],2) ;}
if(f==1){ m=0;
LCD_Play(4,16,1,jie[m],1) ;
LCD_Play(4,32,1,shou[m],1) ;
LCD_Play(4,48,1,mo[m],1) ;
LCD_Play(4,0,1,shi[m],2) ;
m=1; }
else {LCD_Play(4,16,1,jie[m],1) ;
LCD_Play(4,32,1,shou[m],1) ;
LCD_Play(4,48,1,mo[m],1) ;
LCD_Play(4,0,1,shi[m],2) ;}
if(f==2){m=0;
LCD_Play(6,16,1,sh[m],1) ;
LCD_Play(6,32,1,ru[m],1) ;
LCD_Play(6,48,1,shu[m],1) ;
LCD_Play(6,0,1,ju[m],2) ;
m=1;}
else { LCD_Play(6,16,1,sh[m],1) ;
LCD_Play(6,32,1,ru[m],1) ;
LCD_Play(6,48,1,shu[m],1) ;
LCD_Play(6,0,1,ju[m],2) ;} }
void display10( )
{ unsigned char idata m0=1;
if(f==0){ m0=0;
LCD_Play(2,16,1,yu[m0],1) ;
LCD_Play(2,32,1,yin[m0],1) ;
LCD_Play(2,48,1,fa[m0],1) ;
LCD_Play(2,0,1,song[m0],2) ;
m0=1;}
else { LCD_Play(2,16,1,yu[m0],1) ;
LCD_Play(2,32,1,yin[m0],1) ;
LCD_Play(2,48,1,fa[m0],1) ;
LCD_Play(2,0,1,song[m0],2) ;}
if(f==1){ m0=0;
LCD_Play(4,16,1,shu[m0],1) ;
LCD_Play(4,32,1,zi[m0],1) ;
LCD_Play(4,48,1,fa[m0],1) ;
LCD_Play(4,0,1,song[m0],2) ;
m0=1; }
else {LCD_Play(4,16,1,shu[m0],1) ;
LCD_Play(4,32,1,zi[m0],1) ;
LCD_Play(4,48,1,fa[m0],1) ;
LCD_Play(4,0,1,song[m0],2) ;}
if(f==2){m0=0;
LCD_Play(6,16,1,tong[m0],1) ;
LCD_Play(6,32,1,shii[m0],1) ;
LCD_Play(6,48,1,fa[m0],1) ;
LCD_Play(6,0,1,song[m0],2) ;
m0=1;}
else { LCD_Play(6,16,1,tong[m0],1) ;
LCD_Play(6,32,1,shii[m0],1) ;
LCD_Play(6,48,1,fa[m0],1) ;
LCD_Play(6,0,1,song[m0],2) ;} }
void display11( )
{ unsigned char idata m1=1;
if(f==0){ m1=0;
LCD_Play(2,16,1,yu[m1],1) ;
LCD_Play(2,32,1,yin[m1],1) ;
LCD_Play(2,48,1,jie[m1],1) ;
LCD_Play(2,0,1,shou[m1],2) ;
m1=1;}
else { LCD_Play(2,16,1,yu[m1],1) ;
LCD_Play(2,32,1,yin[m1],1) ;
LCD_Play(2,48,1,jie[m1],1) ;
LCD_Play(2,0,1,shou[m1],2) ;}
if(f==1){ m1=0;
LCD_Play(4,16,1,shu[m1],1) ;
LCD_Play(4,32,1,zi[m1],1) ;
LCD_Play(4,48,1,jie[m1],1) ;
LCD_Play(4,0,1,shou[m1],2) ;
m1=1; }
else {LCD_Play(4,16,1,shu[m1],1) ;
LCD_Play(4,32,1,zi[m1],1) ;
LCD_Play(4,48,1,jie[m1],1) ;
LCD_Play(4,0,1,shou[m1],2) ;}
if(f==2){m1=0;
LCD_Play(6,16,1,tong[m1],1) ;
LCD_Play(6,32,1,shii[m1],1) ;
LCD_Play(6,48,1,jie[m1],1) ;
LCD_Play(6,0,1,shou[m1],2) ;
m1=1;}
else { LCD_Play(6,16,1,tong[m1],1) ;
LCD_Play(6,32,1,shii[m1],1) ;
LCD_Play(6,48,1,jie[m1],1) ;
LCD_Play(6,0,1,shou[m1],2) ;} }
void display12( )
{ unsigned char idata m2=1;
if(f==0){ m2=0;
LCD_Play(2,16,1,sh[m2],1) ;
LCD_Play(2,32,1,ru[m2],1) ;
LCD_Play(2,48,1,shu[m2],1) ;
LCD_Play(2,0,1,zi[m2],2) ;
m2=1;}
else { LCD_Play(2,16,1,sh[m2],1) ;
LCD_Play(2,32,1,ru[m2],1) ;
LCD_Play(2,48,1,shu[m2],1) ;
LCD_Play(2,0,1,zi[m2],2) ;}
if(f==1){ m2=0;
LCD_Play(4,16,1,sh[m2],1) ;
LCD_Play(4,32,1,ru[m2],1) ;
LCD_Play(4,48,1,zi[m2],1) ;
LCD_Play(4,0,1,mu[m2],2) ;
m2=1; }
else {LCD_Play(4,16,1,sh[m2],1) ;
LCD_Play(4,32,1,ru[m2],1) ;
LCD_Play(4,48,1,zi[m2],1) ;
LCD_Play(4,0,1,mu[m2],2) ;}
if(f==2){m2=0;
LCD_Play(6,16,1,sh[m2],1) ;
LCD_Play(6,32,1,ru[m2],1) ;
LCD_Play(6,48,1,han[m2],1) ;
LCD_Play(6,0,1,zi[m2],2) ;
m2=1;}
else { LCD_Play(6,16,1,sh[m2],1) ;
LCD_Play(6,32,1,ru[m2],1) ;
LCD_Play(6,48,1,han[m2],1) ;
LCD_Play(6,0,1,zi[m2],2) ;} }
void main()
{ unsigned char xdata KeyValue,keyValue,i=0,d=0,c=0;
unsigned char code valuedeal[28]={88,12,11,10,0,0,0,0,77,9,8,7,0,0,0,0,66,6,5,4,0,0,0,0,55,3,2,1};
void (*p)();
p=display1;
systemInit();
LCD_Play(0,0,1,Chinese_qing,1) ;
LCD_Play(0,16,1,Chinese_xuan,1) ;
LCD_Play(0,32,1,Chinese_ze,1) ;
LCD_Play(0,48,1,maohao,1) ;
(*p)( );
for(;;)
{
if ( p00==0)
{
p00= 1;
ZLG7290_ReadReg(ZLG7290_Key,&KeyValue);
keyValue=valuedeal[KeyValue-1];
ZLG7290_Download(i, 0, 0, keyValue);
switch(keyValue)
{ case 55: if(f==0) f=2; else f--;break;
case 66: if(f==2) f=0; else f++;break;
case 77: if(d<1) d++;c=f; f=0; break;
case 88: if(d!=0) d--; f=0; break;
default: break;}
}
if(d==0) p=display1;
if(d==1){if(c==0) p=display10;
if(c==1) p=display11;
if(c==2) p=display12;}
(*p)();
} }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -