adafruit_thermal_printer.thermal_printer - Thermal Printer Driver

Thermal printer control module built to work with small serial thermal receipt printers. Note that these printers have many different firmware versions and care must be taken to select the appropriate module inside this package for your firmware printer:

  • thermal_printer = The latest printers with firmware version 2.68+
  • thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
  • thermal_printer_legacy = Printers with firmware version before 2.64.
  • Author(s): Tony DiCola

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_thermal_printer.thermal_printer.ThermalPrinter(uart, *, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03, auto_warm_up=True)[source]

Thermal printer for printers with firmware version from 2.68 and below 2.168

feed(lines)[source]

Advance paper by specified number of blank lines.

feed_rows(rows)[source]

Advance paper by specified number of pixel rows.

flush()[source]

Flush data pending in the printer.

has_paper()[source]

Return a boolean indicating if the printer has paper. You MUST have the serial RX line hooked up for this to work. NOTE: be VERY CAREFUL to ensure your board can handle a 5V serial input before hooking up the RX line!

inverse

Set the inverse printing mode boolean to enable or disable inverse printing.

justify

Set the justification of text, must be a value of JUSTIFY_LEFT, JUSTIFY_CENTER, or JUSTIFY_RIGHT.

offline()[source]

Put the printer into an offline state. No other commands can be sent until an online call is made.

online()[source]

Put the printer into an online state after previously put offline.

print(text, end='\n')[source]

Print a line of text. Optionally specify the end keyword to override the new line printed after the text (set to None to disable the new line entirely).

print_barcode(text, barcode_type)[source]

Print a barcode with the specified text/number (the meaning varies based on the type of barcode) and type. Type is a value from the datasheet or class-level variables like UPC_A, etc. for convenience. Note the type value changes depending on the firmware version so use class-level values where possible!

reset()[source]

Reset the printer.

send_command(command)[source]

Send a command string to the printer.

set_defaults()[source]

Set default printing and text options. This is useful to reset back to a good state after printing different size, weight, etc. text.

size

Set the size of text, must be a value of SIZE_SMALL, SIZE_MEDIUM, or SIZE_LARGE.

tab()[source]

Print a tab (i.e. move to next 4 character block). Note this is only supported on more recent firmware printers!

test_page()[source]

Print a test page.

underline

Set the underline state of the text, must be None (off), UNDERLINE_THIN, or UNDERLINE_THICK.

up_down_mode

Turns on/off upside-down printing mode

warm_up(heat_time=120)[source]

Initialize the printer. Can specify an optional heat_time keyword to override the default heating timing of 1.2 ms. See the datasheet for details on the heating time value (duration in 10uS increments). Note that calling this function will take about half a second for the printer to intialize and warm up.

adafruit_thermal_printer.thermal_printer_264.ThermalPrinter

Thermal printer control module built to work with small serial thermal receipt printers. Note that these printers have many different firmware versions and care must be taken to select the appropriate module inside this package for your firmware printer:

  • thermal_printer_2168 = Printers with firmware version 2.168+.
  • thermal_printer = The latest printers with firmware version 2.68 up to 2.168
  • thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
  • thermal_printer_legacy = Printers with firmware version before 2.64.
  • Author(s): Tony DiCola
class adafruit_thermal_printer.thermal_printer_264.ThermalPrinter(uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03)[source]

Thermal printer for printers with firmware version 2.64 up to (but NOT including) 2.68.

adafruit_thermal_printer.thermal_printer_legacy.ThermalPrinter

Thermal printer control module built to work with small serial thermal receipt printers. Note that these printers have many different firmware versions and care must be taken to select the appropriate module inside this package for your firmware printer:

  • thermal_printer_2168 = Printers with firmware version 2.168+.
  • thermal_printer = The latest printers with firmware version 2.68 up to 2.168
  • thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
  • thermal_printer_legacy = Printers with firmware version before 2.64.
  • Author(s): Tony DiCola
class adafruit_thermal_printer.thermal_printer_legacy.ThermalPrinter(uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03)[source]

Thermal printer for printers with firmware version before 2.64.

feed(lines)[source]

Advance paper by specified number of blank lines.

has_paper()[source]

Return a boolean indicating if the printer has paper. You MUST have the serial RX line hooked up for this to work.

Note

be VERY CAREFUL to ensure your board can handle a 5V serial input before hooking up the RX line!

print_barcode(text, barcode_type)[source]

Print a barcode with the specified text/number (the meaning varies based on the type of barcode) and type. Type is a value from the datasheet or class-level variables like UPC_A, etc. for convenience. Note the type value changes depending on the firmware version so use class-level values where possible!

reset()[source]

Reset the printer.