/****************************************Copyright (c)**************************************************
**                               Guangzhou ZHIYUAN electronics Co.,LTD.
**                                     
**                                 http://www.embedtools.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name:          main.c
** Last modified Date: 2010-08-31
** Last Version:       v1.01
** Description:        NXP LPC1100 Series Cortex-M0 MCU ZYTP_LIB Driver Library Application Examples (applicable hardware version V1.01)
** 
**------------------------------------------------------------------------------------------------------
** Created By:         Huangyixin
** Created date:       2010-11-02
** Version:            v1.01
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
********************************************************************************************************/
#include "../MAIN/main.h"
#include "../MAIN/ZLG_IMG.h"

/*********************************************************************************************************
** Function name:           main
** Descriptions:            The main function
** input parameters:        none
** output parameters:       none
** Returned value:          none
** Created by:
** Created Date:
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:                  
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int  main(void)
{
    /*
     * Horizontal tab position settings, unit: 1mm (8 dots)
     */
    unsigned char ucTab1[] = {24};                                      /* Memory for Horizontal tab 1 position settings */
    unsigned char ucTab2[] = {20, 36};                                  /* Memory for Horizontal tab 2 position settings */
                                                            
    targetInit();                                                       /* Hardware initialization      */
    pinInit();                                                          /* Pin initialization           */

    uartInit(9600);                                                     /* UART initialization, ZYTP58 default Baud rate */

    /*
    *  Printer initialization
    */  
    printerInit();     

    /* 
    *  Configure printer
    */
    printerBaudRateSet (115200);                                        /* Change ZYTP58's Baud rate to 115200      */

    uartInit (115200);                                                  /* Change local machine Baud rate to 115200 */         
                                                                        
    printerFlowCtrlSet(FLOW_CTRL_NONE);                                 /* Set flow control mode        */  

    printerStateAutoUpload(PRINTER_STATE_OFPAPER);                      /* Set auto upload              */
                                                                        /* error state indicator, user  */
                                                                        /* can modify it in ZYTP_STATE_HANDLE.c  */                                

    printerStateRT(0, 100);                                             /* Get printer state, synchronize to local machine */
    
    /*
     * Print out "Print Example"
     */
    horizontalAlign(ALIGN_CENTER);                                      /* Set align to center          */
    fontTypeSet(FONT_TYPE_DOUBLE_HEIGHT | FONT_TYPE_DOUBLE_WIDTH);
                                                                        /* Set font double width and double hight */
    uartSendStr("Print Example");
    printAndFeedNDotLine(60);                                           /* Print and feed paper for 60 dots  */
    
    horizontalAlign(ALIGN_LEFT);                                        /* Set align to left            */
    
    /*
     * Print out "CRP Report Sample: 50"
     */
    abscissaSet(72);                                                    /* Set abscissa printing position, unit: dot   */
    fontTypeSet(FONT_TYPE_NORMAL);                                      /* Set font type to normal */
    uartSendStr("CRP Report Sample No: 50");                  
    print();                                                            /* Print and line feed */ 
    
    /*
     * Print out "Name:		Sex:"
     */
    horizontalTabSet(ucTab1, 1);                                        /* Set Horizontal tab position  */
    uartSendStr("Name:");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Sex:"); 
    print();                                                            /* Print and line feed          */ 
    
    /*
     * Print out "Age:        Dept.: Emergency"
     */
    uartSendStr("Age:        ");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Dept.: Emergency"); 
    print();                                                            /* Print and line feed          */ 
    
    /*
     * Print out "Doctor:         Bed No.: 909"
     */
    uartSendStr("Doctor:");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Bed No.: 909"); 
    print();                                                            /* Print and line feed          */
    
    /*
     * Print out "Clinic No.: 0111   Sample type: blood serum"
     */
    uartSendStr("Clinic No.: 0111");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Sample type: blood serum"); 
    print();                                                            /* Print and line feed          */
    
    /*
     * Print out "Inspector: John   Verifier: John"
     */
    uartSendStr("Inspector: John");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Verifier: John"); 
    print();                                                            /* Print and line feed          */
    
    /*
     * Print out "Receive Date: 2002-11-15"
     */
    uartSendStr("Recevie Date: 2002-11-15");  
    print();                                                            /* Print and line feed          */
    
    /*
     * Print out "Verify Date: 2009-11-19"
     */
    uartSendStr("Verify Date: 2009-11-19");  
    print();                                                            /* Print and line feed          */
    
    /*
     * Print out "- - - - - - - - - - - - - - - - "
     */
    uartSendStr("- - - - - - - - - - - - - - - - ");  
    print();                                                            /* Print and line feed          */
    
    /*
     * Print out "Test subject  Result  Unit  Reference range:"
     */
    fontTypeSet(FONT_TYPE_EMPHASIZE);                                   /* Set font type to Bold        */
    horizontalTabSet(ucTab2, 2);                                        /* Set horizontal tab position  */
    uartSendStr("Test subject");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Result"); 
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("Unit"); 
    print();                                                            /* Print and line feed          */
        
    /*
     * Print out "C reaction protein  1.59  ml/L  3-200"
     */
    fontTypeSet(FONT_TYPE_NORMAL);                                      /* Set font type to normal      */
    uartSendStr("C reaction protein");  
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("1.59"); 
    horizontalTab();                                                    /* Move to next tab position    */
    uartSendStr("ml/L"); 
    print();                                                            /* Print and line feed          */

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

    //printerCutPaper(100, CUT_TYPE_HALF);                                /* Before cutting, feed 100 dots  */

    while(1);  
}

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