Add support for slip/cheque dot matrix printers (#485)

* Add support for slip/cheque dot matrix printers

* format

* fix comments

---------

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
This commit is contained in:
Mathieu Poussin 2023-05-09 01:25:48 +02:00 committed by GitHub
parent 6849dd3979
commit 7bf8d4e4b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 0 deletions

View File

@ -1,9 +1,11 @@
Ahmed Tahri Ahmed Tahri
akeonly akeonly
Alejandro Hernández
Alexander Bougakov Alexander Bougakov
Alex Debiasio Alex Debiasio
Asuki Kono Asuki Kono
belono belono
B. Howell
Brian Brian
Christoph Heuel Christoph Heuel
Cody (Quantified Code Bot) Cody (Quantified Code Bot)
@ -11,6 +13,7 @@ csoft2k
Curtis // mashedkeyboard Curtis // mashedkeyboard
Davis Goglin Davis Goglin
Dean Rispin Dean Rispin
dependabot[bot]
Dmytro Katyukha Dmytro Katyukha
Gerard Marull-Paretas Gerard Marull-Paretas
Hark Hark
@ -21,6 +24,7 @@ Kristi
ldos ldos
Lucy Linder Lucy Linder
Manuel F Martinez Manuel F Martinez
Mathieu Poussin
Maximilian Wagenbach Maximilian Wagenbach
Michael Billington Michael Billington
Michael Elsdörfer Michael Elsdörfer

View File

@ -77,6 +77,16 @@ LINE_DISPLAY_CLOSE = ESC + b"\x3d\x01"
SHEET_SLIP_MODE = ESC + b"\x63\x30\x04" # slip paper 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_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 # Text format
# TODO: Acquire the "ESC/POS Application Programming Guide for Paper Roll # TODO: Acquire the "ESC/POS Application Programming Guide for Paper Roll
# Printers" and tidy up this stuff too. # Printers" and tidy up this stuff too.

View File

@ -30,6 +30,11 @@ from .constants import (
QR_ECLEVEL_M, QR_ECLEVEL_M,
QR_ECLEVEL_H, QR_ECLEVEL_H,
QR_ECLEVEL_Q, QR_ECLEVEL_Q,
SHEET_ROLL_MODE,
SHEET_SLIP_MODE,
SLIP_PRINT_AND_EJECT,
SLIP_SELECT,
SLIP_EJECT,
) )
from .constants import ( from .constants import (
QR_MODEL_1, QR_MODEL_1,
@ -1011,6 +1016,41 @@ class Escpos(object):
if status[0] & RT_MASK_PAPER == RT_MASK_PAPER: if status[0] & RT_MASK_PAPER == RT_MASK_PAPER:
return 2 return 2
def target(self, type="ROLL"):
"""Select where to print to
Print to the thermal printer by default (ROLL) or
print to the slip dot matrix printer if supported (SLIP)
"""
if type.upper() == "ROLL":
self._raw(SHEET_ROLL_MODE)
elif type.upper() == "SLIP":
self._raw(SHEET_SLIP_MODE)
else:
raise ValueError("Unsupported target")
def eject_slip(self):
"""Eject the slip/cheque"""
self._raw(SLIP_EJECT)
def print_and_eject_slip(self):
"""Print and eject
Prints data from the buffer to the slip station and if the paper
sensor is covered, 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.
"""
self._raw(SLIP_PRINT_AND_EJECT)
def use_slip_only(self):
"""Selects the Slip Station for all functions.
The receipt station is the default setting after the printer
is initialized or the Clear Printer (0x10) command is received
"""
self._raw(SLIP_SELECT)
class EscposIO(object): class EscposIO(object):
"""ESC/POS Printer IO object """ESC/POS Printer IO object