AS-289R2 Thermal Printer shield control library

Dependents:   AS-289R2_Hello-World AS-289R2_Hello-World-mbed-OS hybrid_image_as289r2 microbit_AS-289R2 ... more

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Fri Feb 03 09:28:48 2017 +0000
Parent:
3:f3dfeb7ccb22
Child:
5:fa3d63a975d9
Commit message:
Add more APIs

Changed in this revision

AS289R2.cpp Show annotated file Show diff for this revision Revisions of this file
AS289R2.h Show annotated file Show diff for this revision Revisions of this file
--- a/AS289R2.cpp	Mon Sep 19 13:52:42 2016 +0000
+++ b/AS289R2.cpp	Fri Feb 03 09:28:48 2017 +0000
@@ -1,5 +1,5 @@
 /* AS289R2 Library, for a Thermal Printer Shield AS-289R2
- * Copyright (c) 2016, Toyomasa Watarai 
+ * Copyright (c) 2016, Toyomasa Watarai
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -153,6 +153,111 @@
     }
 }
 
+void AS289R2::setLineSpaceing(uint32_t space)
+{
+    _serial.putc(0x1B);
+    _serial.putc(0x33);
+    _serial.putc(space);
+}
+
+void AS289R2::defaultLineSpaceing()
+{
+    _serial.printf("\x1B\x33\x04");
+}
+
+void AS289R2::setPrintDirection(uint32_t direction)
+{
+    _serial.putc(0x1B);
+    _serial.putc(0x49);
+    _serial.putc(direction);
+}
+
+void AS289R2::putPaperFeed(uint32_t space)
+{
+    _serial.putc(0x1B);
+    _serial.putc(0x4A);
+    _serial.putc(space);
+}
+
+void AS289R2::setInterCharacterSpace(uint32_t space)
+{
+    _serial.putc(0x1B);
+    _serial.putc(0x20);
+    _serial.putc(space);
+}
+
+void AS289R2::defaultInterCharacterSpace()
+{
+    _serial.printf("\x1B\x20\x01");
+}
+
+void AS289R2::putPrintPosition(uint32_t position)
+{
+    _serial.putc(0x1B);
+    _serial.putc(0x6c);
+    _serial.putc(position);
+}
+
+void AS289R2::setScript(uint32_t script)
+{
+    _serial.putc(0x1B);
+    _serial.putc(0x73);
+    _serial.putc(script);
+}
+
+void AS289R2::clearScript()
+{
+    _serial.printf("\x1B\x73\x30");
+}
+
+void AS289R2::setQuadrupleSize()
+{
+    _serial.printf("\x1C\x57\x31");
+}
+
+void AS289R2::clearQuadrupleSize()
+{
+    _serial.printf("\x1C\x57\x30");
+}
+
+void AS289R2::setEnlargement(uint32_t width, uint32_t height)
+{
+    _serial.putc(0x1C);
+    _serial.putc(0x65);
+    _serial.putc(width);
+    _serial.putc(height);
+}
+
+void AS289R2::clearEnlargement()
+{
+    _serial.printf("\x1C\x65\x31\x31");
+}
+
+void AS289R2::setBarCodeHeight(uint32_t height)
+{
+    _serial.putc(0x1D);
+    _serial.putc(0x68);
+    _serial.putc(height);
+}
+
+void AS289R2::defaultBarCodeHeight()
+{
+    _serial.printf("\x1D\x68\x50");
+}
+
+void AS289R2::setBarCodeBarSize(uint32_t narrowbar, uint32_t widebar)
+{
+    _serial.putc(0x1D);
+    _serial.putc(0x77);
+    _serial.putc(narrowbar);
+    _serial.putc(widebar);
+}
+
+void AS289R2::defaultBarCodeBarSize()
+{
+    _serial.printf("\x1D\x77\x02\x05");
+}
+
 int AS289R2::_putc(int value)
 {
     _serial.putc(value);
--- a/AS289R2.h	Mon Sep 19 13:52:42 2016 +0000
+++ b/AS289R2.h	Fri Feb 03 09:28:48 2017 +0000
@@ -1,5 +1,5 @@
 /* AS289R2 Library, for a Thermal Printer Shield AS-289R2
- * Copyright (c) 2016, Toyomasa Watarai 
+ * Copyright (c) 2016, Toyomasa Watarai
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -19,7 +19,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
- 
+
 #ifndef MBED_AS289R2_H
 #define MBED_AS289R2_H
 
@@ -35,9 +35,9 @@
  * @code
  * #include "mbed.h"
  * #include "AS829R2.h"
- * 
+ *
  * AS829R2 tp(D1); // tx, 9600bps
- * 
+ *
  * int main() {
  *     tp.printf("Hello World!\r");
  * }
@@ -116,7 +116,7 @@
      *
      */
     void clearBuffer(void);
-    
+
     /** Set double height size font
      *
      */
@@ -181,6 +181,102 @@
      */
     void printBitmapImage(uint32_t cmd, uint16_t lines, const char * image);
 
+    /** Set Line Spaceing
+     *
+     * @param space line spacing
+     */
+    void setLineSpaceing(uint32_t space);
+
+    /** Set as default Line Spaceing
+     *
+     */
+    void defaultLineSpaceing(void);
+
+    /** Set Print Direction
+     *
+     * @param direction Print direction
+     */
+    void setPrintDirection(uint32_t direction);
+
+    /** Send feed code
+     *
+     * @param space Paper feed
+     */
+    void putPaperFeed(uint32_t space);
+
+    /** Set Inter Character Space
+     *
+     * @param space inter-character space
+     */
+    void setInterCharacterSpace(uint32_t space);
+
+    /** Set as default Inter Character Space
+     *
+     */
+    void defaultInterCharacterSpace(void);
+
+    /** Send Print Position
+     *
+     * @param position Print position
+     */
+    void putPrintPosition(uint32_t position);
+
+    /** Set Script
+     *
+     * @param script Superscript and Subsprict
+     */
+    void setScript(uint32_t script);
+
+    /** Clear Script
+     *
+     */
+    void clearScript(void);
+
+    /** Set Quadruple size
+     *
+     */
+    void setQuadrupleSize(void);
+
+    /** Clear Quadruple size
+     *
+     */
+    void clearQuadrupleSize(void);
+
+    /** Set Enlargement size
+     *
+     * @param width enlargement
+     * @param height enlargement
+     */
+    void setEnlargement(uint32_t width, uint32_t height);
+
+    /** Clear Enlargement size
+     *
+     */
+    void clearEnlargement(void);
+
+    /** Set BarCode Height size
+     *
+     * @param height Bar height
+     */
+    void setBarCodeHeight(uint32_t height);
+
+    /** Set as default BarCode Height size
+     *
+     */
+    void defaultBarCodeHeight(void);
+
+    /** Set BarCode Bar size
+     *
+     * @param narrowbar narrow bars size
+     * @param widebar wide bars size
+     */
+    void setBarCodeBarSize(uint32_t narrowbar, uint32_t widebar);
+
+    /** Set as default BarCode Bar size
+     *
+     */
+    void defaultBarCodeBarSize(void);
+
 private:
     Serial *_serial_p;
     Serial &_serial;