⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yibiao1.c

📁 这是我在我们公司做的C51加油单片机程序
💻 C
📖 第 1 页 / 共 5 页
字号:
                            card_err_state=ver_pin();
                            if (card_err_state==0)
                                break;
                            else
                            {
                                clear();
                                xs_hhz(0,0,MMCWQCS);
                            }
                         }
                   }
                   if (card_err_state==0)
                   {
                       clear();
                       xs_hhz(0,0,ZAXZHMD);/*查找黑名单*/
                       clear();
                       if (yhkjycz())
                       {
                             xs_hhz(0,24,JYWC);
                             out_card();
                             goto j3;
                       }
                       else
                          goto j3;
                  }
               }
        }
        if (key=='x')/*处理加油机下班*/
        {
j5:
              clear();
              xs_hhz(2,32,XB);
              while(1)
              {
                      key=getkey();
                      if (key=='l')
                         goto j2;
                      if (key=='k')
                         break;
              }
              clear();
              xs_hhz(0,0,QSRYGMM);
              i=password(0);
              if (i==2)/*返回退卡*/
              {
                   out_card();
                   goto j3;
              }
              if (i==1) /*密码正确*/
              {
                   out_card();
                   goto start;
              }
              if (i==0)/*密码错误*/
              {
                   out_card();
                   goto j3;
              }
        }
        if  (key=='.')
        {
                while(1)
                {
                        key=getkey();
                        if (key!=0xff)
                        if (key=='k')
                           goto j5;
                        else
                           goto j4;
                }
        }
        xs_time();
   }
}
/*主程序结束*/
uint dw_zk(uint qw)
{
        union
        {
                uint int_z;
                unsigned char ch_z[2];
         } xdata zk;
         union
        {
                ulong int_z1;
                uint ch_z1[2];
         } xdata zk1;
        ulong w1;

        zk.int_z=qw;
        w1=94*(zk.ch_z[0]-0xa1)+(zk.ch_z[1]-0xa1);
        zk1.int_z1=w1*32;
        zk.int_z=zk1.ch_z1[0];
        ZK_CS=1;
        XBYTE[0xc011]=zk.ch_z[1];
        return  zk1.ch_z1[1];
     }
void dl(uint xdata t)
{
		uint xdata i,j;
		for(i=0;i<t;i++)
			for(j=0;j<100;j++);

}
void write_control(unsigned char con)
{
        RW=0;
        RS=0;
        E=con;
}
void write_data(unsigned char d)
{
        RW=0;
        RS=1;
     	E=d;
}

void init_xs()
{
	unsigned char page;
        write_control(0x3f);
        write_control(0xc0);
	for(page=0;page<8;page++)
	{
		clr_hang(page);
	}

}
void clear()
{
	unsigned char page;

	for(page=0;page<6;page++)
	{
		clr_hang(page);
	}

}
unsigned char getkey()
{
	unsigned char temp,i;
        static bit keyf=1;
        key_dlu();
        key_dlu();
        for(i=0;i<21;i++)
	{
                if (i==0)
                   KEY_SDA=0;
                else
                    KEY_SDA=1;
                KEY_CLK=1;
		dlu();
		KEY_CLK=0;
		dlu();
                temp=XBYTE[0xc010];
                temp=temp&0x01;
                if (temp==0)
                {
                        if (keyf==1)
                           switch (i)
                           {
                                case 1:{keyf=0;return 8;}
                                case 2:{keyf=0;return 7;}
                                case 3:{keyf=0;return 6;}
                                case 4:{keyf=0;return 5;}
                                case 5:{keyf=0;return 4;}
                                case 6:{keyf=0;return 3;}
                                case 7:{keyf=0;return 2;}
                                case 8:{keyf=0;return 1;}
                                case 9:{keyf=0;return 'k';}
                                case 10:{keyf=0;return 'l';}
                                case 11:{keyf=0;return '.';}
                                case 12:{keyf=0;return 0;}
                                case 13:{keyf=0;return 'j';}
                                case 14:{keyf=0;return 'e';}
                                case 15:{keyf=0;return 'g';}
                                case 16:{keyf=0;return 9;}
                                case 17:{keyf=0;return 't';}
                                case 18:{keyf=0;return 'x';}
                                case 19:{keyf=0;return 's';}
                           }else return 0xff;
                }
	}
       keyf=1;
       return 0xff;
}
void clr_hang(unsigned char hang)
{
	unsigned char lie;

        xscs1();
	write_control(0xb8+hang);
	for(lie=0;lie<64;lie++)
	{
		write_control(0x40+lie);
		write_data(0);
	}
        xscs2();
        write_control(0xb8+hang);
	for(lie=0;lie<64;lie++)
	{
		write_control(0x40+lie);
		write_data(0);
	}

}
void xs_zi(unsigned char hh,unsigned char ll,uint p)
{
	unsigned char idata i;
        unsigned char idata buf;
        uint idata temp;
        unsigned char disp_suf[32];
        temp=dw_zk(p);
        for(i=0;i<32;i++)
        {
            ZK_CS=0;
            buf=XBYTE[temp+i];
            ZK_CS=1;
            disp_suf[i]=buf;
            dlu();
        }
        ZK_CS=1;
        xscs1();
	for(i=0;i<16;i++)
	{
		if ((ll+i)>63)
		{
			xscs2();
			write_control(0xb8+hh);
			write_control(0x40+ll+i-64);
		}
		else
		{
			xscs1();
			write_control(0xb8+hh);
			write_control(0x40+ll+i);
		}
		write_data(disp_suf[i]);
		//p++;
	}

	for(i=0;i<16;i++)
	{
		if ((ll+i)>63)
		{
			xscs2();
			write_control(0xb8+hh+1);
			write_control(0x40+ll+i-64);
		}
		else
		{
			xscs1();
			write_control(0xb8+hh+1);
			write_control(0x40+ll+i);
		}
		write_data(disp_suf[i+16]);
	//	p++;
	}

}
void xscs1()
{
        CS1=1;
        CS2=0;
}
void xscs2()
{
        CS1=0;
        CS2=1;
}
 void dlu()
{
	_nop_();
	_nop_();
	_nop_();
	_nop_();
}
void key_dlu()
{
        uint k;
        for(k=0;k<2400;k++);
}
void xs_hhz(unsigned char hh,unsigned char ll, uint *p)
{
        unsigned char i;
        for(i=0;*(p+i)!=0;i++)
                if (*(p+i)!=0xffff)
                   xs_zi(hh,ll+i*16,*(p+i));
}
bit strcomp(unsigned char *p1,unsigned char *p2,unsigned char num)
{
        unsigned char i;
        for(i=0;i<num;i++)
        {
                if ((*(p1+i))!=(*(p2+i)))
                   return 0;
        }
        return 1;
}
void astobcd(unsigned char n)
{
      char l,temp;
      if (n==1) return;
      for(l=key_buf_p;l<6;l++)
      key_buf[l]=0x00;
      for(l=0;l<n;l+=2)
      {
            temp=key_buf[l]<<4;
            temp=temp|key_buf[l+1];
            key_buf[l/2]=temp;
      }
}
void jezh1()
{
      union{
            ulong da;
            unsigned char aa[4];
        }xdata jes;
        ulong xdata temp;
        unsigned char xdata i=0,g=0;
        huakuang(4,7,0);
        jes.aa[0]=balance[0];
        jes.aa[1]=balance[1];
        jes.aa[2]=balance[2];
        jes.aa[3]=balance[3];
        temp=jes.da/1000000000;
        if (temp!=0)
        {
                xs_shu(4,3*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*1000000000;
        temp=jes.da/100000000;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,4*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*100000000;
        temp=jes.da/10000000;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,5*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*10000000;
        temp=jes.da/1000000;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,6*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*1000000;
        temp=jes.da/100000;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,7*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*100000;
        temp=jes.da/10000;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,8*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*10000;
        temp=jes.da/1000;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,9*8,yi_1+(temp*8));
                i++;
        }
        jes.da=jes.da-temp*1000;
        temp=jes.da/100;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,10*8,yi_1+(temp*8));
                i++;
        }
        if (i==0)
        {
             g=1;
             xs_shu(4,10*8,yi_1);

        }
        xs_shu(4,11*8,yi_1+(11*8));
        i++;
        jes.da=jes.da-temp*100;
        temp=jes.da/10;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,12*8,yi_1+(temp*8));
                i++;
        }
        temp=jes.da-temp*10;
        if ((temp!=0)||(i!=0))
        {
                xs_shu(4,13*8,yi_1+(temp*8));
                i++;
        }
}
void xs_key_buf(unsigned char num)
{
        unsigned char i;
        for(i=0;i<num;i++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -