版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、/*/ 新榮達(dá)電子打印機(jī)測(cè)試程序/ 51單片機(jī),晶振11.0592/時(shí)間:2009-7-10/用與測(cè)試串行接口打印機(jī)/常用打印機(jī)指令以函數(shù)行式體現(xiàn)/可根據(jù)需要自行調(diào)用單一函數(shù)*/#include/51頭文件#include /字串處理函數(shù)頭文件 #include#define uchar unsigned charsbit BUSY=P34; /并口打印機(jī)的BUSY,串口打印機(jī)的CTS /*單字節(jié)打印函數(shù)*/void print(unsigned char ch)while (BUSY=1) /busy為1時(shí),等待,如數(shù)據(jù)量小,可不判BUSY ; SBUF= ch; /busy=0,將數(shù)據(jù)送到
2、P1口while(TI=0)/當(dāng)TI為0時(shí),表示數(shù)據(jù)未發(fā)送完成,一直等待,直到為1;TI=0;/將TI清0/*串口初始化*/void com_init(void) TH1=0XFD; /波特率值裝入計(jì)數(shù)器,9600BPSTMOD=0X20; /串口設(shè)置,定時(shí)器1,設(shè)為方式2,8位自動(dòng)重載,用于產(chǎn)生波特率SCON=0X50; /串口發(fā)送方式1,8位數(shù)據(jù)位,1位停止位TR1=1;/開(kāi)啟定時(shí)器1 /*字符打印函數(shù)*/void print_chs(uchar ch)uchar i;for(i=0;istrlen(ch);i+)print(chi);/*漢字打印例程*/void hanzitest(vo
3、id)uchar i;print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(漢字命令測(cè)試:n);for(i=0;i5;i+) /搋環(huán)打印5次print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print(0xd0);print(0xc2);/打印數(shù)據(jù)新print(0x1b);print(0x38);print(0x04);/調(diào)用12*12點(diǎn)陣漢字,24點(diǎn)陣為24*24print(
4、0xc8);print(0xd9);print(0xb4);print(0xef);/打印數(shù)據(jù)“榮達(dá)”print(0x0d);/回車/*行間距例程*/void hangjianju(void)uchar i;print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(行間距測(cè)試:n);for(i=0;i11;i=i+2) /循環(huán)打印print(0x1b);print(0x31);print(i); /ESC 1,設(shè)置行間距print_chs(LINE
5、SPACING);print(0x0a); /打印字符串和換行/*水平造表例程*/void shuipingzhaobiao(void)print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(水平造表測(cè)試:n);print_chs(23456);/ 標(biāo)尺print(0x0d);print(0x1b);print(0x44);print(2);print(9);print(14);print(0);/ESC Dprint(9); /HT命令print
6、_chs(HT1); /打印字符串print(9); /HT命令print_chs(HT2); /打印字符串print(9); /HT命令print_chs(HT3); /打印字符串print(0x0d);/*打印空格或換行例程*/void konggehuanhang(void)print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(換行或空格測(cè)試:n);print_chs(TE); /打印字符串“TE”print(0x1b);print(0x6
7、6);print(0);print(0x06);/空六格print_chs(ST); /打印字符串“ST”print(0x0d); /回車print_chs(TE); /打印字符串“TE”print(0x1b);print(0x66);print(0x01);print(0x06);/換6行print_chs(ST); /打印字符串“ST”print(0x0d); /回車/*右限例程*/void youxian(void)print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為
8、24*24print_chs(右限測(cè)試:n);print_chs();/標(biāo)尺print(0x1b);print(0x51);print(0x06); /ESC Q 命令,右限為6print_chs();/打印字串print(0x0d); /回車/*左限例程*/void zhuoxian(void)print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(左限測(cè)試:n);print_chs();/標(biāo)尺print(0x1b);print(0x6c);pr
9、int(0x06); /ESC I 命令,左限為6print_chs();/打印字串print(0x0d); /回車/*放大指令例程*/void fangda(void)uchar i;print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(放大測(cè)試:n);for(i=1;i4;i+) /從1到3倍print (0x1b);print(0x55);print(i); /橫向放大print_chs(RD); /打印字符print(0x0d); /回車
10、命令print(0x1b);print(0x40); /初始化打印機(jī)for(i=1;i4;i+) /從1到3倍print (0x1b);print(0x56);print(i); /縱放命令print_chs(RD); /打印字符print(0x0d); /回車print(0x1b);print(0x40); /初始化打印機(jī)for(i=1;i4;i+) /從1到3倍 print (0x1b);print(0x57);print(i); /橫縱向同時(shí)放大print_chs(RD); /打印字符print(0x0d); /回車/*劃線指令例程*/void huaxian(void)print(0x
11、1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(劃線測(cè)試:n);print(0x1b);print(0x57);print(2);/放大兩倍打印,便于觀察劃線print_chs(RD); /打印字串print(0x1b);print(0x2d);print(1);/允許下劃線打印print_chs(UPT); /UPT打印下劃線print(0x1b);print(0x2d);print(0);/禁止下劃線打印print_chs(RD); /打印字串prin
12、t(0x0d); /回車print(0x1b);print(0x40); /初始化打印機(jī)print(0x1b);print(0x57);print(2);/放大兩倍打印,便于觀察劃線print_chs(RD); /打印字串print(0x1b);print(0x2b);print(1);/允許上打印線打印print_chs(UPT); /UPT上打印上劃線print(0x1b);print(0x2b);print(0);/禁止上劃線 print_chs(RD);/打印字串print(0x0d);/打印回車/*上下標(biāo)指令例程*/void shangxiabiao(void)print(0x1b)
13、;print(0x40); /初始化打印機(jī)print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(上下標(biāo)測(cè)試:n);print(0x1b);print(0x57);print(0x02); /放大兩倍print(M); /打印字符Mprint(0x1b);print(0x57);print(0x01); /原倍print(0x1c);print(0x72);print(0); /上標(biāo)命令print(2); /打印字符2print(0x0d); /回車print(0x1b);print(0x57);print(0
14、x01); /原倍print(0x1b);print(0x57);print(0x02); /放大兩倍print(M); /打印字符Mprint(0x1c);print(0x72);print(1); /上標(biāo)命令print(0x1b);print(0x57);print(0x01); /原倍print(2); /打印字符2print(0x0d); /回車/*橫縱向指令例程*/void hengzhong(void)print(0x1b);print(0x40);print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_c
15、hs(橫縱向測(cè)試:n);print(0x1c);print(0x4a); /設(shè)置縱向打印print_chs(ABCDEFGHI); /打印字符print(0x0d); /回車 print(0x1b);print(0x40);print(0x1C);print(0x4B); /設(shè)置橫向打印print_chs(ABCDEFGHI); /打印字符print(0x0d); /回車 /*自定義指令例程*/void zidingyi(void)print(0x1b);print(0x40); /初始化指令print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,2
16、4點(diǎn)陣為24*24print_chs(自定義字符測(cè)試:n);print(0x1b);print(0x36); /如是24點(diǎn)陣機(jī)器,在自定義字符前面要加一個(gè)1B 36 指令才行print(0x1b);print(0x57);print(2); /橫向縱向放大2倍print(0x1b);print(0x26);print(65); /ESC & 命令print(0x02);print(0x7C);print(0x40); /字模數(shù)據(jù)print(0xC0);print(0x40);print(0x00); /字模數(shù)據(jù)print(0x1b);print(0x25);print(65);print(65
17、);print(0); /ESC %print(65); /打印定義字符print(0x1b);print(0x3a); /ESC:命令print(65); /復(fù)符集中的字符print(0x0d);/*圖形指令例程*/void tuxing(void)uchar code tch =0x7c,0x44,0x44,0xff,0x44,0x44,0x7c,0x00,0x41,0x62,0x54,0xc8,0x54,0x62,0x41;uchar i;print(0x1b);print(0x40);/初始化指令print(0x1b);print(0x38);print(0x00); /調(diào)用16*16
18、點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(圖形測(cè)試:n);/print(0x1b);print(0x57);print(2);/橫向縱向放大2倍print(0x1b);print(0x4b);print(15);print(0); /ESC K命令for(i=0;i15;i+)/輸入15個(gè)字節(jié)數(shù)據(jù)print(tchi);print(0x0d);/輸入回車/*曲線II指令例程*/僅適用于熱敏打印機(jī)void quxian_2(void) float X;unsigned int Y,YY;/Y1=50+40*abs(-0.01*X)*sin(X/10)/Y2=50-40*abs(-0.01
19、*X)*sin(X/10)/Y3=50/Y4=50+40*abs(-0.1*X)/Y5=50-40*abs(-0.01*X)/你可以用C語(yǔ)言編寫(xiě)如下的程序:/#include /unsigned int Y,YY,X;print(0x1b);print(0x40);/初始化指令print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(曲線1測(cè)試:n);for(X=0;X150;X+)/打印150點(diǎn)行 Y= 40*exp(-0.01*X); YY= Y*sin(X/10); print(0x1b);print(39
20、);print(5);print(0); /ESC命令,M=5,0 print(50+YY);print(0);print(50-YY);print(0);print(50);print(0); print(50+Y);print(0);print(50-Y);print(0);print(13); /*曲線I指令例程*/僅適用于針式打印機(jī)void quxian_1(void) float X;unsigned int Y,YY;/Y1=50+40*abs(-0.01*X)*sin(X/10)/Y2=50-40*abs(-0.01*X)*sin(X/10)/Y3=50/Y4=50+40*abs
21、(-0.1*X)/Y5=50-40*abs(-0.01*X)/你可以用C語(yǔ)言編寫(xiě)如下的程序:/#include /unsigned int Y,YY,X;print(0x1b);print(0x40);/初始化指令print(0x1b);print(0x38);print(0x00); /調(diào)用16*16點(diǎn)陣漢字,24點(diǎn)陣為24*24print_chs(曲線2測(cè)試:n);for(X=0;X150;X+)/打印150點(diǎn)行 Y= 40*exp(-0.01*X); YY= Y*sin(X/10); print(0x1b);print(39);print(5); /ESC命令,M=5 print(50+
22、YY);print(50-YY);print(50); print(50+Y);print(50-Y);print(13); /*旋轉(zhuǎn)指令例程*/void xuanzhuan(void)uchar i;print(0x1b);print(0x40);/初始化指令for(i=0;i4;i+) /0,90,180,270旋轉(zhuǎn)print(0x1c);print(0x49);print(i); /旋轉(zhuǎn)指令print(0x1b);print(0x38);print(0);/漢字調(diào)出指令print_chs(旋轉(zhuǎn)測(cè)試);/打印漢字print(0x0d); /回車/*反白指令例程*/void fanbai(v
23、oid)uchar i;print(0x1b);print(0x40);/初始化指令for(i=0;i2;i+) /i為1時(shí),反白打印print(0x1b);print(0x69);print(i);print(0x1b);print(0x38);print(0);print_chs(反白測(cè)試);print(0x0d);/*反向指令例程*/void fanxiang(void)uchar i; print(0x1b);print(0x40);/初始化指令for(i=0;i2;i+)/i為1時(shí),禁止反向print(0x1b);print(0x63);print(i);print(0x1b);print(0x38);print(0);print_chs(反向測(cè)試);print(0x0d);/*條碼指令例程*/只有部分型號(hào)的打印機(jī)支持此指令void tiaoma(void) print(0x1b);print(0x40);/初始化指令print(0x1d);print(0x72);print(0x01);/打印條碼字
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- (3篇)2024大學(xué)輔導(dǎo)員個(gè)人工作總結(jié)
- 教師政治思想及職業(yè)道德方面的考核報(bào)告
- 2024年淮南聯(lián)合大學(xué)高職單招職業(yè)技能測(cè)驗(yàn)歷年參考題庫(kù)(頻考版)含答案解析
- 烏魯木齊市八年級(jí)上學(xué)期期末地理試題及答案
- 二零二五年旅游開(kāi)發(fā)項(xiàng)目合同2篇
- 2024年陜西省婦幼保健院高層次衛(wèi)技人才招聘筆試歷年參考題庫(kù)頻考點(diǎn)附帶答案
- 2024年河南藝術(shù)職業(yè)學(xué)院高職單招職業(yè)適應(yīng)性測(cè)試歷年參考題庫(kù)含答案解析
- 2024年阜陽(yáng)市第三人民醫(yī)院阜陽(yáng)市中心醫(yī)院高層次衛(wèi)技人才招聘筆試歷年參考題庫(kù)頻考點(diǎn)附帶答案
- 2024年長(zhǎng)春市婦產(chǎn)科醫(yī)院高層次衛(wèi)技人才招聘筆試歷年參考題庫(kù)頻考點(diǎn)附帶答案
- 2024年江西工商職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測(cè)驗(yàn)歷年參考題庫(kù)(頻考版)含答案解析
- 健康食品開(kāi)發(fā)及生產(chǎn)協(xié)議
- 數(shù)字孿生產(chǎn)業(yè)發(fā)展及軌道交通領(lǐng)域的應(yīng)用研究
- 2024年中學(xué)總務(wù)處工作總結(jié)
- 手術(shù)室各級(jí)人員培訓(xùn)
- 教育部中國(guó)特色學(xué)徒制課題:基于中國(guó)特色學(xué)徒制的新形態(tài)教材建設(shè)與應(yīng)用研究
- 2025年護(hù)理質(zhì)量與安全管理工作計(jì)劃
- (T8聯(lián)考)2025屆高三部分重點(diǎn)中學(xué)12月第一次聯(lián)考評(píng)物理試卷(含答案詳解)
- 工程施工揚(yáng)塵防治教育培訓(xùn)
- 紅薯采購(gòu)合同模板
- 2023年河南省公務(wù)員錄用考試《行測(cè)》真題及答案解析
- 山西省太原市重點(diǎn)中學(xué)2025屆物理高一第一學(xué)期期末統(tǒng)考試題含解析
評(píng)論
0/150
提交評(píng)論