1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-08-24 09:03:34 +00:00

modernize and cleanup documentation (#542)

* disable system packages on rtd

* install pycups on rtd

* enable cups binding in documentation

* document CupsPrinter

* fix formatting

* revise methods and installation

* revise user/printers

* revise raspi section

* further revise
This commit is contained in:
Patrick Kanzler
2023-08-10 01:38:47 +02:00
committed by GitHub
parent 4c2dcdfac6
commit 2b62c8e28d
18 changed files with 174 additions and 103 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.

View File

@@ -440,9 +440,11 @@ if _CUPSPRINT:
"""Simple CUPS printer connector.
.. note::
Requires _pycups_ which in turn needs the cups development library package:
- Ubuntu/Debian: _libcups2-dev_
- OpenSuse/Fedora: _cups-devel_
Requires ``pycups`` which in turn needs the cups development library package:
- Ubuntu/Debian: ``libcups2-dev``
- OpenSuse/Fedora: ``cups-devel``
"""
def __init__(self, printer_name=None, *args, **kwargs):