久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 6448|回復(fù): 1
收起左側(cè)

北京迅普微型打印機(jī),驅(qū)動(dòng)程序分享

[復(fù)制鏈接]
ID:96218 發(fā)表于 2015-11-18 19:01 | 顯示全部樓層 |閱讀模式
北京迅普微型打印機(jī)

/*------------------------------------------------------------------------------
File   : Printer_WH.c            
Project         : Printer_WH.prj
Item   : Cam Controller TT-FZ0430607-V1.0 F60608027
New Data  : 2007-10-23
Author   : wangxinjia
Comments  : Printet -
      Uart0 Link
      ( Uart - SIUPO(北京迅普微型打印機(jī)) )
------------------------------------------------------------------------------*/
#i nclude  "Universal.h"
//#i nclude "Printer_WH.h"
#i nclude <stdarg.h>
#i nclude <stdlib.h>
#i nclude <ctype.h>
#i nclude <string.h>

#define  BAUD  9600
#define  UBRR_VALUE (INT32U)FCLK/16/(INT32U)BAUD -1

#define  NUL   0x00       //空
#define  BEL   0x07       //報(bào)警符
#define  BS   0x08       //退格
#define  HT   0x09       //橫向列表
#define  LF   0x0A       //換行
#define  VT   0x0B       //垂直制表
#define  FF   0x0C       //換頁(走紙控制)
#define  CR   0x0D       //回車
#define  SO   0x0E       //橫向放大兩倍(移位輸出)
#define  DC4   0x14       //橫向無放大(設(shè)備控制4)
#define  CAN   0x18       //刪除一行(做廢)
#define  ESC   0x1B       //     
#define  FS   0x1C       //
#define  SPACE  0x20       //空格

#define  PANE  0X3C       //方框  

static char  buf[25]     ;
UCHAR   PrintDataPrec   ;
UCHAR   PrintDataSignCh   ;
int    PrintDataWidth   ;
UCHAR   PrintDataFlag   ;
//--------------------------------------
#define  F_ALTFORM  0x01       /* alternate form, e.g. %#x */
#define  F_LONG   0x02       /* long modifier, e.g. %ld */
#define  F_LEFTALIGN 0x04       /* left align, e.g. %-... */
#define  F_ADDSIGN  0x08       /* sign (+ or -) e.g. %+, or %(space) */
#define  F_ZEROPADD  0x10       /* zero padded instead of space padded */
#define  F_FRACTION  0x20       /* fraction  */
//---------------------------------------

void PrinterInit(void);
void PrintLineChar(char *s);

void PrintChar(unsigned char c);
void PrintString(char *bp);
void PrintDigit(char *bp);
int MixPrintFun(CONST char *fmt, ...);

void uart0_init (void)
{
UCSRB = 0x00;           //disable while setting baud rate
  UCSRA = 0x00;
// UCSRC = BIT(URSEL)|BIT(UPM1)|BIT(UCSZ1)|BIT(UCSZ0); //8,even,1
UCSRC = BIT(URSEL)|BIT(UCSZ1)|BIT(UCSZ0);   //8,N,1
UBRRL = WORD_LO(UBRR_VALUE);      //9600-0x67;38400-0x19
UBRRH = WORD_HI(UBRR_VALUE);
// UCSRB = BIT(TXEN);         //only enable send
UCSRB = BIT(RXCIE)|BIT(RXEN)|BIT(TXEN);    //0x98
}

void PrinterInit (void)
{
//-----串口設(shè)置--------------
uart0_init();
//-----初始化打印機(jī)----------
putchar(ESC);
putchar('@');
//-----12*12點(diǎn)陣漢字----------
putchar(ESC);
putchar('8');
//----------------------------
  MixPrintFun("\t產(chǎn)品批號(hào): 0000%5u\n",65535);
}
/*-------------------------------
* 打印一行字符:包括漢字和字符
* 從行首開始打印
* 打印完成后自動(dòng)回車換行
-------------------------------*/
void PrintLineChar (char *s)
{
puts(s);
// printf("%s\n",s);
}

void PrintChar(unsigned char c)
{
unsigned char i;
switch ((unsigned char) c) {
    case '\a' :
   putchar(BEL); //putchar(0x07);報(bào)警符
   break;
    case '\b' :
   putchar(BS); //putchar(0x08);退格
   break;
    case '\t' :
//   putchar(HT); //putchar(0x09);橫向列表
   for(i=0;i<4;i++){
    putchar(' ');
   }
   break;
    case '\n' :
   putchar(LF); //putchar(0x0A);換行
   break;   
    case '\f' :
   putchar(FF); //putchar(0x0C);走紙控制(換頁)
   break;            
    case '\r' :
   putchar(CR); //putchar(0x0D);回車
   break;
  default :
      putchar ((unsigned char) c);

}

}
// 字符串的格式化打印
// 程序先對(duì)補(bǔ)0和前導(dǎo)以及符號(hào)位進(jìn)行判斷處理
// 然后輸出數(shù)據(jù),注意小數(shù)點(diǎn)的位置
void PrintString(char *bp)
{
UCHAR i;
if (PrintDataWidth)       //指定了寬度
     PrintDataWidth -= strlen(bp);   //除去字符剩余的寬度
    if (PrintDataWidth && (PrintDataFlag & F_ADDSIGN)) //除去數(shù)據(jù)字符的寬度里面再除去符號(hào)位
       PrintDataWidth--;
if (PrintDataWidth && (PrintDataFlag & F_FRACTION)) //除去數(shù)據(jù)字符的寬度里面再除去小數(shù)點(diǎn)位
       PrintDataWidth--;  
    if (PrintDataFlag & F_ZEROPADD){   //前端補(bǔ)0
  if (PrintDataFlag & F_ADDSIGN)   //sign
   PrintChar(PrintDataSignCh);
  if (!(PrintDataFlag & F_LEFTALIGN)){ //不要求左對(duì)齊,即指定寬度右對(duì)齊
   while (PrintDataWidth > 0){
    PrintChar('0');
    PrintDataWidth--;
   }
  }
}else{
  if (!(PrintDataFlag & F_LEFTALIGN)){ //不要求左對(duì)齊,即指定寬度右對(duì)齊
   while (PrintDataWidth > 0){   //前端補(bǔ)' '
    PrintChar(' ');
       PrintDataWidth--;
   }
  }
  if (PrintDataFlag & F_ADDSIGN)
   PrintChar(PrintDataSignCh);
    }
i=strlen(bp);
while(i){    //數(shù)據(jù)輸出
  if ( (i==PrintDataPrec) && (PrintDataFlag & F_FRACTION) ){
   PrintChar('.');  //小數(shù)點(diǎn)
  }
  PrintChar(*bp);
  bp++;
  i--;
}
}
// 數(shù)據(jù)打印處理
void PrintDigit(char *bp)
{
int i;
    if (PrintDataPrec){   
     i = strlen(buf);
     if (PrintDataPrec > i) //小數(shù)點(diǎn)位置不能越界
      PrintDataPrec = i;
    }
PrintString(bp);
}
/*-------------------------------
* cntrl_string  格式化文本字符串
* va_list    不確定類型(變長(zhǎng)參數(shù)),需要stdarg.h; va_start,va_end成對(duì)使用。
* cnt_printed_chars 返回輸出的字符個(gè)數(shù)
-------------------------------*/
int MixPrintFun(CONST char *fmt, ...)
{
va_list va;
char *bp;
char *s;
unsigned char* cs;
   unsigned char done;
   int i;

va_start(va, fmt);

// val = _print((void (*)(char))putchar, fmt, va);
for ( ; *fmt; fmt++){    //非格式字符%
       if (*fmt != '%'){
           PrintChar(*fmt);
           continue;
        }
  bp = buf;
  PrintDataFlag = 0;
  PrintDataWidth= 0;
       PrintDataPrec = 0;
  PrintDataSignCh= ' ';
       ++fmt;
  PrintDataFlag=0;
  for (done = 0; ; fmt++){   //查找格式控制字符
         switch (fmt[0]){
          case '#':  // o/0x/0X 引導(dǎo)
              PrintDataFlag |= F_ALTFORM;
              break;
          case '-':  //左對(duì)齊
              PrintDataFlag |= F_LEFTALIGN;
              break;
           case '+':  //正整數(shù)前面加符號(hào)+
              PrintDataFlag |= F_ADDSIGN;
              PrintDataSignCh = '+';
              break;
          case ' ':  //顯示符號(hào)位
              PrintDataFlag |= F_ADDSIGN;
              PrintDataSignCh = ' ';
              break;
          case '0':  //用0代替輸出的空格
              PrintDataFlag |= F_ZEROPADD;
              break;
          default:
              done = 1; //格式控制字符后面的數(shù)據(jù)寬度和精度以及類型等的處理
              break;
            }
         if (done)   /* break here so fmt++ would not happen */
             break;
        }//for (done = 0; ; fmt++)
  //獲得寬度
       if (isdigit (fmt[0])) {   //取格式化字符指定的寬度(1 bit)
           PrintDataWidth = atoi ((char *) fmt);
           while (isdigit (*fmt))
               fmt++;
        }else if (fmt[0] == '*'){  //參數(shù)指定寬度
           PrintDataWidth = va_arg(va, int);
           fmt++;
        }
  if (fmt[0] == '.'){    //獲得精度
   PrintDataFlag |= F_FRACTION;
           ++fmt;
           if (isdigit(fmt[0])){  //取格式化字符指定的精度(1 bit)
             PrintDataPrec = atoi ((char *) fmt);
             while (isdigit (*fmt))
                 fmt++;
            }else if (fmt[0] == '*'){ //參數(shù)指定精度
             PrintDataPrec = va_arg(va, int);
             fmt++;
            }
        }
  switch (*fmt){     //輸出數(shù)據(jù)格式處理
         default:     //無效格式,當(dāng)字符處理
            PrintChar(*fmt);
            break;
   case 'c':     //輸出字符
    PrintChar(va_arg (va, int) );
    break;
   case 's':     //輸出字符串
    cs = va_arg(va, unsigned char *);
     i = 0;
     while (cs [i]) {
        PrintChar (cs [i++]);
    }   
    break;  
         case 'd':     //10進(jìn)制int輸出
    i = va_arg (va, int);
               if (i < 0){
                  PrintDataFlag |= F_ADDSIGN;
                  PrintDataSignCh = '-';
                  i = -i;
                }
               itoa (bp, i, 10);
    PrintDigit(bp);
    break;
         case 'u':     //10進(jìn)制無符號(hào)數(shù)輸出
//    break;
   case 'o':     //八進(jìn)制數(shù)據(jù)輸出
//    break;
   case 'x':     //16進(jìn)制小寫輸出
//    break;
   case 'X':     //16進(jìn)制大寫輸出
    i = va_arg (va, unsigned int);
    if (*fmt == 'u'){
     utoa (bp, i, 10);
    }else if (*fmt == 'o'){
     if (PrintDataFlag & F_ALTFORM)
                    *bp++ = 'o';
     utoa (bp, i, 8);
     bp--;  //'o'
    }else{
     if (PrintDataFlag & F_ALTFORM){
                    *bp++ = '0';
                    *bp++ = fmt[0];
                 }
     utoa (bp, i, 16);
     if (fmt[0] == 'X'){
                  for (s = buf; *s; s++)
                      *s = toupper(*s);
     }
     bp-=2;  //0x  
    }
    PrintDigit(bp);
    break;  
  }//switch (*fmt)
}//for ( ; *fmt; fmt++)   
va_end(va);

return 1;
}



回復(fù)

使用道具 舉報(bào)

ID:86796 發(fā)表于 2015-11-19 21:07 | 顯示全部樓層
能否自己寫個(gè)EPSON TM-T86L的DRIVER?
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 日日噜噜夜夜爽爽狠狠 | 麻豆av片| 日韩中文一区二区三区 | 亚洲精品乱码久久久久久蜜桃 | 国产精品久久久久久久久久 | 一区二区三区在线电影 | 中文字幕高清av | 免费高清av | 精品小视频 | 欧美成人精品一区二区三区 | 久久久国产精品 | 99久久婷婷国产综合精品 | 色吧色综合 | 日本精品免费在线观看 | 日韩免费看视频 | 国产九九精品视频 | 亚洲精品免费视频 | 国产亚洲精品久久久久久牛牛 | 久久久91精品国产一区二区三区 | 人人九九 | 欧美久久精品一级c片 | 天天操 夜夜操 | 亚洲国产精品一区二区第一页 | av一级久久| 精产国产伦理一二三区 | 国产综合久久 | 宅女噜噜66国产精品观看免费 | 国产精品美女久久久久久久久久久 | 中文在线一区 | 365夜爽爽欧美性午夜免费视频 | 欧美成人免费在线视频 | 久久亚洲国产 | 精品久久久久久久人人人人传媒 | 日本精品一区二区三区视频 | av网站在线播放 | 国产亚洲一区二区在线观看 | 中文字幕在线三区 | 亚洲精品在线国产 | 日韩伦理一区二区 | 懂色中文一区二区在线播放 | 亚洲精品久久久久久久久久久久久 |