Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit b4bfee5

Browse files
committed
Add get_printer_class function and new global constants to package-level scope.
1 parent a3d9c90 commit b4bfee5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

adafruit_thermal_printer/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from adafruit_thermal_printer.thermal_printer import JUSTIFY_LEFT, \
2+
JUSTIFY_CENTER, JUSTIFY_RIGHT, SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE, \
3+
UNDERLINE_THIN, UNDERLINE_THICK
4+
5+
def get_printer_class(version):
6+
"""Retrieve the class to construct for an instance of the specified
7+
thermal printer version. Pass in the printer firmware version as a numeric
8+
value like 2.68, 2.64, etc. You can get this value by holding the button
9+
on the printer as it powers on and a test page is printed--look at the
10+
bottom of the test page for the version number.
11+
"""
12+
assert version is not None
13+
assert version >= 0.0
14+
if version < 2.64:
15+
import adafruit_thermal_printer.thermal_printer_legacy as thermal_printer
16+
elif version < 2.68:
17+
import adafruit_thermal_printer.thermal_printer_264 as thermal_printer
18+
else:
19+
import adafruit_thermal_printer.thermal_printer as thermal_printer
20+
return thermal_printer.ThermalPrinter

0 commit comments

Comments
 (0)