EPSON Thermal Printer RS232 Interface Model --TM-T82II

Dependents:   EPSON_Printer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EPSON.h Source File

EPSON.h

Go to the documentation of this file.
00001 /**
00002  ******************************************************************************
00003  * @file    EPSON.h
00004  * @author  Shivanand Gowda 
00005  * @version V1.0.0
00006  * @date    21 May 2018
00007  * @brief   This file contains the class of a EPSON thermal control component
00008  ******************************************************************************
00009  * @attention
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a copy
00012  * of this software and associated documentation files (the "Software"), to deal
00013  * in the Software without restriction, including without limitation the rights
00014  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00015  * copies of the Software, and to permit persons to whom the Software is
00016  * furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included in
00019  * all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00022  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00024  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00026  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00027  * THE SOFTWARE.
00028  */
00029  
00030 #ifndef MBED_EPSON_H
00031 #define MBED_EPSON_H
00032  
00033 #include "mbed.h"
00034  
00035 #if defined(__CC_ARM)
00036 // To avoid "invalid multibyte character sequence" warning
00037 #pragma diag_suppress 870
00038 #endif
00039  
00040  
00041 class EPSON : public Stream
00042 {
00043 public:
00044  
00045     /**
00046      * @enum Kanji_font_size
00047      * Value of Japanese Kanji font size
00048      */
00049     enum Kanji_font_size {
00050         //! 24x24 dot font
00051         KANJI_24x24 = 0x30,
00052         //! 16x16 dot font
00053         KANJI_16x16,
00054         //! Defalut font size
00055         KANJI_DEFAULT = KANJI_24x24
00056     };
00057  
00058     /**
00059      * @enum ANK_font_size
00060      * Value of ANK font size
00061      */
00062     enum ANK_font_size {
00063         //! 8x16 dot font
00064         ANK_8x16 = 0x30,
00065         //! 12x24 dot font
00066         ANK_12x24,
00067         //! 16x16 dot font
00068         ANK_16x16,
00069         //! 24x24 dot fot
00070         ANK_24x24,
00071         //! Defalut font size
00072         ANK_DEFAULT = ANK_12x24
00073     };
00074  
00075     /**
00076      * @enum QRcode_error_level
00077      * Value of CQ code error correction level
00078      */
00079     enum QRcode_error_level {
00080         //! Error correction level L (7%)
00081         QR_ERR_LVL_L = 0x4C,
00082         //! Error correction level M (15%)
00083         QR_ERR_LVL_M = 0x4D,
00084         //! Error correction level Q (25%)
00085         QR_ERR_LVL_Q = 0x51,
00086         //! Error correction level H (30%)
00087         QR_ERR_LVL_H = 0x48
00088     };
00089  
00090     /**
00091      * @enum barcode_mode
00092      * Value of barcode mode
00093      */
00094     enum barcode_mode {
00095         //!  UPC-A : 11-digit, d1-d11, C/D
00096         BCODE_UPC_A = 0x30,
00097         //! JAN13 : 12-digit, d1-d12, C/D
00098         BCODE_JAN13 = 0x32,
00099         //! JAN8 : 7-digit, d1-d7, C/D
00100         BCODE_JAN8,
00101         //! CODE39 : variable, d1-d20, C/D
00102         BCODE_CODE39,
00103         //! ITF : variable, d1-d20
00104         BCODE_ITF,
00105         //! CODABAR (NW7) : variable, d1-d20
00106         BCODE_CODABAR
00107     };
00108     
00109     /**
00110      * @enum script_mode
00111      * Value of script mode
00112      */
00113     enum script_mode {
00114         //! Cancel script mode
00115         SCRIPT_CANCEL = 0,
00116         //! Super script
00117         SCRIPT_SUPER,
00118         //! Sub script
00119         SCRIPT_SUB
00120     };
00121  
00122     /** Create a EPSON instance
00123      *  which is connected to specified Serial pin with specified baud rate
00124      *
00125      * @param tx Serial TX pin
00126      * @param baud (option) serial baud rate (default: 9600bps)
00127      */
00128     EPSON(PinName tx,PinName rx, uint32_t baud = 9600);
00129  
00130     /** Create a EPSON instance
00131      *  which is connected to specified Serial instance with specified baud rate
00132      *
00133      * @param serial_obj Serial object (instance)
00134      * @param baud (option) serial baud rate (default: 9600bps)
00135      */
00136     EPSON(Serial &serial_obj, uint32_t baud = 9600);
00137  
00138     /** Destructor of EPSON
00139      */
00140     virtual ~EPSON();
00141  
00142     /** Initializa EPSON
00143      *
00144      *  Issues initialize command for AS-289R2
00145      *
00146      */
00147     void initialize(void);
00148  
00149     /** Send line feed code
00150      *  which is connected to specified Serial pin with specified baud rate
00151      *
00152      * @param lines Number of line feed
00153      */
00154      void printTest(void);
00155      void printnputLineFeed(uint8_t lines);
00156      void lineFeed(void);
00157      void putHorizontaltab(void);
00158  
00159      void setdefaultLinespacing(void);
00160      void setLinespacing(uint8_t lines);
00161      void setleftMargin(uint8_t n1, uint8_t n2);
00162      void absoluteprintPosition(uint8_t n1, uint8_t n2);
00163      void whiteblack(uint8_t n1);
00164     void papersensorstatus(void);
00165     void carriageReturn(void);
00166     
00167     
00168     
00169     
00170    void printCenter(void);
00171     void printLeft(void);
00172     void printRight(void);
00173     
00174     void font_ZeroOne(void);
00175     void font_Zero(void);
00176     void font_OneZero(void);
00177     int PrintBarCode(char *data ,int ilen);
00178     
00179     
00180     void printModes(uint8_t n);  
00181     
00182     
00183     
00184     
00185      /** pur Horizontal Tab
00186      *
00187      */
00188     
00189     void putLineFeed(uint8_t lines);
00190  
00191     /** Clear image buffer of the AS-289R2
00192      *
00193      */
00194     void clearBuffer(void);
00195  
00196     /** Set double height size font
00197      *
00198      */
00199     void setDoubleSizeHeight(void);
00200  
00201     /** Set normal height size font
00202      *
00203      */
00204     void clearDoubleSizeHeight(void);
00205  
00206     /** Set double width size font
00207      *
00208      */
00209     void setDoubleSizeWidth(void);
00210  
00211     /** Set normal width size font
00212      *
00213      */
00214     void clearDoubleSizeWidth(void);
00215  
00216     /** Set large size font (48x96)
00217      *
00218      */
00219     void setLargeFont(void);
00220  
00221     /** Set normal size font
00222      *
00223      */
00224     void clearLargeFont(void);
00225  
00226     /** Set ANK font
00227      *
00228      * @param font ANK font e.g. EPSON::ANK_8x16
00229      */
00230     void setANKFont(uint32_t font);
00231  
00232     /** Set Kanji font size
00233      *
00234      * @param font Kanji font e.g. EPSON::KANJI_16x16
00235      */
00236     void setKanjiFont(uint32_t font);
00237  
00238     /** Print QR code
00239      *
00240      * @param err QR code error correction level e.g. EPSON::QR_ERR_LVL_M
00241      * @param buf Data to be printed
00242      */
00243     void printQRCode(uint32_t err, const char* buf);
00244  
00245     /** Print Bar code
00246      *
00247      * @param code Type of Bar code e.g. EPSON::JAN13
00248      * @param buf Data to be printed
00249      */
00250     void printBarCode(uint32_t code, const char* param);
00251  
00252     /** Print bitmap image
00253      *
00254      * @param cmd Type of operation mode, 0x61: print image buffer, 0x62: register image buffer, 0x63: register -> print, 0x64: print -> register, 0x65: line print
00255      * @param lines Number of print line
00256      * @param image Data to be printed
00257      */
00258     void printBitmapImage(uint32_t cmd, uint16_t lines, const uint8_t * image);
00259  
00260     /** Set Line Spaceing
00261      *
00262      * @param space line spacing
00263      */
00264     void setLineSpaceing(uint32_t space);
00265  
00266     /** Set as default Line Spaceing
00267      *
00268      */
00269     void defaultLineSpaceing(void);
00270  
00271     /** Set Print Direction
00272      *
00273      * @param direction Print direction, 0: lister, 1: texter
00274      */
00275     void setPrintDirection(uint32_t direction);
00276  
00277     /** Send feed code
00278      *
00279      * @param space Paper feed
00280      */
00281     void putPaperFeed(uint32_t space);
00282  
00283     /** Set Inter Character Space
00284      *
00285      * @param space inter-character space
00286      */
00287     void setInterCharacterSpace(uint32_t space);
00288  
00289     /** Set as default Inter Character Space
00290      *
00291      */
00292     void defaultInterCharacterSpace(void);
00293  
00294     /** Send Print Position
00295      *
00296      * @param position Print position
00297      */
00298     void putPrintPosition(uint32_t position);
00299  
00300     /** Set Script
00301      *
00302      * @param script mode e.g. EPSON::SCRIPT_SUPER
00303      */
00304     void setScript(script_mode script);
00305  
00306     /** Clear Script
00307      *
00308      */
00309     void clearScript(void);
00310  
00311     /** Set Quadruple size
00312      *
00313      */
00314     void setQuadrupleSize(void);
00315  
00316     /** Clear Quadruple size
00317      *
00318      */
00319     void clearQuadrupleSize(void);
00320  
00321     /** Set Enlargement size
00322      *
00323      * @param width enlargement
00324      * @param height enlargement
00325      */
00326     void setEnlargement(uint32_t width, uint32_t height);
00327  
00328     /** Clear Enlargement size
00329      *
00330      */
00331     void clearEnlargement(void);
00332  
00333     /** Set BarCode Height size
00334      *
00335      * @param height Bar height
00336      */
00337     void setBarCodeHeight(uint32_t height);
00338  
00339     /** Set as default BarCode Height size
00340      *
00341      */
00342     void defaultBarCodeHeight(void);
00343  
00344     /** Set BarCode Bar size
00345      *
00346      * @param narrowbar narrow bars size
00347      * @param widebar wide bars size
00348      */
00349     void setBarCodeBarSize(uint32_t narrowbar, uint32_t widebar);
00350  
00351     /** Set as default BarCode Bar size
00352      *
00353      */
00354     void defaultBarCodeBarSize(void);
00355  
00356 private:
00357     Serial *_serial_p;
00358     Serial &_serial;
00359  
00360 protected:
00361     // Stream implementation functions
00362     virtual int _putc(int value);
00363     virtual int _getc();
00364 };
00365  
00366 #endif
00367  
00368