1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

revise methods and installation

This commit is contained in:
Patrick Kanzler
2023-08-10 01:03:02 +02:00
parent b3445b2c6f
commit aacc392c9a
4 changed files with 43 additions and 23 deletions

View File

@@ -45,6 +45,8 @@ HW_RESET = ESC + b"\x3f\x0a\x00" # Reset printer hardware
_CASH_DRAWER = (
lambda m, t1="", t2="": ESC + b"p" + m + six.int2byte(t1) + six.int2byte(t2)
)
#: decimal cash drawer kick sequence
CD_KICK_DEC_SEQUENCE = (
lambda esc, p, m, t1=50, t2=50: six.int2byte(esc)
+ six.int2byte(p)
@@ -52,8 +54,10 @@ CD_KICK_DEC_SEQUENCE = (
+ six.int2byte(t1)
+ six.int2byte(t2)
)
CD_KICK_2 = _CASH_DRAWER(b"\x00", 50, 50) # Sends a pulse to pin 2 []
CD_KICK_5 = _CASH_DRAWER(b"\x01", 50, 50) # Sends a pulse to pin 5 []
#: Sends a pulse to pin 2 []
CD_KICK_2 = _CASH_DRAWER(b"\x00", 50, 50)
#: Sends a pulse to pin 5 []
CD_KICK_5 = _CASH_DRAWER(b"\x01", 50, 50)
# Paper Cutter
_CUT_PAPER = lambda m: GS + b"V" + m

View File

@@ -1021,8 +1021,11 @@ class Escpos(object):
def cashdraw(self, pin):
"""Send pulse to kick the cash drawer
Kick cash drawer on pin 2 or pin 5 according to default parameter.
For non default parameter send a decimal sequence i.e. [27,112,48] or [27,112,0,25,255]
Kick cash drawer on pin 2 (:py:const:`~escpos.constants.CD_KICK_2`)
or pin 5 (:py:const:`~escpos.constants.CD_KICK_5`)
according to the default parameters.
For non default parameters send a decimal sequence i.e.
[27,112,48] or [27,112,0,25,255].
:param pin: pin number, 2 or 5 or list of decimals
:raises: :py:exc:`~escpos.exceptions.CashDrawerError`
@@ -1094,7 +1097,7 @@ class Escpos(object):
def print_and_feed(self, n=1):
"""Print data in print buffer and feed *n* lines
if n not in range (0, 255) then ValueError will be raised
If n not in range (0, 255) then a ValueError will be raised.
:param n: number of n to feed. 0 <= n <= 255. default: 1
:raises ValueError: if not 0 <= n <= 255
@@ -1144,17 +1147,24 @@ class Escpos(object):
def panel_buttons(self, enable=True):
"""Controls the panel buttons on the printer (e.g. FEED)
When enable is set to False the panel buttons on the printer will be disabled. Calling the method with
enable=True or without argument will enable the panel buttons.
When enable is set to False the panel buttons on the printer
will be disabled.
Calling the method with `enable=True` or without argument
will enable the panel buttons.
If panel buttons are enabled, the function of the panel button, such as feeding, will be executed upon pressing
the button. If the panel buttons are disabled, pressing them will not have any effect.
If panel buttons are enabled, the function of the panel button,
such as feeding, will be executed upon pressing the button.
If the panel buttons are disabled, pressing them will not have
any effect.
This command is effective until the printer is initialized, reset or power-cycled. The default is enabled panel
buttons.
This command is effective until the printer is initialized,
resetted or power-cycled.
The default is enabled panel buttons.
Some panel buttons will always work, especially when printer is opened. See for more information the manual
of your printer and the escpos-command-reference.
Some panel buttons will always work, especially when the
printer is opened.
See for more information the manual of your printer and
the escpos-command-reference.
:param enable: controls the panel buttons
:rtype: None
@@ -1166,7 +1176,8 @@ class Escpos(object):
def query_status(self, mode):
"""
Queries the printer for its status, and returns an array of integers containing it.
Queries the printer for its status, and returns an array
of integers containing it.
:param mode: Integer that sets the status mode queried to the printer.
- RT_STATUS_ONLINE: Printer status.