This commit is contained in:
Patrick Kanzler 2023-05-09 01:19:07 +02:00
parent c2ec6051d7
commit a827bcec20
2 changed files with 16 additions and 8 deletions

View File

@ -78,10 +78,14 @@ SHEET_SLIP_MODE = ESC + b"\x63\x30\x04" # slip paper
SHEET_ROLL_MODE = ESC + b"\x63\x30\x01" # paper roll SHEET_ROLL_MODE = ESC + b"\x63\x30\x01" # paper roll
# Slip specific codes # Slip specific codes
SLIP_EJECT = ESC + b"\x4b\xc0" # Eject the slip or cheque SLIP_EJECT = ESC + b"\x4b\xc0" # Eject the slip or cheque
SLIP_SELECT = FS # Select the slip station as default station SLIP_SELECT = FS # Select the slip station as default station
SLIP_SET_WAIT_TIME = ESC + b"\x1b\x66" # Set timeout waiting for a slip/cheque to be inserted SLIP_SET_WAIT_TIME = (
SLIP_PRINT_AND_EJECT = b"\x0c" # Print the buffer and eject (after waiting for the paper to be inserted) ESC + b"\x1b\x66"
) # Set timeout waiting for a slip/cheque to be inserted
SLIP_PRINT_AND_EJECT = (
b"\x0c" # Print the buffer and eject (after waiting for the paper to be inserted)
)
# Text format # Text format
# TODO: Acquire the "ESC/POS Application Programming Guide for Paper Roll # TODO: Acquire the "ESC/POS Application Programming Guide for Paper Roll

View File

@ -34,7 +34,7 @@ from .constants import (
SHEET_SLIP_MODE, SHEET_SLIP_MODE,
SLIP_PRINT_AND_EJECT, SLIP_PRINT_AND_EJECT,
SLIP_SELECT, SLIP_SELECT,
SLIP_EJECT SLIP_EJECT,
) )
from .constants import ( from .constants import (
QR_MODEL_1, QR_MODEL_1,
@ -1022,10 +1022,11 @@ class Escpos(object):
Print to the thermal printer by default (ROLL) or Print to the thermal printer by default (ROLL) or
print to the slip dot matrix printer if supported (SLIP) print to the slip dot matrix printer if supported (SLIP)
""" """
def target(self, type='ROLL'):
if type.upper() == 'ROLL': def target(self, type="ROLL"):
if type.upper() == "ROLL":
self._raw(SHEET_ROLL_MODE) self._raw(SHEET_ROLL_MODE)
elif type.upper() == 'SLIP': elif type.upper() == "SLIP":
self._raw(SHEET_SLIP_MODE) self._raw(SHEET_SLIP_MODE)
else: else:
raise ValueError("Unsupported target") raise ValueError("Unsupported target")
@ -1033,6 +1034,7 @@ class Escpos(object):
""" """
Eject the slip/cheque Eject the slip/cheque
""" """
def eject_slip(self): def eject_slip(self):
self._raw(SLIP_EJECT) self._raw(SLIP_EJECT)
@ -1041,6 +1043,7 @@ class Escpos(object):
reverses the slip out the front of the printer far enough to be accessible to the operator. reverses the slip out the front of the printer far enough to be accessible to the operator.
The impact station opens the platen in all cases. The impact station opens the platen in all cases.
""" """
def print_and_eject_slip(self): def print_and_eject_slip(self):
self._raw(SLIP_PRINT_AND_EJECT) self._raw(SLIP_PRINT_AND_EJECT)
@ -1049,6 +1052,7 @@ class Escpos(object):
The receipt station is the default setting after the printer is initialized or The receipt station is the default setting after the printer is initialized or
the Clear Printer (0x10) command is received the Clear Printer (0x10) command is received
""" """
def use_slip_only(self): def use_slip_only(self):
self._raw(SLIP_SELECT) self._raw(SLIP_SELECT)