/****************************************Copyright (c)**************************************************
**                               Guangzhou ZHIYUAN electronics Co.,LTD.
**                                     
**                                 http://www.embedtools.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name:           ZyPrtLib.h
** Last modified Date:  2010-12-15
** Last Version:        v1.01
** Description:         zyPrtLib driver library header file
** 
**------------------------------------------------------------------------------------------------------
** Created By:          Huangyixin
** Created date:        2010-12-15
** Version:             v1.01
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:         Huangyixin 
** Modified date:       2011-03-28
** Version:             
** Description:         
**
********************************************************************************************************/
#ifndef __ZYTP58_H__
#define __ZYTP58_H__

#ifdef __cplusplus
extern "C" {
#endif

/*********************************************************************************************************
**  Font type macro, used by fontTypeSet()
*********************************************************************************************************/
#define  FONT_TYPE_NORMAL             0x00                              /* Normal                       */
#define  FONT_TYPE_ITALIC             0x02                              /* Italic                       */
#define  FONT_TYPE_BORDER             0x04                              /* Border                       */
#define  FONT_TYPE_EMPHASIZE          0x08                              /* Bold                         */
#define  FONT_TYPE_DOUBLE_HEIGHT      0x10                              /* Double Height                */
#define  FONT_TYPE_DOUBLE_WIDTH       0x20                              /* Double Width                 */
#define  FONT_TYPE_REVERSE_VEDIO      0x40                              /* Inverse color                */
#define  FONT_TYPE_UNDERLINE          0x80                              /* Underline                    */

/*********************************************************************************************************
**  Alignment mode, used by horizontalAlign()
*********************************************************************************************************/
#define  ALIGN_LEFT		      0					/* Align to left                */
#define  ALIGN_CENTER		      1					/* Aligh to cente               */
#define  ALIGN_RIGHT		      2					/* Aligh to right               */	

/*********************************************************************************************************
**  Printing speed, used by printSpeedSet()
*********************************************************************************************************/
#define  PRINT_SPEED_LOW              0                                 /* Low speed                    */
#define  PRINT_SPEED_MIDIUM           1                                 /* Moderate speed               */
#define  PRINT_SPEED_HIGHT            2                                 /* High speed                   */

/*********************************************************************************************************
**  Font size, used by fontSizeSet()
*********************************************************************************************************/
#define  FONT_SIZE_24                 0                                 /* 24x24                       */
#define  FONT_SIZE_16                 1                                 /* 16x16                       */
#define  FONT_SIZE_12                 2                                 /* 12x12                       */

/*********************************************************************************************************
**  Vertical-scaned bitmap image printing, picturePrintV()
*********************************************************************************************************/
#define  DOT_8_SINGLE_DENSITY         0                                 /* 8 dots sigle density         */
#define  DOT_8_DOUBLE_DENSITY         1                                 /* 8 dots double density        */
#define  DOT_24_SINGLE_DENSITY        32                                /* 24 dots sigle density        */
#define  DOT_24_DOUBLE_DENSITY        33                                /* 24 dots double density       */
  
/*********************************************************************************************************
**  Horizontal-scaned bitmap image printing, used by picturePrintH()
*********************************************************************************************************/
#define  PICTURE_TYPE_NORMAL          0                                 /* Normal                       */
#define  PICTURE_TYPE_DOUBLE_WIDTH    1                                 /* Double width                 */
#define  PICTURE_TYPE_DOUBLE_HEIGHT   2                                 /* Double height                */
#define  PICTURE_TYPE_QUADRUPLE       3                                 /* Double width & double height */

/*********************************************************************************************************
**  Vertical form font type macro, used by formPrintV()
*********************************************************************************************************/
#define  VF_FONT_TYPE_NORMAL          0                                 /* Normal                       */
#define  VF_FONT_TYPE_EMPHASIZE       1                                 /* Bold                         */
#define  VF_FONT_TYPE_UNDERLINE       2                                 /* Underline                    */
#define  VF_FONT_TYPE_REVERSE_VEDIO   3                                 /* Inverse color                */

/*********************************************************************************************************
**  Vertical form item structure
*********************************************************************************************************/
typedef struct __formItem {
    unsigned char ucPos;                                                /* Position of the form item    */
    unsigned char ucFontType;                                           /* Font type of the form itme   */
    unsigned char ucDataLen;                                            /* Data length of the form item */
    unsigned char *pucDataBuf;                                          /* Data value of the form item  */
}formItem;

/*********************************************************************************************************
**  Barcode Text position macro, used by barcodeHriPosSet()
*********************************************************************************************************/
#define  BARCODE_HRI_POS_NONE         0                                 /* None                         */
#define  BARCODE_HRI_POS_TOP          1                                 /* Top                          */
#define  BARCODE_HRI_POS_BOTTOM       2                                 /* Bottom                       */
#define  BARCODE_HRI_POS_TOP_BOTTOM   3                                 /* Both top and bottom          */

/*********************************************************************************************************
**  Barcode text font type macro, used by barcodeHriFontSet()
*********************************************************************************************************/
#define  BARCODE_HRI_FONT_24          0                                 /* 12x24                        */
#define  BARCODE_HRI_FONT_16          1                                 /* 8x16                         */
#define  BARCODE_HRI_FONT_12          2                                 /* 6x12                         */

/*********************************************************************************************************
**  Barcode system macro, used by barcodePrint()
*********************************************************************************************************/
#define  BARCODE_SYS_UPCA			  0                                  
#define  BARCODE_SYS_UPCE			  1								 
#define  BARCODE_SYS_EAN13			  2								 
#define  BARCODE_SYS_EAN8			  3								 
#define  BARCODE_SYS_CODE39			  4                                  
#define  BARCODE_SYS_ITF25			  5								 
#define  BARCODE_SYS_CODABAR		  	  6								 
#define  BARCODE_SYS_CODE93			  7								 
#define  BARCODE_SYS_CODE128		  	  8			
#define  BARCODE_SYS_EAN128			  9	

/*********************************************************************************************************
**  Paper cut mode, used by printerCutPaper()
*********************************************************************************************************/
#define  CUT_TYPE_HALF				  0x42			/* Half cutting                 */
#define  CUT_TYPE_ALL				  0x41			/* Cut it all                   */

/*********************************************************************************************************
**  Printer state macro, used by printerStateRT(), and printerStateAutoUpload()
*********************************************************************************************************/
#define  PRINTER_STATE_NORMAL         0x00                              /* No errors/close all          */
#define  PRINTER_STATE_OVERVOLATGE    0x01                              /* Over voltage                 */
#define  PRINTER_STATE_AXOOPEN	      0x02                              /* Platen open                  */
#define  PRINTER_STATE_OFPAPER        0x04                              /* Paper end                    */
#define  PRINTER_STATE_OVERHEAT       0x08                              /* Over heat                    */
#define  PRINTER_STATE_CUTTERON       0x20                              /* Cutter cut down              */

/*********************************************************************************************************
**  flow control option macro, used by printerFlowCtrlSet()
*********************************************************************************************************/
#define  FLOW_CTRL_NONE              0                                  /* No flow control              */
#define  FLOW_CTRL_SOFTWARE          49                                 /* Software flow control        */
#define  FLOW_CTRL_HARDWARE          48                                 /* Hardware flow control        */

/*********************************************************************************************************
**  Returned value macro
*********************************************************************************************************/
#define  FAIL                         0                                 /* Success                      */
#define  SUCCESS                      1                                 /* Failure                      */

/*********************************************************************************************************
**  Driver library codes selection
*********************************************************************************************************/
#define uartSendStr_EN                1
#define print_EN                      1 
#define printAndFeedNDotLine_EN       1
#define printAndBackFeedNDotLine_EN   1
#define printAndFeedNFontLine_EN      1
#define printAndBackFeedNFontLine_EN  1
#define lineSpacingSet_EN             1
#define lineSpacingDefault_EN         1
#define leftMarginSet_EN              1
#define rightMarginSet_EN             1
#define abscissaSet_EN                1
#define fontTypeSet_EN                1 
#define horizontalAlign_EN            1
#define fontGrayscaleSet_EN           1
#define printSpeedSet_EN              1
#define fontSizeSet_EN                1
#define picturePrintV_EN              1
#define picturePrintH_EN              1
#define horizontalTabSet_EN           1
#define horizontalTab_EN              1
#define formPrintV_EN                 1
#define barcodeHeightSet_EN           1
#define barcodeWidthSet_EN            1 
#define barcodeHriPosSet_EN           1
#define barcodeHriFontSet_EN          1
#define barcodePrint_EN               1
#define printerInit_EN                1
#define printerClearBuffer_EN         1
#define printerCutPaper_EN            1
#define printerStateRT_EN             1
#define printerStateAutoUpload_EN     1
#define printerBaudRateSet_EN         1
#define printerFlowCtrlSet_EN         1
#define printerEnterLowPowerMode_EN   1
#define printerExitLowPowerMode_EN    1
#define selectKanjiMode_EN            1
#define cancelKanjiMode_EN            1
#define selectInternationalChar_EN    1
#define selectCharCodePage_EN         1

/*********************************************************************************************************
**  Driver library function declarations for user calls
*********************************************************************************************************/
extern void uartSendStr (unsigned char *pucStr);
extern void print (void); 
extern void printAndFeedNDotLine (unsigned char ucDotLineNum);
extern void printAndBackFeedNDotLine (unsigned char ucDotLineNum); 
extern void printAndFeedNFontLine (unsigned char ucFontLineNum); 
extern void printAndBackFeedNFontLine (unsigned char ucFontLineNum); 
extern void lineSpacingSet (unsigned char ucDotLineNum); 
extern void lineSpacingDefault (void); 
extern void leftMarginSet (unsigned char ucLeftMargin); 
extern void rightMarginSet (unsigned char ucRightMargin); 
extern void abscissaSet (unsigned short ucXNum); 
extern void fontTypeSet (unsigned char ucFontType); 
extern void horizontalAlign(unsigned char align);
extern void fontGrayscaleSet (unsigned char ucFontGrayscale); 
extern void printSpeedSet (unsigned char ucPrintSpeed);
extern void fontSizeSet (unsigned char ucFontSize);
extern void picturePrintV (unsigned char ucType, 
                           unsigned short usHSize, 
                           unsigned char *pucDataBuf);
extern void picturePrintH (unsigned char ucType, 
                           unsigned short usHSize, 
                           unsigned short usVSize, 
                           unsigned char *pucDataBuf); 
extern void horizontalTabSet (unsigned char * pucNBuf, unsigned char ucDataNum); 
extern void horizontalTab (void);      
extern void formPrintV (unsigned char ucVLineNum, 
                        unsigned char *pucVLinePos, 
                        unsigned char ucItemNum, 
                        formItem      *psItem);           
extern void barcodeHeightSet(unsigned char ucHeight); 
extern void barcodeWidthSet(unsigned char ucWidth);
extern void barcodeHriPosSet(unsigned char ucHriPos);
extern void barcodeHriFontSet(unsigned char ucHriFont);
extern void barcodePrint(unsigned char ucBarcodeSys,
                         unsigned char *pucCodeBuf, 
                         unsigned char ucCodeLen); 
extern void printerInit (void); 
extern void printerClearBuffer(void);
extern void printerCutPaper(unsigned char ucDotLineNum, unsigned char type);
extern unsigned char printerStateRT(unsigned char *pucState, unsigned short usTimeOut);
extern void printerStateAutoUpload(unsigned char key);
extern void printerBaudRateSet (unsigned long ulBaudRate);
extern void printerFlowCtrlSet(unsigned char Mode);
extern unsigned char printerEnterLowPowerMode (unsigned short usTimeOut);
extern unsigned char printerExitLowPowerMode (unsigned short usTimeOut);
extern void selectKanjiMode (void);
extern void cancelKanjiMode (void);
extern void selectInternationalChar (unsigned char ucCountry);
extern void selectCharCodePage (unsigned char ucPageNum);

/*********************************************************************************************************
**  Driver library function declaration for dirvier library internal calls
*********************************************************************************************************/
extern void uartRecvProc (unsigned char ucData); 

#ifdef __cplusplus
    }
#endif

#endif

/*********************************************************************************************************
**  End of File
*********************************************************************************************************/
