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

📄 dy.c

📁 打印机控制程序
💻 C
字号:
#include <reg52.h>
#include"intrins.h"

#define uchar unsigned char
#define uint unsigned int

sbit PRINT_BUSY = P1^1;


uchar print_hzinit[4]={0x1b,0x56,0x01,0x00};
//永泰和电子
uchar code print_example[24][15]={
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
0x00,0x00,0x00, 0x00,0x20,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 
0x00,0x38,0x00, 0x00,0x30,0x00, 0x00,0x30,0x00, 0x00,0x18,0x00, 0x00,0x00,0x10, 
0x00,0x08,0x00, 0x00,0x20,0x10, 0x00,0xf0,0x00, 0x00,0x10,0x00, 0x0f,0xff,0xf0,
0x00,0x08,0x00, 0x1f,0xff,0xf8, 0x1f,0x00,0x08, 0x00,0x10,0x00, 0x00,0x00,0x60,
0x00,0x00,0x00, 0x00,0x20,0x00, 0x01,0x03,0xfc, 0x00,0x10,0x00, 0x00,0x00,0x80,
0x00,0x08,0x00, 0x00,0x20,0x00, 0x01,0x02,0x08, 0x0f,0xff,0xf0, 0x00,0x01,0x00,
0x03,0xf8,0x30, 0x0f,0xff,0xe0, 0x01,0x02,0x08, 0x08,0x10,0x20, 0x00,0x16,0x00,                                             
0x00,0x18,0x30,	0x00,0x60,0x00, 0x01,0x1a,0x08, 0x08,0x10,0x20,	0x00,0x18,0x00,
0x00,0x18,0x60, 0x00,0x40,0x08, 0x1f,0xe2,0x08, 0x08,0x10,0x20, 0x00,0x08,0x00,
0x00,0x9c,0xc0, 0x7f,0xff,0xf8, 0x01,0x02,0x08, 0x08,0x10,0x20, 0x00,0x08,0x0c,
0x3f,0xdd,0x00, 0x00,0x82,0x00, 0x03,0x82,0x08, 0x08,0x10,0x20, 0x7f,0xff,0xfe,
0x01,0x9a,0x00, 0x01,0x81,0x00, 0x03,0x62,0x08, 0x0f,0xff,0xe0, 0x00,0x08,0x00,
0x01,0x1a,0x00, 0x01,0x19,0x80, 0x07,0x32,0x08, 0x08,0x10,0x20, 0x00,0x08,0x00,
0x03,0x19,0x00, 0x02,0x10,0xc0, 0x05,0x1a,0x08, 0x08,0x10,0x20, 0x00,0x08,0x00,
0x02,0x19,0x80, 0x05,0x11,0x60, 0x09,0x02,0x08, 0x08,0x10,0x20, 0x00,0x08,0x00,
0x06,0x18,0xc0, 0x08,0x92,0xb8, 0x11,0x02,0x08, 0x08,0x10,0x20, 0x00,0x08,0x00,
0x04,0x18,0x60, 0x10,0x9c,0x1e, 0x21,0x03,0xf8, 0x0f,0xff,0xe0, 0x00,0x08,0x00,
0x08,0x18,0x30, 0x60,0x14,0x00, 0x41,0x02,0x08, 0x08,0x10,0x00, 0x00,0x08,0x00,
0x18,0x18,0x1c, 0x03,0xd3,0x80, 0x01,0x02,0x08, 0x00,0x10,0x08, 0x00,0x08,0x00,
0x30,0x18,0x08, 0x0c,0x10,0xc0, 0x01,0x00,0x00, 0x00,0x10,0x04, 0x00,0x18,0x00,
0x40,0xf8,0x00, 0x08,0xb0,0x40, 0x01,0x80,0x00, 0x00,0x18,0x0e, 0x00,0xf8,0x00,
0x00,0x30,0x00, 0x00,0x70,0x00, 0x01,0x00,0x00, 0x00,0x0f,0xfc, 0x00,0x30,0x00,
0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,	0x00,0x00,0x00,	0x00,0x00,0x00};								









code unsigned char print_da[24][3]={0x00,0x00,0x00,0x01,0x80,0x00,0x01,0xc0,0x00,0x01,0xc0,0x00,
0x01,0xc0,0x00,0x01,0x80,0xfc,0x01,0x9f,0xfe,0x01,0xfe,0xc0,
0x1f,0xc0,0xc0,0x0d,0x80,0xc0,0x01,0xe0,0xc0,0x01,0xc0,0xc0,
0x01,0x80,0xc0,0x07,0x80,0xc0,0x1f,0x80,0xc0,0x79,0x80,0xc0,
0x71,0x80,0xc0,0x01,0x86,0xc0,0x07,0x83,0xc0,0x03,0x81,0xc0,
0x03,0x81,0xc0,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00};     //打

code unsigned char print_yin[24][3]={0x00,0x00,0x00,0x00,0xc0,0x00,0x01,0xe0,0x00,0x01,0xe0,0x00,
0x03,0x80,0xf8,0x3e,0x0f,0xf8,0x38,0x0c,0x38,0x18,0xcc,0x30,
0x1b,0xcc,0x30,0x1f,0x0c,0x30,0x18,0x0c,0x30,0x08,0x6d,0xf0,
0x09,0xcc,0xf0,0x1f,0x0c,0x60,0x1e,0x0c,0x00,0x1c,0x0c,0x00,
0x18,0x0c,0x00,0x00,0x0c,0x00,0x00,0x0c,0x00,0x00,0x0c,0x00,
0x00,0x0c,0x00,0x00,0x0c,0x00,0x00,0x04,0x00,0x00,0x00,0x00};  //印

code unsigned char print_shi1[24][3]={0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x03,0x80,0x00,0x01,0x80,
0x00,0x01,0x80,0x03,0x81,0x80,0x7f,0x81,0x80,0x31,0x81,0xbc,
0x31,0xbf,0xfc,0x31,0xff,0x80,0x3f,0x81,0x80,0x3d,0xb1,0x80,
0x31,0x99,0x80,0x31,0x9d,0x80,0x71,0x89,0x80,0x71,0x81,0x80,
0x7f,0x81,0x80,0x63,0x81,0x80,0x01,0x01,0xc0,0x00,0x07,0xc0,
0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00};      //时

code unsigned char print_jian[24][3]={0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xe0,0x03,0x9f,0xf0,
0x01,0x98,0x30,0x18,0x00,0x30,0x18,0x00,0x30,0x18,0x9e,0x30,
0x18,0xff,0x30,0x18,0xc6,0x30,0x18,0xd6,0x30,0x18,0xfe,0x30,
0x18,0xc6,0x30,0x18,0xc6,0x30,0x18,0xfe,0x30,0x18,0xce,0x30,
0x38,0x84,0x30,0x38,0x00,0x30,0x38,0x01,0xf0,0x10,0x00,0xf0,
0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00};     //间
										
code unsigned char print_maohao[24][2]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
										0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
										0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,
										0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
										0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,
										0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};     //:



//打印初始化
void print_init()
{
	SCON=0X50;    
	T2CON=0X34;   //波特率为115200
	RCAP2H=0XFF;
	RCAP2L=0XFD;
	REN=1;
}

//向串口发送一个字符 
void psend_char_com(unsigned char ch)  
{
while(PRINT_BUSY==0);
 {   SBUF=ch;
    while(TI==0);
    TI=0;
 }
}
//向串口发送一个字符串,strlen为该字符串长度 
void  psend_string_com(unsigned char *str,unsigned int strlen)
{
    unsigned int k=0;
    do 
    {
        psend_char_com(*(str + k));
        k++;
    } while(k < strlen);
}
//延时
void delay ()
{
	unsigned char j;

		for(j=0;j<97;j++)
		{
			_nop_();
			_nop_();
		 }		
}

void main()
{
	unsigned char h,k,a;
    delay();
 	print_init();
	for(a=0;a<20;a++)
{
/*	for(h=0;h<24;h++)               
	{
		psend_string_com(print_hzinit,4);
		psend_string_com(print_example[h],15);
		for(k=0;k<33;k++)
		{
			psend_char_com(0x00);
		}
	}
//	delay();

}*/
	
	for(h=0;h<24;h++)               //打印时间:
	{
//		print_hzinit();
	psend_string_com(print_hzinit,4);
		psend_string_com(print_da[h],3);
	    psend_string_com(print_yin[h],3);
		psend_string_com(print_shi1[h],3);
		psend_string_com(print_jian[h],3);
		psend_string_com(print_maohao[h],2);
			for(k=0;k<34;k++)
		{
			psend_char_com(0x00);
		}  		
	}
}
while(1);
	
}

⌨️ 快捷键说明

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