/****************************************Copyright (c)**************************************************
**                               Guangzhou ZHIYUAN electronics Co.,LTD.
**                                     
**                                 http://www.embedtools.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name:          main.c
** Last modified Date: 2010-11-02
** Last Version:       v1.01
** Description:        NXP P89V51 series 51 MCU ZYTP_LIB driver application example£¨available for ZYTP58 V1.01 hardware£©
** 
**------------------------------------------------------------------------------------------------------
** Created By:         Huangyixin
** Created date:       2010-11-02
** Version:            v1.01
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:        Huangyixin 
** Modified date:      2011-03-28
** Version:
** Description:
**
********************************************************************************************************/
#include "../MAIN/main.h"
#include "../MAIN/ZLG_IMG.h"

/*********************************************************************************************************
** Function name:           main
** Descriptions:            main function
** input parameters:        none
** output parameters:       none
** Returned value:          none
** Created by:
** Created Date:
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:                  
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int main(void)
{
    /*
     * Set horizontal tab positions settings, unit: 1mm£¨8 dots£©
     */
    unsigned char ucTab1[] = {24};                                      /* Store the settings of the horizontal tab 1 */
    unsigned char ucTab2[] = {20, 36};                                  /* Store the settings of the horizontal tab 2 */
                                                            
    uartInit(9600);                                                     /* Initial serial port to the default baud rate of ZYTP58 */
In
    /*
    *  Initial printer
    */  
    printerInit();   

    /* 
    *  Configure printer
    */
    printerBaudRateSet (28800);                                         /* Modify the baud rate of ZYTP58 to 28800 */

    uartInit (28800);                                                   /* Modify the baud rate to 28800 */         
                                                                        
    printerFlowCtrlSet(FLOW_CTRL_NONE);                                 /* Set software flow control */  

    printerStateAutoUpload(PRINTER_STATE_OFPAPER);                      /* Set printer states automatic back */
                                                                        /* User can set the error states indication in ZYTP_STATE_HANDLE.c */
                                                                                                     

    printerStateRT(0, 100);                                             /* Query printer state in realtime */

    /*
     * Print "Printer Example"
     */
    horizontalAlign(ALIGN_CENTER);                                      /* Set the print alignment to center */
    fontTypeSet(FONT_TYPE_DOUBLE_HEIGHT | FONT_TYPE_DOUBLE_WIDTH);
                                                                        /* Set the font type to double height and double width */
    uartSendStr("Printing Example");
    printAndFeedNDotLine(60);                                           /* Print and feed paper for 60 lines */
    
    horizontalAlign(ALIGN_LEFT);                                        /* Set the print alignment to left */
    
    /*
     * Print "CRP report Sample Number:50"
     */
    abscissaSet(72);                                                    /* Set the absolute print position, unit: dot */
    fontTypeSet(FONT_TYPE_NORMAL);                                      /* Set font type to normal */
    uartSendStr("CRP report  Sample Number: 50");                  
    print();                                                            /* Print and feed line */ 
    
    /*
     * Print "Name:         Gender:"
     */
    horizontalTabSet(ucTab1, 1);                                        /* Set horizontal tab positions */
    uartSendStr("Name:");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Gender:"); 
    print();                                                            /* Print and feed one line */ 
    
    /*
     * Print ¡°Age:        Department: Emergency Department"
     */
    uartSendStr("Age:    ");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Department: Emergency Department "); 
    print();                                                            /* Print and feed one line */ 
    
    /*
     * Print "Doctor:         Bed: 909"
     */
    uartSendStr("Doctor:");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Bed: 909"); 
    print();                                                            /* Print and feed one line */
    
    /*
     * Print "Outpatient server number: 0111   Specimens type: blood serum"
     */
    uartSendStr("Outpatient server number: 0111");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Specimens type: blood serum"); 
    print();                                                            /* Print and feed one line */
    
    /*
     * Print "Inspector:John   Checker:John"
     */
    uartSendStr("Inspector:John");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Checker:John"); 
    print();                                                            /* Print and feed one line */
    
    /*
     * Print "Inspection date: 2002-11-15"
     */
    uartSendStr("Inspection date: 2002-11-15");  
    print();                                                            /* Print and feed one line */
    
    /*
     * Print "Check date: 2009-11-19"
     */
    uartSendStr("Check date: 2009-11-19");  
    print();                                                            /* Print and feed one line */
    
    /*
     * Print "- - - - - - - - - - - - - - - - "
     */
    uartSendStr("- - - - - - - - - - - - - - - - ");  
    print();                                                            /* Print and feed one line */
    
    /*
     * Print "Inspection item  Result  Unit  Medical reference range"
     */
    fontTypeSet(FONT_TYPE_EMPHASIZE);                                   /* Set the font to Bold */
    horizontalTabSet(ucTab2, 2);                                        /* Set the absolute print position */
    uartSendStr("Inspection item");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Result"); 
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("Unit"); 
    print();                                                            /* Print and feed one line */
        
    /*
     * Print"CRPT  1.59  ml/L  3-200"
     */
    fontTypeSet(FONT_TYPE_NORMAL);                                      /* Set the font to normal */
    uartSendStr("CRPT");  
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("1.59"); 
    horizontalTab();                                                    /* Shift to next tab position */
    uartSendStr("ml/L"); 
    print();                                                            /* Print and feed one line */

    /*
    *  Print ZLG LOGO
    */ 
    horizontalAlign(ALIGN_CENTER); 
    picturePrintH(PICTURE_TYPE_NORMAL, 20, 113, (unsigned char *)gImage_ZLG_IMG);
        
    /*
    * Printing end and cut paper
    */

    //printerCutPaper(100, CUT_TYPE_HALF);                              /* Feed paper for 100 dots and cut paper */

    while(1);  
}

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