📄 print.c
字号:
/*********************Thermal Printer FTP-628MCL701******************************/
/*********************Program Designed by ChuFangqun*****************************/
//Check the swich ON or oFF
#include "SST89x5xxRD2.H"
#include "INTRINS.H"
//sfr P4 = 0xA5;
typedef unsigned char uchar;
typedef bit ubit;
uchar bdata print_8data;
sbit print_8data0=print_8data^0;
extern void printa(void);
extern void printb(void);
sbit print_clk = P2^4; //sbit print_clk =P4^0;
sbit stb6_print = P1^0; //These signal is stp used for FTPprint
sbit stb5_print = P1^1; //as the same
sbit stb4_print = P1^2; //as the same
sbit stb3_print = P1^3; //as the same
sbit stb2_print = P1^4; //as the same
sbit stb1_print = P1^5; //as the same
sbit RX_print = P3^0; //as the same
sbit TX_print = P3^1; //as the same<input type="button" >
sbit phot_print = P3^4; //as the same
sbit no_paper_print = P3^5; //as the same
sbit data_print = P2^0; //as the same
sbit busy_print = P2^7; //as the same
sbit lat_print = P2^2; ////set thermal printer FTP-628mcl 701 lat signal
sbit mtb_print = P1^6; //as the same
sbit mtbf_print = P1^7; //as the same
sbit mta_print = P3^3; //as the same
sbit mtaf_print = P3^2; //as the same
sbit power = P0^7; //as the same
uchar data ptempdata[48]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11};
void motoroff(void)
{
mtb_print=0;
mtbf_print=0;
mta_print=0;
mtaf_print=0;
}
void print_int(void)
{
power=1;
data_print=0;
stb6_print=0;
stb5_print=0;
stb4_print=0;
stb3_print=0;
stb2_print=0;
stb1_print=0;
data_print=0;
print_clk=0;
lat_print=1;
motoroff();
return;
}
void write_print(void)
{
uchar a,b,*p;
p=ptempdata;
for(a=0;a<48;a++)
{
print_8data=*p;
for(b=0;b<8;b++)
{
print_clk=0;
data_print=print_8data0;
print_8data=print_8data>>1;
print_clk=1;
}
++p;
}
lat_print=0;
_nop_();
lat_print=1;
}
void delay12_5ms(void) // Delay 1.25mS time
{
uchar a,b;
for(a=0;a<0x14;a++)
{
for(b=0;b<0x40;b++){_nop_();}
}
_nop_();
_nop_();
}
void heat(void)//heat the paper all the time is 7,5ms Set heat time is 1.25ms
{
stb1_print=1;
stb3_print=1;
stb5_print=1;
delay12_5ms();
stb1_print=0;
stb3_print=0;
stb5_print=0;
stb2_print=1;
stb4_print=1;
stb6_print=1;
delay12_5ms();
stb2_print=0;
stb4_print=0;
stb6_print=0;
}
void delay500us(void)// Delay 500uS time
{
uchar a,b;
for(a=0;a<0x07;a++)
{
for(b=0;b<0x14;b++)//od change to
{
_nop_();
}
}
_nop_();
_nop_();
}
//////////////////////////电机基本驱动///////////////////////////////////
void step1(void)
{
mtbf_print=1;//begin BF
delay500us();
mta_print=0;//end A
}
void step2(void)
{
mtaf_print=1;//begin AF
delay500us();
mtbf_print=0;//end BF
}
void step3(void)
{
mtb_print=1;//begin B
delay500us();
mtaf_print=0;//end AF
}
void step4(void)
{
mta_print=1;//begin A
delay500us();
mtb_print=0;//end B
}
//////////////////////////电机连续驱动///////////////////////////////////////////////////
void drivers(void) // Motor
{
step1();
delay500us();
step2();
delay500us();
step3();
delay500us();
step4();
delay500us();
}
void main(void)
{
uchar a;
print_int();
for(a=0;a<10;a++)
{
drivers();
}
motoroff();
power=0;
for(a=0;a<20;a++)
{
printa();
printb();
}
power=1;
for(a=0;a<10;a++)
{
drivers();
}
motoroff();
for(;;)
{
;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -