就是那個not的幾行,老是一直掃描導致一直在閃,找不到好的方法。#include <REGX51.H>
#include <intrins.h>
#include <zimo.c>
#define uchar unsigned char
#define uint unsigned int
void delay(uint i){while(i--);}
sbit cs2=P2^3; sbit cs1=P2^4; sbit en=P2^5; sbit rw=P2^6; sbit rs=P2^7;
sbit row0=P3^0; sbit row1=P3^1; sbit col0=P3^2; sbit col1=P3^3; sbit col2=P3^4;
sbit col3=P3^5; sbit sw=P3^6;
sbit w1=P3^7; sbit w2=P2^0; sbit w3=P2^1; sbit w4=P2^2;
sbit wl1=P1^0; sbit wl2=P1^1; sbit wl3=P1^2; sbit wl4=P1^3;
sbit wl5=P1^4; sbit wl6=P1^5; sbit wl7=P1^6; sbit wl8=P1^7;
#define zuo {w1=0;w2=1;}
#define you {w1=1;w2=0;}
#define stop {w1=w2=1;}
#define jia {w3=0;}
#define song {w3=1;}
#define shang {w4=1;}
#define xia {w4=0;}
uchar key(void)
{
uchar k=0xff;
row0=0; k=col0==0?0:col1==0?1:col2==0?2:col3==0?3:k; row0=1;
row1=0; k=col0==0?4:col1==0?5:col2==0?6:col3==0?7:k; row1=1;
return k;
}
void wc(uchar com)
{
rs=0;rw=0;
P0=com;
en=1;en=0;
}
void wd(uchar dat)
{
rs=1;rw=0;
P0=dat;
en=1;en=0;
}
void clr()
{
uchar i,j;
cs1=cs2=1;
for(i=0;i<8;i++)
{
wc(0xb8+i);
wc(0x40);
for(j=0;j<64;j++)wd(0);
}
}
/** 將一字節數據dat寫到r行,c列 **/
void wo(uchar r,uchar c,uchar dat){
if(c<64)cs1=1,cs2=0; //選擇左屏
else cs1=0,cs2=1,c-=64; //選擇右屏
wc(0xb8+r);
wc(0x40+c);
wd(dat);
}
/** 讀當顯示數據 **/
uchar read(uchar r,uchar c){
uchar temp;
if(c<64)cs1=1,cs2=0; //選擇左屏
else cs1=0,cs2=1,c-=64; //選擇右屏
wc(0xb8+r);
wc(0x40+c);
P0=0xFF;
rs=1;rw=1;
en=1;en=0;delay(1); //讀空操作
en=1;temp=P0;en=0;//正式讀數據
return temp;
}
/** 反白顯示,參數:r為頁號,n為跨頁數,c為起始列,w為寬度 **/
void not(uchar r,uchar n,uchar c,uchar w){
uchar i,j=8;
for(j=r;j<r+n;j++)
for(i=c;i<c+w;i++)
wo(j,i,~read(j,i));
}
void clr1(uchar row,uchar col,uchar x,uchar y)
{
uchar i,j;
cs1=cs2=1;
for(i=0;i<y;i++)
{
wc(0xb8+row+i);
wc(0x40+col);
for(j=0;j<x;j++)wd(0);
}
}
void init12864()
{
P0=0xff;
wc(0x3f);
wc(0xc0);
clr();
}
void showxy(uchar row,uchar col,uchar x,uchar y,uchar *tab)
{
uchar i,j;
bit right;
if(col<64)right=0;
else {col-=64;right=1;}
for(i=0;i<y;i++)
{
if(right)cs1=0,cs2=1;
else cs1=1,cs2=0;
wc(0xb8+row+i);
wc(0x40+col);
for(j=0;j<x;j++)
{
if(col+j<64)wd(tab[i*x+j]);
else if(right==0)
{
cs1=0;cs2=1;
wc(0xb8+row+i);
wc(0x40+(col+j-64));
wd(tab[i*x+j]);
}
}
}
}
void menu0()
{
showxy(0,0,16,2,zm16x16[15]);
showxy(0,16,16,2,zm16x16[16]);
showxy(0,32,16,2,zm16x16[17]);
showxy(0,48,16,2,zm16x16[18]);
showxy(0,64,16,2,zm16x16[19]);
}
void menu1()
{
showxy(0,40,16,2,zm16x16[20]);
showxy(0,56,16,2,zm16x16[21]);
showxy(0,72,16,2,zm16x16[22]);
showxy(2,0,16,2,zm16x16[23]);
showxy(2,16,16,2,zm16x16[24]);
showxy(4,0,16,2,zm16x16[25]);
showxy(4,16,16,2,zm16x16[26]);
}
void menu2()
{
showxy(0,32,16,2,zm16x16[23]);
showxy(0,48,16,2,zm16x16[24]);
showxy(0,64,16,2,zm16x16[21]);
showxy(0,80,16,2,zm16x16[22]);
showxy(2,0,16,2,zm16x16[27]);
showxy(2,16,16,2,zm16x16[28]);
showxy(2,32,16,2,zm16x16[29]);
showxy(2,48,16,2,zm16x16[30]);
showxy(2,64,16,2,zm16x16[23]);
showxy(2,80,16,2,zm16x16[24]);
showxy(4,0,16,2,zm16x16[31]);
showxy(4,16,16,2,zm16x16[28]);
showxy(4,32,16,2,zm16x16[27]);
showxy(4,48,16,2,zm16x16[32]);
showxy(4,64,16,2,zm16x16[30]);
showxy(4,80,16,2,zm16x16[23]);
showxy(4,96,16,2,zm16x16[24]);
showxy(6,0,16,2,zm16x16[19]);
showxy(6,16,16,2,zm16x16[33]);
showxy(6,32,16,2,zm16x16[34]);
showxy(6,48,16,2,zm16x16[35]);
showxy(6,64,16,2,zm16x16[23]);
showxy(6,80,16,2,zm16x16[24]);
}
uchar j=0,ci=0,row=2,col=0,q=0,y;
void main()
{
init12864();
delay(1);
while(1)
{
while(sw==1)
{
while(ci==0){clr();menu0();ci++;}
q=0;
j=0;
}
while(sw==0)
{
switch(q)
{
case 0:
while(j==0){clr();j++;}
menu1();
if(key()==4||key()==0)q=1;
break;
case 1:
if(row<4&&key()==4){row+=2;}
else if(row>2&&key()==0){row-=2;}
else if(key()==2&row==2)q=2;
else if(key()==2&row==4)q=20;
<font color="#8b0000"> if(row==4)not(4,2,0,127);</font>
<font color="#ff0000"> else if(row==2)not(2,2,0,127);</font>
break;
case 2:
clr();
menu2();
q=4;
case 4:
if(row<6&&key()==4){while(key()==4);row+=2;}
else if(row>2&&key()==0){while(key()==0);row-=2;}
<font color="#ff0000"> if(row==4)not(4,2,0,127);
else if(row==2)not(2,2,0,127);
else if(row==6)not(6,2,0,127);</font>
}
ci=0;
}
}
}
// 1516171819202122232425262728293031323334353637383940414243
//uchar code zm16x16l[]="系統待機中主菜單設置運行裝箱總數每瓶獎幾率有狀態共第點";
|