From a827bcec209572e921bbf6000c29a0c87d3b36e4 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Tue, 9 May 2023 01:19:07 +0200 Subject: [PATCH] format --- src/escpos/constants.py | 12 ++++++++---- src/escpos/escpos.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/escpos/constants.py b/src/escpos/constants.py index 83edd6a..3c018db 100644 --- a/src/escpos/constants.py +++ b/src/escpos/constants.py @@ -78,10 +78,14 @@ SHEET_SLIP_MODE = ESC + b"\x63\x30\x04" # slip paper SHEET_ROLL_MODE = ESC + b"\x63\x30\x01" # paper roll # Slip specific codes -SLIP_EJECT = ESC + b"\x4b\xc0" # Eject the slip or cheque -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_PRINT_AND_EJECT = b"\x0c" # Print the buffer and eject (after waiting for the paper to be inserted) +SLIP_EJECT = ESC + b"\x4b\xc0" # Eject the slip or cheque +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_PRINT_AND_EJECT = ( + b"\x0c" # Print the buffer and eject (after waiting for the paper to be inserted) +) # Text format # TODO: Acquire the "ESC/POS Application Programming Guide for Paper Roll diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 94184c6..3597e3c 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -34,7 +34,7 @@ from .constants import ( SHEET_SLIP_MODE, SLIP_PRINT_AND_EJECT, SLIP_SELECT, - SLIP_EJECT + SLIP_EJECT, ) from .constants import ( QR_MODEL_1, @@ -1022,10 +1022,11 @@ class Escpos(object): Print to the thermal printer by default (ROLL) or 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) - elif type.upper() == 'SLIP': + elif type.upper() == "SLIP": self._raw(SHEET_SLIP_MODE) else: raise ValueError("Unsupported target") @@ -1033,6 +1034,7 @@ class Escpos(object): """ Eject the slip/cheque """ + def eject_slip(self): 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. The impact station opens the platen in all cases. """ + def print_and_eject_slip(self): 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 Clear Printer (0x10) command is received """ + def use_slip_only(self): self._raw(SLIP_SELECT)