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

📄 lprtpos.c

📁 原创一个简单打小票POS机源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
              {        
 
              if ((ncount<4)&&(dott<2))
                 {        
     
                  money[5]=money[4];
                  money[4]=money[3];
                  money[3]=money[2];
                  money[2]=money[1];
                  money[1]=money[0];
                  money[0]=led[pjz];
                  
                  prtm5=prtm4;
                  prtm4=prtm3;
                  prtm3=prtm2;
                  prtm2=prtm1;
                  prtm1=prtm0;
                  prtm0=pjz;                                    
                 }
                 if ((dotbj==1)&&(dott<2)) {dott++;}
                if ((ncount==0x01)&&(dotbj==0)) 
                  {
                   money[0]=money[0]+0x08;dotbj=1;
                  }
              ncount++;             
               pjz=0xff;
              }
              else if ((pjz==0x0a)&&(dotbj==0))
              {
              if (ncount>0) {money[ncount-1]=money[ncount-1]+0x08;dotbj=1;}
                else {money[ncount]=money[ncount]+0x08;dotbj=1;}
               }
         //  if (ncount>=2)  ncount=0;
             if (pjz==0x0b)
              {  
                ncount=0; pjz=0xff;
                    /*进行累加放入dataflash中打出小票zmoney1,zmoney2,zmoney0thy*/  
                   // prt(); zmoney0       
                // if (Lockbj==1)    
               // {
                   if (dott==2)           
                   {
                   if (prtm4>0) {prtm4=prtm4+0x10;prtm3=prtm3+0x10;prtm2=prtm2+0x10;}
                   else if (prtm3>0) {prtm3=prtm3+0x10;prtm2=prtm2+0x10;}
                   else {prtm2=prtm2+0x10;}
                   cred1++;
                   if (cred1>99) {cred1=0;cred2++;
                   if (cred2>99){cred2=0;}
                     }
                   prtd(prtm4,prtm3,prtm2,prtm1,prtm0);
                   dadd(prtm0,prtm1,prtm2,prtm3,prtm4);  
                   madd(prtm0,prtm1,prtm2,prtm3,prtm4);                        	 
                  
                   }
                   else if (dott==1)
                   {
                   if (prtm3>0) {prtm3=prtm3+0x10;prtm2=prtm2+0x10;prtm1=prtm1+0x10;}
                   else if (prtm2>0) {prtm1=prtm1+0x10;prtm2=prtm2+0x10;}
                   else {prtm1=prtm1+0x10;}
                   
                   cred1++;
                   if (cred1>99) {cred1=0;cred2++;
                   if (cred2>99){cred2=0;}
                   }
                   prtd(prtm3,prtm2,prtm1,prtm0,0);  
                   dadd(0,prtm0,prtm1,prtm2,prtm3);  
                   madd(0,prtm0,prtm1,prtm2,prtm3);                   
                                                      
                   }
                   else if (dott==0)
                   {
                   if (prtm2>0) {prtm0=prtm0+0x10;prtm2=prtm2+0x10;prtm1=prtm1+0x10;}
                   else if (prtm1>0) {prtm1=prtm1+0x10;prtm0=prtm0+0x10;}
                   else {prtm0=prtm0+0x10;}
                   cred1++;
                   if (cred1>99) {cred1=0;cred2++;
                   if (cred2>99){cred2=0;}
                   }
                   prtd(prtm2,prtm1,prtm0,0,0);   
                   dadd(0,0,prtm0,prtm1,prtm2);  
                   madd(0,0,prtm0,prtm1,prtm2);                   

                   }
              /* }
                else {
                       for (i=0;i<100;i++) errshow();
		      P0=0;P2=P2&0xf6;P2=P2|0x09;      
		     delay(200);
         	    for (i=0;i<100;i++) errshow();
		      P0=0;P2=P2&0xf6;P2=P2|0x09;      
		     delay(200);
		    for (i=0;i<100;i++) errshow();     

                }
*/
                break;  
                                       
                }       
            if (pjz==0x0e) {pjz=0xff;break; }     

	    }

}

/*x类单一报表2006-09-29*/
void uxreport(void)
{
 UINT8 x1,x2;
 UINT8 umoney[8];
 switch (unit)
 {
 case 1:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney1[x1];
  break;
 case 2:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney2[x1];
  break;
 case 3:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney3[x1];
  break;
 case 4:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney4[x1];
  break;
 case 5:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney5[x1];
  break;
 case 6:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney6[x1];
  break;
 default:
 for (x1=0;x1<8;x1++) umoney[x1]=0;
 break;
 } 
 while(busy);
   PSendChar(0x1B);PSendChar(0x40);/*打印机初始化*/

  PSendChar(0x1B);PSendChar(0x31);PSendChar(0x06);/*6点行间距*/
  PSendChar(0x1B);PSendChar(0x66);PSendChar(1);PSendChar(0x02);/*2个空行*/
  PSendChar(0x1B);PSendChar(0x6C);PSendChar(0);  /*设置左限*/
  PSendChar(0x1B);PSendChar(0x51);PSendChar(0);/*设置右限*/
  PSendChar(0x1B);PSendChar(0x70);PSendChar(1);/*字符间距为2*/  

  PSendChar(0x0D);//换行
  PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x08);/*8个空格*/
  
  
  
   
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xa1);PSendChar(0xef);/*#*/
   PSendChar(0xb1);PSendChar(0xa3);/*保*/
   PSendChar(0xb6);PSendChar(0xa8);/*定*/
   PSendChar(0xd2);PSendChar(0xf8);/*银*/
   PSendChar(0xba);PSendChar(0xd3);/*河*/
   PSendChar(0xbf);PSendChar(0xa8);/*卡*/
   PSendChar(0xa1);PSendChar(0xef);/*#*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   PSendChar(0x0D);/*换行   */

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xc0);PSendChar(0xdb);/*累*/
   PSendChar(0xbc);PSendChar(0xc6);/*计*/
   PSendChar(0xbd);PSendChar(0xf0);/*金*/
   PSendChar(0xb6);PSendChar(0xee);/*额*/
   PSendChar(0xa3);PSendChar(0xba);/*:*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/

/*金额数字*/
 /*选择字符集1*/
    PSendChar(0x1b);PSendChar(0x36);
/*0、1、2、3、4、5、6、7、8、9、.等字符*/
    if (umoney[7]==0)
     {PSendChar(0x20);
    
        if (umoney[6]==0) 
           {PSendChar(0x20);
            		if (umoney[5]==0)
            		{PSendChar(0x20);
            		          if (umoney[4]==0)
            		            {PSendChar(0x20);
					     if (umoney[3]==0)
					     {PSendChar(0x20);
					      PSendChar(0x30+umoney[2]);
					      PSendChar(0x2e);
					      PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);					     
					     
					     }
					     else
					     {
					      PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
					      PSendChar(0x2e);
					      PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);					     
					     }
            		          
            		                 }
            		          else {
            		              PSendChar(0x30+umoney[4]);
				      PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
				      PSendChar(0x2e);
				      PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);
            		          }
            		}
            	else
            	{
            	 PSendChar(0x30+umoney[5]);PSendChar(0x30+umoney[4]);
 		 PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
		 PSendChar(0x2e);
		 PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);
            	}
            }
            else
            {
            PSendChar(0x30+umoney[6]);
	    PSendChar(0x30+umoney[5]);PSendChar(0x30+umoney[4]);
	    PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
	    PSendChar(0x2e);
	    PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);            
            }    
    }
    
    else
    {
    PSendChar(0x30+umoney[7]);PSendChar(0x30+umoney[6]);
    PSendChar(0x30+umoney[5]);PSendChar(0x30+umoney[4]);
    PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
    PSendChar(0x2e);
    PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);
    }
   PSendChar(0x0D);//换行
  for (x1=0;x1<14;x1++)
  {
   PSendChar(0x2d);PSendChar(0x20);/*-*/
  } 
   PSendChar(0x2d);
   PSendChar(0x0D);//换行

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
//   PSendChar(0xb4);PSendChar(0xf2);/*打*/
//   PSendChar(0xd3);PSendChar(0xa1);/*印*/
   
   PSendChar(0xc8);PSendChar(0xd5);/*日*/
   PSendChar(0xc6);PSendChar(0xda);/*期*/
   PSendChar(0xca);PSendChar(0xb1);/*时*/
   PSendChar(0xbc);PSendChar(0xe4);/*间*/
   PSendChar(0xa3);PSendChar(0xba);/*:*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
/*打印日期数字*/
   PSendChar(0x1b);PSendChar(0x36);
/*0、1、2、3、4、5、6、7、8、9、.等字符*/
    PSendChar(0x32);PSendChar(0x30);
    x1=((time[6]>>4)+0x30);x2=((0x0f&time[6])+0x30);
    PSendChar(x1);PSendChar(x2);
    PSendChar(0x2d);
    x1=((time[5]>>4)+0x30);x2=((0x0f&time[5])+0x30);
    PSendChar(x1);PSendChar(x2);
     PSendChar(0x2d);
    x1=((time[3]>>4)+0x30);x2=((0x0f&time[3])+0x30);
    PSendChar(x1);PSendChar(x2);

    PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x02);/*2个空格*/
    x1=((time[2]/16)+0x30);x2=((time[2]%16)+0x30);
    PSendChar(x1);PSendChar(x2);
    PSendChar(0x3a);
    x1=((time[1]/16)+0x30);x2=((time[1]%16)+0x30);
    PSendChar(x1);PSendChar(x2);

   PSendChar(0x0D);//换行
   PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x0a);/*10个空格*/

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xb2);PSendChar(0xbf);/*部类报表*/
   PSendChar(0xc0);PSendChar(0xe0);
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
 /*选择字符集1*/
    PSendChar(0x1b);PSendChar(0x36);
   PSendChar(0x30);PSendChar(0x30+unit);

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/   
   PSendChar(0xb1);PSendChar(0xa8);
   PSendChar(0xb1);PSendChar(0xed);
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   PSendChar(0x0D);//换行   
   
   
  PSendChar(0x1b);PSendChar(0x56);PSendChar(2);/*汉字放大*/
  PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x06);/*2个空格*/
 
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xd2);PSendChar(0xf8);/*银*/
   PSendChar(0xba);PSendChar(0xd3);/*河*/
   PSendChar(0xbf);PSendChar(0xa8);/*卡*/
   PSendChar(0xcf);PSendChar(0xb5);/*系*/
   PSendChar(0xc1);PSendChar(0xd0);/*列*/
   PSendChar(0xca);PSendChar(0xd5);/*收*/
   PSendChar(0xd2);PSendChar(0xf8);/*银*/   
   PSendChar(0xbb);PSendChar(0xfa);/*机*/   
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/

   PSendChar(0x0D);//换行
   PSendChar(0x1B);PSendChar(0x66);PSendChar(1);PSendChar(0x05);/*5空行*/ 
unit=0;   
}
/*X类单一报表2006-09-29*/

/*ureport*/
void ureport(UINT8 xx)
{
 UINT8 x1,x2;
 UINT8 umoney[8];
 UINT16 hmoney;
 switch (xx)
 {
 case 5:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney6[x1];
  break;
 case 4:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney5[x1];
  break;
 case 3:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney4[x1];
  break;
 case 2:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney3[x1];
  break;
 case 1:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney2[x1];
  break;
 case 0:
  for (x1=0;x1<8;x1++) umoney[x1]=umoney1[x1];
  break;
 default:
 for (x1=0;x1<8;x1++) umoney[x1]=0;
 break;
 } 
 hmoney=umoney[7]*100000+umoney[6]*10000+umoney[5]*1000+umoney[4]*100+umoney[3]*10+umoney[2];
  x1=umoney[1]*10+umoney[0];
 if ((hmoney>0)|(x1>0))
 {
 // while(busy);
    PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x03);/*3个空格*/

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xb2);PSendChar(0xbf);/*部类报表*/
   PSendChar(0xc0);PSendChar(0xe0);
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
 /*选择字符集1*/
    PSendChar(0x1b);PSendChar(0x36);
   PSendChar(0x30);PSendChar(0x31+xx);

  PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x05);/*5个空格*/

 /*选择字符集1*/
    PSendChar(0x1b);PSendChar(0x36);
/*0、1、2、3、4、5、6、7、8、9、.等字符*/
    if (umoney[7]==0)
     {PSendChar(0x20);
    
        if (umoney[6]==0) 
           {PSendChar(0x20);
            		if (umoney[5]==0)
            		{PSendChar(0x20);
            		          if (umoney[4]==0)
            		            {PSendChar(0x20);
					     if (umoney[3]==0)
					     {PSendChar(0x20);
					      PSendChar(0x30+umoney[2]);
					      PSendChar(0x2e);
					      PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);					     
					     
					     }
					     else
					     {
					      PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
					      PSendChar(0x2e);
					      PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);					     
					     }
            		          
            		                 }
            		          else {
            		              PSendChar(0x30+umoney[4]);
				      PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
				      PSendChar(0x2e);
				      PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);
            		          }
            		}
            	else
            	{
            	 PSendChar(0x30+umoney[5]);PSendChar(0x30+umoney[4]);
 		 PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
		 PSendChar(0x2e);
		 PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);
            	}
            }
            else
            {
            PSendChar(0x30+umoney[6]);
	    PSendChar(0x30+umoney[5]);PSendChar(0x30+umoney[4]);
	    PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
	    PSendChar(0x2e);
	    PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);            
            }    
    }
    
    else
    {
    PSendChar(0x30+umoney[7]);PSendChar(0x30+umoney[6]);
    PSendChar(0x30+umoney[5]);PSendChar(0x30+umoney[4]);
    PSendChar(0x30+umoney[3]);PSendChar(0x30+umoney[2]);
    PSendChar(0x2e);
    PSendChar(0x30+umoney[1]);PSendChar(0x30+umoney[0]);
    }
     PSendChar(0x0D);//换行

 }
 
}
/*ureport*/

/*X类总报表*/
void xreport(void)
{
 UINT8 x1,x2,phour,pmin,shour,smin,sday;
 bit ubj;
 while(busy);
   PSendChar(0x1B);PSendChar(0x40);/*打印机初始化*/

  PSendChar(0x1B);PSendChar(0x31);PSendChar(0x06);/*6点行间距*/
  PSendChar(0x1B);PSendChar(0x66);PSendChar(1);PSendChar(0x02);/*2个空行*/
  PSendChar(0x1B);PSendChar(0x6C);PSendChar(0);  /*设置左限*/
  PSendChar(0x1B);PSendChar(0x51);PSendChar(0);/*设置右限*/
  PSendChar(0x1B);PSendChar(0x70);PSendChar(1);/*字符间距为2*/  

    PSendChar(0x0D);//换行
    PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x08);/*2个空格*/
   
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xa1);PSendChar(0xef);/*#*/
   PSendChar(0xb1);PSendChar(0xa3);/*保*/
   PSendChar(0xb6);PSendChar(0xa8);/*定*/
   PSendChar(0xd2);PSendChar(0xf8);/*银*/
   PSendChar(0xba);PSendChar(0xd3);/*河*/
   PSendChar(0xbf);PSendChar(0xa8);/*卡*/
   PSendChar(0xa1);PSendChar(0xef);/*#*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   PSendChar(0x0D);/*换行   */

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xc0);PSendChar(0xdb);/*累*/
   PSendChar(0xbc);PSendChar(0xc6);/*计*/
   PSendChar(0xbd);PSendChar(0xf0);/*金*/
   PSendChar(0xb6);PSendChar(0xee);/*额*/
   PSendChar(0xa3);PSendChar(0xba);/*:*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/

/*金额数字*/
 /*选择字符集1*/
    PSendChar(0x1b);PSendChar(0x36);
/*0、1、2、3、4、5、6、7、8、9、.等字符*/
    if (zdmoney[7]==0)
     {PSendChar(0x20);
    
        if (zdmoney[6]==0) 
           {PSendChar(0x20);
            		if (zdmoney[5]==0)
            		{PSendChar(0x20);
            		          if (zdmoney[4]==0)
            		            {PSendChar(0x20);
					     if (zdmoney[3]==0)
					     {PSendChar(0x20);
					      PSendChar(0x30+zdmoney[2]);
					      PSendChar(0x2e);
					      PSendChar(0x30+zdmoney[1]);PSendChar(0x30+zdmoney[0]);					     
					     
					     }
					     else
					     {
					      PSendChar(0x30+zdmoney[3]);PSendChar(0x30+zdmoney[2]);
					      PSendChar(0x2e);
					      PSendChar(0x30+zdmoney[1]);PSendChar(0x30+zdmoney[0]);					     
					     }
            		          
            		                 }
            		          else {
            		              PSendChar(0x30+zdmoney[4]);
				      PSendChar(0x30+zdmoney[3]);PSendChar(0x30+zdmoney[2]);
				      PSendChar(0x2e);
				      PSendChar(0x30+zdmoney[1]);PSendChar(0x30+zdmoney[0]);
            		          }
            		}
            	else
            	{
            	 PSendChar(0x30+zdmoney[5]);PSendChar(0x30+zdmoney[4]);
 		 PSendChar(0x30+zdmoney[3]);PSendChar(0x30+zdmoney[2]);
		 PSendChar(0x2e);
		 PSendChar(0x30+zdmoney[1]);PSendChar(0x30+zdmoney[0]);
            	}
            }
            else
            {
            PSendChar(0x30+zdmoney[6]);
	    PSendChar(0x30+zdmoney[5]);PSendChar(0x30+zdmoney[4]);
	    PSendChar(0x30+zdmoney[3]);PSendChar(0x30+zdmoney[2]);
	    PSendChar(0x2e);
	    PSendChar(0x30+zdmoney[1]);PSendChar(0x30+zdmoney[0]);            
            }    
    }
    
    else
    {
    PSendChar(0x30+zdmoney[7]);PSendChar(0x30+zdmoney[6]);
    PSendChar(0x30+zdmoney[5]);PSendChar(0x30

⌨️ 快捷键说明

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