Adafruit Thermal Printer Library
Public Member Functions | List of all members
Adafruit_Thermal Class Reference

#include <Adafruit_Thermal.h>

Inheritance diagram for Adafruit_Thermal:

Public Member Functions

 Adafruit_Thermal (Stream *s=&Serial, uint8_t dtr=255)
 Thermal constructor. More...
 
size_t write (uint8_t c)
 Writes a character to the thermal printer. More...
 
void begin (uint16_t version=268)
 
void boldOff ()
 Disables bold text.
 
void boldOn ()
 Enables bold text.
 
void doubleHeightOff ()
 Disables double-height text.
 
void doubleHeightOn ()
 Enables double-height text.
 
void doubleWidthOff ()
 Disables double-width text.
 
void doubleWidthOn ()
 Enables double-width text.
 
void feed (uint8_t x=1)
 Feeds by the specified number of lines. More...
 
void feedRows (uint8_t)
 Feeds by the specified number of individual pixel rows. More...
 
void flush ()
 Flush data pending in the printer.
 
void inverseOff ()
 Disables white/black reverse printing mode.
 
void inverseOn ()
 Enables white/black reverse printing mode.
 
void justify (char value)
 Set the justification of text. More...
 
void offline ()
 Put the printer into an offline state. No other commands can be sent until an online call is made.
 
void online ()
 Put the printer into an online state after previously put offline.
 
void printBarcode (const char *text, uint8_t type)
 Print a barcode. More...
 
void printBitmap (int w, int h, const uint8_t *bitmap, bool fromProgMem=true)
 Prints a bitmap. More...
 
void printBitmap (int w, int h, Stream *fromStream)
 Prints a bitmap. More...
 
void printBitmap (Stream *fromStream)
 Prints a bitmap. More...
 
void normal ()
 Sets text to normal mode.
 
void reset ()
 Reset the printer.
 
void setBarcodeHeight (uint8_t val=50)
 Sets the barcode height. More...
 
void setFont (char font='A')
 Sets the font. More...
 
void setCharSpacing (int spacing=0)
 Sets the character spacing. More...
 
void setCharset (uint8_t val=0)
 Sets the character set. More...
 
void setCodePage (uint8_t val=0)
 Sets character code page. More...
 
void setDefault ()
 Sets the default settings.
 
void setLineHeight (int val=30)
 Sets the line height. More...
 
void setMaxChunkHeight (int val=256)
 Set max rows to write. More...
 
void setSize (char value)
 Sets text size. More...
 
void setTimes (unsigned long, unsigned long)
 Sets print and feed speed. More...
 
void setHeatConfig (uint8_t dots=11, uint8_t time=120, uint8_t interval=40)
 Sets print head heating configuration. More...
 
void setPrintDensity (uint8_t density=10, uint8_t breakTime=2)
 Sets print density. More...
 
void sleep ()
 Puts the printer into a low-energy state immediately.
 
void sleepAfter (uint16_t seconds)
 Puts the printer into a low-energe state after the given number of seconds. More...
 
void strikeOff ()
 Disables delete line mode.
 
void strikeOn ()
 Enables delete line mode.
 
void tab ()
 Sends tab to device.
 
void test ()
 Prints test text.
 
void testPage ()
 Prints test page.
 
void timeoutSet (unsigned long)
 Sets the estimated completion time for a just-issued task. More...
 
void timeoutWait ()
 Waits for the prior task to complete.
 
void underlineOff ()
 Disables underline.
 
void underlineOn (uint8_t weight=1)
 Enables underline. More...
 
void upsideDownOff ()
 Disables upside-down text mode.
 
void upsideDownOn ()
 Enables upside-down text mode.
 
void wake ()
 Wakes device that was in sleep mode.
 
bool hasPaper ()
 Whether or not the printer has paper. More...
 

Detailed Description

Driver for the thermal printer

Constructor & Destructor Documentation

◆ Adafruit_Thermal()

Adafruit_Thermal::Adafruit_Thermal ( Stream *  s = &Serial,
uint8_t  dtr = 255 
)

Thermal constructor.

Parameters
sSerial stream
dtrData Terminal Ready control

Member Function Documentation

◆ write()

size_t Adafruit_Thermal::write ( uint8_t  c)

Writes a character to the thermal printer.

Parameters
cCharacter to write
Returns
Returns true if successful

◆ begin()

void Adafruit_Thermal::begin ( uint16_t  version = 268)
Parameters
versionfirmware version as integer, e.g. 268 = 2.68 firmware

◆ feed()

void Adafruit_Thermal::feed ( uint8_t  x = 1)

Feeds by the specified number of lines.

Parameters
xHow many lines to feed

◆ feedRows()

void Adafruit_Thermal::feedRows ( uint8_t  rows)

Feeds by the specified number of individual pixel rows.

Parameters
rowsHow many rows to feed

◆ justify()

void Adafruit_Thermal::justify ( char  value)

Set the justification of text.

Parameters
valuejustification, must be JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHT

◆ printBarcode()

void Adafruit_Thermal::printBarcode ( const char *  text,
uint8_t  type 
)

Print a barcode.

Parameters
textThe specified text/number (the meaning varies based on the type of barcode) and type to write to the barcode
typeValue from the datasheet or class-level variables like UPC-A. Note the type value changes depending on the firmware version so use class-level values where possible

◆ printBitmap() [1/3]

void Adafruit_Thermal::printBitmap ( int  w,
int  h,
const uint8_t *  bitmap,
bool  fromProgMem = true 
)

Prints a bitmap.

Parameters
wWidth of the image in pixels
hHeight of the image in pixels
bitmapBitmap data, from a file.
fromProgMem

◆ printBitmap() [2/3]

void Adafruit_Thermal::printBitmap ( int  w,
int  h,
Stream *  fromStream 
)

Prints a bitmap.

Parameters
wWidth of the image in pixels
hHeight of the image in pixels
fromStreamStream to get bitmap data from

◆ printBitmap() [3/3]

void Adafruit_Thermal::printBitmap ( Stream *  fromStream)

Prints a bitmap.

Parameters
fromStreamStream to get bitmap data from

◆ setBarcodeHeight()

void Adafruit_Thermal::setBarcodeHeight ( uint8_t  val = 50)

Sets the barcode height.

Parameters
valDesired height of the barcode

◆ setFont()

void Adafruit_Thermal::setFont ( char  font = 'A')

Sets the font.

Parameters
fontDesired font, either A or B

◆ setCharSpacing()

void Adafruit_Thermal::setCharSpacing ( int  spacing = 0)

Sets the character spacing.

Parameters
spacingDesired character spacing

◆ setCharset()

void Adafruit_Thermal::setCharset ( uint8_t  val = 0)

Sets the character set.

Parameters
valValue of the desired character set

◆ setCodePage()

void Adafruit_Thermal::setCodePage ( uint8_t  val = 0)

Sets character code page.

Parameters
valValue of the desired character code page

◆ setLineHeight()

void Adafruit_Thermal::setLineHeight ( int  val = 30)

Sets the line height.

Parameters
valDesired line height

◆ setMaxChunkHeight()

void Adafruit_Thermal::setMaxChunkHeight ( int  val = 256)

Set max rows to write.

Parameters
valMax rows to write

◆ setSize()

void Adafruit_Thermal::setSize ( char  value)

Sets text size.

Parameters
valueText size

◆ setTimes()

void Adafruit_Thermal::setTimes ( unsigned long  p,
unsigned long  f 
)

Sets print and feed speed.

Parameters
pprint speed
ffeed speed

◆ setHeatConfig()

void Adafruit_Thermal::setHeatConfig ( uint8_t  dots = 11,
uint8_t  time = 120,
uint8_t  interval = 40 
)

Sets print head heating configuration.

Parameters
dotsmax printing dots, 8 dots per increment
timeheating time, 10us per increment
intervalheating interval, 10 us per increment

◆ setPrintDensity()

void Adafruit_Thermal::setPrintDensity ( uint8_t  density = 10,
uint8_t  breakTime = 2 
)

Sets print density.

Parameters
densityprinting density
breakTimeprinting break time

◆ sleepAfter()

void Adafruit_Thermal::sleepAfter ( uint16_t  seconds)

Puts the printer into a low-energe state after the given number of seconds.

Parameters
secondsHow many seconds to wait until sleeping

◆ timeoutSet()

void Adafruit_Thermal::timeoutSet ( unsigned long  x)

Sets the estimated completion time for a just-issued task.

Parameters
xEstimated completion time

◆ underlineOn()

void Adafruit_Thermal::underlineOn ( uint8_t  weight = 1)

Enables underline.

Parameters
weightWeight of the line

◆ hasPaper()

bool Adafruit_Thermal::hasPaper ( )

Whether or not the printer has paper.

Returns
Returns true if there is still paper

The documentation for this class was generated from the following files: