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

📄 lprtpos1.c

📁 原创一个简单打小票POS机源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        wwr(0x5a00+x1,0);
        wwr(0x5c00+x1,0);
        wwr(0x5e00+x1,0);
        wwr(0x6000+x1,0);
        wwr(0x6200+x1,0);
      }
      for (x1=8;x1<15;x1++) 
      {
        wwr(0x5400+x1,time[x1-8]);
      }
    delay(3);
	   for (x1=0;x1<7;x1++)
	   {
	   wwr(0x5600+x1,time[x1]);
	   delay(1);
	   }
	   dday=time[3];   
}
else 
{
dday=wrd(0x540b);

if (dday==0xff){dday=time[3];}

      for (x1=0;x1<8;x1++) 
      {
        zdmoney[x1]=wrd(0x5400+x1);
        umoney1[x1]=wrd(0x5800+x1);
        umoney2[x1]=wrd(0x5a00+x1);
        umoney3[x1]=wrd(0x5c00+x1);
        umoney4[x1]=wrd(0x5e00+x1);
        umoney5[x1]=wrd(0x6000+x1);
        umoney6[x1]=wrd(0x6200+x1);
      }

		if (zdmoney[0]==0xff) 
		{
	      for(x1=0;x1<8;x1++)
    		 {
		      zdmoney[x1]=0;
		      umoney1[x1]=0;
		      umoney2[x1]=0;
		      umoney3[x1]=0;
		      umoney4[x1]=0;
		      umoney5[x1]=0;
		      umoney6[x1]=0;
		     }
    	}
	else 
	{
	 

	  if (umoney1[0]==0xff) 
	   {
	   for (x1=0;x1<8;x1++) {umoney1[x1]=0;}
	   }

	  if (umoney2[0]==0xff) 
	   {
	   for (x1=0;x1<8;x1++) {umoney2[x1]=0;}
	   }

	  if (umoney3[0]==0xff) 
	   {
	   for (x1=0;x1<8;x1++) {umoney3[x1]=0;}
	   }
	
	  if (umoney4[0]==0xff) 
	   {
   		for (x1=0;x1<8;x1++) {umoney4[x1]=0;}
		   }

	  if (umoney5[0]==0xff) 
	   {
	   for (x1=0;x1<8;x1++) {umoney5[x1]=0;}
	   }

	  if (umoney6[0]==0xff) 
	   {
	   for (x1=0;x1<8;x1++) {umoney6[x1]=0;}
	   }
  }


}
}

 /*day print clear?*/





/*模拟串口相关子程序11.0592MHZ*/
void IntTimer0() interrupt 1
{
F_TM=1;
}
/*发送一个字符*/
void PSendChar(UINT8 inch)
{
#ifdef MODE_QUICK
ACC=inch;

F_TM=0;
BT_SND=0; //start bit
TIMER0_ENABLE; /*启动*/
while(!F_TM);

BT_SND=ACC0; /*先送出低位*/
F_TM=0;
while(!F_TM);

BT_SND=ACC1;
F_TM=0;
while(!F_TM);

BT_SND=ACC2;
F_TM=0;
while(!F_TM);

BT_SND=ACC3;
F_TM=0;
while(!F_TM);

BT_SND=ACC4;
F_TM=0;
while(!F_TM);

BT_SND=ACC5;
F_TM=0;
while(!F_TM);

BT_SND=ACC6;
F_TM=0;
while(!F_TM);

BT_SND=ACC7;
F_TM=0;
while(!F_TM);

BT_SND=1;
F_TM=0;
while(!F_TM);


TIMER0_DISABLE; /*停止timer*/
#else
UINT8 ii;

ii=0;

F_TM=0;
BT_SND=0; /*start bit*/
TIMER0_ENABLE; /*启动*/
while(!F_TM);

while(ii<8)
{
if(inch&1)
{
BT_SND=1;
}
else
{
BT_SND=0;
}
F_TM=0;
while(!F_TM);
ii++;
inch>>=1;
}
BT_SND=1;
F_TM=0;
while(!F_TM);

#endif
TIMER0_DISABLE; /*停止timer*/
}
/*接收一个字符*/
/*
UINT8 PGetChar()
{
#ifdef MODE_QUICK

TIMER0_ENABLE;
F_TM=0;
while(!F_TM); *//*等过起始位*/
/*
ACC0=BT_REC;

TL0=TH0;

F_TM=0;
while(!F_TM);
ACC1=BT_REC;

F_TM=0;
while(!F_TM);
ACC2=BT_REC;

F_TM=0;
while(!F_TM);
ACC3=BT_REC;

F_TM=0;
while(!F_TM);
ACC4=BT_REC;

F_TM=0;
while(!F_TM);
ACC5=BT_REC;

F_TM=0;
while(!F_TM);
ACC6=BT_REC;

F_TM=0;
while(!F_TM);
ACC7=BT_REC;

F_TM=0;

while(!F_TM)
{
if(BT_REC)
{
break;
}
}
TIMER0_DISABLE;*/ /*停止timer*/
/*
return ACC;
#else
UINT8 rch,ii;
TIMER0_ENABLE;
F_TM=0;
ii=0;
rch=0;
while(!F_TM); *//*等过起始位*/
/*
while(ii<8)
{
rch>>=1;
if(BT_REC)
{
rch|=0x80;
}
ii++;
F_TM=0;
while(!F_TM);

}
F_TM=0;
while(!F_TM)
{
if(BT_REC)
{
break;
}

}
TIMER0_DISABLE;*/ /*停止timer*/
/*
return rch;

#endif

}
*//*注掉模拟接收字符函数2006-12-2*/
/*检查是不是有起始位*/
/*
bit StartBitOn()
{
return  (BT_REC==0);
}
*/
/*模拟串口相关子程序11.0592MHZ*/

/*小票打印相关子程序*/

void thanks(void)
{
UINT8 x1,x2;
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x09);/*2个空格*/
   PSendChar(0xb7);PSendChar(0xc0);/*防*/
   PSendChar(0xce);PSendChar(0xb1);/*伪*/
   PSendChar(0xb1);PSendChar(0xea);/*标*/
   PSendChar(0xbc);PSendChar(0xc7);/*记*/
   PSendChar(0xa3);PSendChar(0xba);/*:*/   
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
    PSendChar(0x1b);PSendChar(0x36);
/*0、1、2、3、4、5、6、7、8、9、.等字符*/
   PSendChar(0x20);
   
   x1=((time[6]^cred1)>>4); if (x1>9) {x1=15-x1+0x30;} else {x1=x1+0x30;}
   x2=(0x0f&(time[6]^cred1));if (x2>9) {x2=15-x2+0x30;} else {x2=x2+0x30;}
   PSendChar(x1);PSendChar(x2);
   x1=((time[5]^cred1)>>4);  if (x1>9) {x1=15-x1+0x30;} else {x1=x1+0x30;}
   x2=(0x0f&(time[5]^cred1));  if (x2>9) {x2=15-x2+0x30;} else {x2=x2+0x30;}
    PSendChar(x1);PSendChar(x2);
    x1=((time[3]^cred2)>>4);  if (x1>9) {x1=15-x1+0x30;} else {x1=x1+0x30;}
    x2=(0x0f&(time[3]^cred2));if (x2>9) {x2=15-x2+0x30;} else {x2=x2+0x30;}
    PSendChar(x1);PSendChar(x2);

   PSendChar(0x0D);/*换行   */
   PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x04
   );/*2个空格*/
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xb8);PSendChar(0xd0);/*感*/
   PSendChar(0xd0);PSendChar(0xbb);/*谢*/
   PSendChar(0xbb);PSendChar(0xdd);/*惠*/
   PSendChar(0xb9);PSendChar(0xcb);/*顾*/
   PSendChar(0xa3);PSendChar(0xac);/*,*/
   PSendChar(0xc7);PSendChar(0xeb);/*请*/
   PSendChar(0xb1);PSendChar(0xa3);/*保*/
   PSendChar(0xb4);PSendChar(0xe6);/*存*/
   PSendChar(0xba);PSendChar(0xc3);/*好*/
   PSendChar(0xd0);PSendChar(0xa1);/*小*/
   PSendChar(0xc6);PSendChar(0xb1);/*票*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/

   PSendChar(0x0D);/*换行   */
}

/*当日当次打印*/

void cred(UINT8 x1,x2)
{
erase(0x6400);
delay(3);
wwr(0x6400,x1);
wwr(0x6401,x2);
wwr(0x6402,time[3]);
}


void prtd(UINT8 money1,money2,money3,money4,money5)
{
 UINT8 x1,x2;
prtinit();

  while(busy);
  PSendChar(0x1B);PSendChar(0x40);/*打印机初始化*/
  PSendChar(0x1B);PSendChar(0x31);PSendChar(0x06);/*3点行间距*/
  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);/*换行   */
  
   thanks();
   PSendChar(0x0D);//换行  
  PSendChar(0x1b);PSendChar(0x36);/*字符集1*/
  for (x1=0;x1<14;x1++)
  {
   PSendChar(0x3d);PSendChar(0x20);/*=*/
  } 
   PSendChar(0x3d); 
   PSendChar(0x0D);//换行
   PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x06);/*2个空格*/
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xcf);PSendChar(0xd6);/*现*/
   PSendChar(0xbd);PSendChar(0xf0);/*金*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   PSendChar(0x1b);PSendChar(0x36);/*字符集1*/  
  for (x1=0;x1<7;x1++)
  {
  PSendChar(0x20); 
  } 
    PSendChar(0x20+money1);
    PSendChar(0x20+money2);PSendChar(0x20+money3);
    PSendChar(0x2e);PSendChar(0x30+money4);
    PSendChar(0x30+money5);
  PSendChar(0x0D);//换行
  PSendChar(0x1b);PSendChar(0x36);/*字符集1*/  
  for (x1=0;x1<14;x1++)
  {
   PSendChar(0x2d);PSendChar(0x20);/*-*/
  } 
   PSendChar(0x2d);
   
   PSendChar(0x0D);//换行
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xb2);PSendChar(0xbf);/*部*/
   PSendChar(0xc0);PSendChar(0xe0);/*类*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/  
   PSendChar(0x1b);PSendChar(0x36);/*字符集1*/   
   PSendChar(0x30);PSendChar(0x30+unit); 
   for (x1=0;x1<14;x1++)
  {
  PSendChar(0x20);
  } 
    PSendChar(0x20+money1);
    PSendChar(0x20+money2);PSendChar(0x20+money3);
    PSendChar(0x2e);PSendChar(0x30+money4);
    PSendChar(0x30+money5);
   
  PSendChar(0x0D);//换行
  PSendChar(0x1b);PSendChar(0x36);/*字符集1*/  
  for (x1=0;x1<14;x1++)
  {
   PSendChar(0x2d);PSendChar(0x20);/*-*/
  } 
    PSendChar(0x2d);
    
   PSendChar(0x0D);//换行
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xc8);PSendChar(0xd5);/*日*/
   PSendChar(0xc6);PSendChar(0xda);/*期*/
//   PSendChar(0xa3);PSendChar(0xba);/*:*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
/*打印日期数字*/
   PSendChar(0x1B);PSendChar(0x36); PSendChar(0x3a);

/*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(0x20);
  
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xca);PSendChar(0xb1);/*时*/
   PSendChar(0xbc);PSendChar(0xe4);/*间*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
     
     
     
    PSendChar(0x1B);PSendChar(0x36); PSendChar(0x3a);
    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(0x3a);
    x1=((time[0]/16)+0x30);x2=((time[0]%16)+0x30);
    PSendChar(x1);PSendChar(x2);          
   
   
   PSendChar(0x0D);//换行
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xca);PSendChar(0xd5);/*收*/
   PSendChar(0xbe);PSendChar(0xdd);/*据*/   
   PSendChar(0xba);PSendChar(0xc5);/*号*/   
   //PSendChar(0xa3);PSendChar(0xba);/*:*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   PSendChar(0x1b);PSendChar(0x36);/*字符集1*/
    PSendChar(0x3a);

   
  for (x1=0;x1<4;x1++)
  {
   PSendChar(0x30);/*0*/
  } 
  PSendChar(0x23);/*#*/  
    x1=((cred2/10)+0x30);x2=((cred2%10)+0x30);
    PSendChar(x1);PSendChar(x2);
    x1=((cred1/10)+0x30);x2=((cred1%10)+0x30);
    PSendChar(x1);PSendChar(x2);
   PSendChar(0x20);
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xca);PSendChar(0xd5);/*收*/
   PSendChar(0xbf);PSendChar(0xee);/*款*/   
//   PSendChar(0xa3);PSendChar(0xba);/*:*/
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   
    PSendChar(0x1b);PSendChar(0x36);/*字符集1*/  
    PSendChar(0x3a);

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xca);PSendChar(0xd5);/*收*/
   PSendChar(0xbf);PSendChar(0xee);/*款*/   
   PSendChar(0xd4);PSendChar(0xb1);/*员*/   
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
   PSendChar(0x1b);PSendChar(0x36);/*字符集1*/
   PSendChar(0x30);PSendChar(0x31);    

   PSendChar(0x0D);//换行
   PSendChar(0x1b);PSendChar(0x36);/*字符集1*/

  for (x1=0;x1<14;x1++)
  {
   PSendChar(0x3d);PSendChar(0x20);/*=*/
  } 
   PSendChar(0x3d); 
   PSendChar(0x0D);//换行
   PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x0a);/*2个空格*/
   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
   PSendChar(0xca);PSendChar(0xd5);/*收*/
   PSendChar(0xd2);PSendChar(0xf8);/*银*/   
   PSendChar(0xc6);PSendChar(0xbe);/*凭*/
   PSendChar(0xbe);PSendChar(0xdd);/*据*/   
   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
 
   PSendChar(0x0D);//换行
   
   
   /*设置大字体*/
 //  PSendChar();
   PSendChar(0x1B);PSendChar(0x55);PSendChar(1);/*汉字放大*/
   PSendChar(0x1B);PSendChar(0x56);PSendChar(2);/*汉字放大*/
//
  PSendChar(0x1B);PSendChar(0x66);PSendChar(0);PSendChar(0x06);/*2个空格*/
 //   PSendChar(0x1C);PSendChar(0x0e);/*汉字放大*/
  // PSendChar(0x1B);PSendChar(0x55);PSendChar(0);PSendChar(0x02);/*2个空格*/

   PSendChar(0x1c);PSendChar(0x26);/*进入汉字打印模式*/
//   PSendChar(0x1C);PSendChar(0x57);PSendChar(2);/*汉字放大*/
   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(0x57);PSendChar(1);/*汉字放大*/

   PSendChar(0x1c);PSendChar(0x2E);/*退出汉字打印模式*/
 //  PSendChar(0x1C);PSendChar(0x57);PSendChar(1);/*汉字放大*/

⌨️ 快捷键说明

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