forked from adafruit/Adafruit-Thermal-Printer-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adafruit_Thermal.h
141 lines (119 loc) · 3.43 KB
/
Adafruit_Thermal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*************************************************************************
This is an Arduino library for the Adafruit Thermal Printer.
Pick one up at --> http://www.adafruit.com/products/597
These printers use TTL serial to communicate, 2 pins are required.
Adafruit invests time and resources providing this open source code.
Please support Adafruit and open-source hardware by purchasing products
from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution.
*************************************************************************/
#ifndef Thermal_h
#define Thermal_h
#if ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
#else
#include "WProgram.h"
#include "WConstants.h"
#include "NewSoftSerial.h"
#endif
// Barcode types
#define UPC_A 0
#define UPC_E 1
#define EAN13 2
#define EAN8 3
#define CODE39 4
#define I25 5
#define CODEBAR 6
#define CODE93 7
#define CODE128 8
#define CODE11 9
#define MSI 10
#if ARDUINO >= 100
#define SERIAL_IMPL SoftwareSerial
#define PRINTER_PRINT(a) _printer->write(a);
#else
#define SERIAL_IMPL NewSoftSerial
#define PRINTER_PRINT(a) _printer->print(a, BYTE);
#endif
class Adafruit_Thermal : public Print {
public:
Adafruit_Thermal(int RX_Pin, int TX_Pin);
void
begin(int heatTime=200),
reset(),
setDefault(),
test(),
testPage(),
normal(),
inverseOn(),
inverseOff(),
upsideDownOn(),
upsideDownOff(),
doubleHeightOn(),
doubleHeightOff(),
doubleWidthOn(),
doubleWidthOff(),
boldOn(),
boldOff(),
underlineOn(uint8_t weight=1),
underlineOff(),
strikeOn(),
strikeOff(),
justify(char value),
feed(uint8_t x=1),
feedRows(uint8_t),
flush(),
online(),
offline(),
sleep(),
sleepAfter(uint8_t seconds),
wake(),
listen(),
setSize(char value),
setLineHeight(int val=32),
printBarcode(char * text, uint8_t type),
setBarcodeHeight(int val=50),
printBitmap(int w, int h, const uint8_t *bitmap, bool fromProgMem = true),
printBitmap(int w, int h, Stream *stream),
printBitmap(Stream *stream),
timeoutSet(unsigned long),
timeoutWait(),
setTimes(unsigned long, unsigned long),
setCharSpacing(int spacing), // Not working
tab(); // Not working
bool hasPaper();
#if ARDUINO >= 100
size_t write(uint8_t c);
#else
void write(uint8_t c);
#endif
protected:
SERIAL_IMPL
*_printer;
uint8_t
prevByte, // Last character issued to printer
column, // Last horizontal column printed
maxColumn, // Page width (output 'wraps' at this point)
charHeight, // Height of characters, in 'dots'
lineSpacing, // Inter-line spacing (not line height), in dots
barcodeHeight; // Barcode height in dots, not including text
unsigned long
resumeTime, // Wait until micros() exceeds this before sending byte
dotPrintTime, // Time to print a single dot line, in microseconds
dotFeedTime; // Time to feed a single dot line, in microseconds
int
printMode,
_RX_Pin,
_TX_Pin;
void
setPrintMode(uint8_t mask),
unsetPrintMode(uint8_t mask),
writePrintMode(),
writeBytes(uint8_t a),
writeBytes(uint8_t a, uint8_t b),
writeBytes(uint8_t a, uint8_t b, uint8_t c),
writeBytes(uint8_t a, uint8_t b, uint8_t c, uint8_t d);
};
#endif // Thermal_h