81 Commits

Author SHA1 Message Date
Patrick Kanzler
91cbc264fc
Refactor to using f-strings (#608)
* update authors

* refactor to using f-strings
2023-12-11 00:34:29 +01:00
Patrick Kanzler
5914c7c560
allow qr to set all arguments to image (#600)
* allow qr to set all arguments to image

* increase coverage
2023-12-04 01:15:19 +01:00
Patrick Kanzler
9a1699ab94
add type annotations for escpos image handler (#599) 2023-12-03 23:36:35 +01:00
Patrick Kanzler
90c89e66f0 filter for ValueError too in dpi logic 2023-11-17 00:48:31 +01:00
Benito López
a00b98937b
Separate method open() and constructor, enhance consistency between connectors. (#584)
* Add self-open mechanism
* self-open mechanism through the 'device' property
* Separate open() and store connection in 'device'
* Restore device status to False on close()
* Add default value to all params + type annotations
* Add generic DeviceNotFoundError exception
* Update USBNotFoundError return code
* Enhance connectors consistency
* Fix LP printer stall
* Fix LP waste of paper due to auto-flush + flush on close
* Move platform dependent printers' guard to init

---------

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-10-16 11:36:07 +02:00
Patrick Kanzler
6d0c475b9a
refactor set method (#547)
* add type annotations
* Update setup.cfg
* improve mypy and test config
* get_profile_class returns a baseProfile
* mute mypy type issue
* add set_with_default
* docstring
* add test for empty call
* correct type annotations in set_with_default
* improve tests
* test for exception
* sort with isort
* add default value to get call
* empty string has the same effect: will not be found --> None
* add mypy test to workflow
* explicitely call mypy
* update spelling
2023-09-19 07:51:39 +02:00
Patrick Kanzler
cfa9ecf16d
Enable spell checking (#563)
* add spellchecking

* improve spelling

* improve spelling config

* extend word list

* improve spelling

* improve spelling

* escalate warning in spell check to failure

* fix spelling

* fix spelling

* add plural

* Update doc/spelling_wordlist.txt

* do not stop on warning

* require newest sphinxcontrib spelling

* remove old comment

* add authors as single line entry to spelling list

* reenable stop on warning
2023-09-07 22:08:31 +02:00
Patrick Kanzler
44444f3c51
Maintenance: fix read the docs and some annotations (#557) 2023-09-03 09:57:56 +02:00
Patrick Kanzler
c7c01cdbff
fix rtd theme (#553)
* use rtd_theme

* add types for serial

* annotate types where possible

* fix imports
2023-08-25 01:19:23 +02:00
Patrick Kanzler
3177c8d411
split off dependencies for optional installation (#546)
* add inheritance diagrams to all printers and exceptions
* split off printer implementations into separate files
* add wrapper that thros RuntimeError if not importable
* add dependency check for lp
* add dependency check for pyserial
* added check for usability
* import Win32Raw
* include WIn32Raw in documentation
* enable all extras on tox
* update github workflow
2023-08-17 01:37:50 +02:00
Patrick Kanzler
fbabd8ed88
Drop Py37, improve typing and docstrings (#544)
Drops Py3.7, improves typing and adds a mypy config, improves the docstrings and isorts the imports.

* configure isort
* sort with isort
* add github action
* enable flake8-docstrings
* fix docstrings
* add mypy env
* no implicit optional
* add type for raw
* add some type hints
2023-08-15 01:03:36 +02:00
Patrick Kanzler
2b62c8e28d
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
2023-08-10 01:38:47 +02:00
Alfredo orozco
df9e8ff394
Feature(escpos) Add buzzer function (#535)
* Add buzzer function
* Add `buzzer(time, duration)` function to control the buzzer on supported
   printers.
* Add unit tests for buzzer function.
* Update test_function_buzzer.py to pass black
* Run black in tests files
---------

Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
2023-07-27 19:10:19 +02:00
Benito López
9ff327d967
Remove sleep when quering status. Fixes #407 (#534)
* Remove sleep when quering status
* Remove unused import time
2023-07-23 23:22:27 +02:00
Patrick Kanzler
e9e8b10582
Fixes from ci (#533)
* break line

* remove unused imports

* remove unused os import

* make flake8 more strict

* configure flake for black

* fix action

* use importlib_resources

* rename deprecated methods
2023-07-21 23:03:46 +02:00
Benito López
3c11c1b9ab
New high level barcode method. Closes #245, #244. (#527)
* Merge software and hardware barcodes to one method

* Fix wrong sw barcode heigh/width

* Add missing param to _sw_barcode call

* Make barcode() smarter, improvements and clean up

* Use param font_size in sw_barcode()

* Update docstrings

* Update barcode examples and docs

* Add --force_software option to CLI

* Attempt to match the sw and hw barcode sizes

* Better approximation to native font size

* Fix docs build

* Update tests at test_function_softbarcode

* Fix exception

* Move image dpi setting to writter_options

* Fix _sw_barcode() docstring param

* Fix wrong default param in docstring

* improve linkage in documentation

---------

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
2023-07-12 20:45:41 +02:00
Mathieu Poussin
7bf8d4e4b8
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>
2023-05-09 01:25:48 +02:00
B. Howell
8bbbf7ceac
soft_barcode to render directly (#469)
Rendering to /dev/null by a call to .write causes an error. Calling .render directly is simpler and fixes the error.

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-05-09 01:07:56 +02:00
Patrick Kanzler
709d90809c fixed formatting with black 2023-04-19 22:23:23 +02:00
Patrick Kanzler
70d4da1364 format with black 2023-04-19 22:11:09 +02:00
Patrick Kanzler
435f2bba24 reformat codebase 2021-10-30 18:15:22 +02:00
B. Howell
69e9b9103e
Update escpos.py
Set block_text to use the default font. This means calls will wrap to full paper width.
2020-11-28 00:41:11 +01:00
Maximilian Wagenbach
ee6eef6db3 I verified that this works. Both modes cut the paper 95% of the way through. 2020-05-26 01:38:57 +02:00
Patrick Kanzler
f4e214ad17 add spellchecker with first conf, fix some errors 2020-05-11 23:39:56 +02:00
Romain Porte
8ca682e3ac soft_barcode: add new center=True option 2020-05-10 14:08:50 +02:00
Romain Porte
cb30d7a881 drop Python 2.7 support
Python 2.7 EOL is arriving on 2020-01-01: https://pythonclock.org/

This will allow us to use Python 3 only libraries, like python-barcode,
which can maintain a reduced, simpler codebase, due to only one version
to support.

Closes #371.

Signed-off-by: Romain Porte <microjoe@microjoe.org>
2020-05-10 10:55:44 +02:00
Maximilian Wagenbach
cc67cb1c1e Added some documentation and error handling to the image center flag. 2020-03-11 15:51:16 +01:00
Patrick Kanzler
5ff73595b6 fix links and impl (in qr-method) in docstrings
fixes #308
2019-06-16 01:54:47 +02:00
Patrick Kanzler
6c94f88c24
improve platform independence (#296)
* add os.devnull for platform independence

fixes #288

* add test for soft_barcode

* open devnull as binary

* add version identifier to pickle
2018-05-15 01:03:07 +02:00
primax79
d085e5c467 parameter for implementation of nonnative qrcode (#289) 2018-05-13 18:42:41 +02:00
Thijs Triemstra
4390dc4a9c fix is_online() (#282)
* fix is_online

* fix sphinx formatting

* reword
2018-05-02 09:25:04 +02:00
Thijs Triemstra
100c6b5e89 fix typo (#279) 2018-02-07 22:17:18 +01:00
reck
3c3dab95f5 raise exception when TypeError occurs in cashdraw (#268) 2017-12-03 23:21:29 +01:00
Lucy Linder
456f5b7aa6 Feature/check barcodes (#255)
* add a method to check barcode code format

ensure that the code to print is compatible with the ESC/POS formats and
also automatically check this format before printing (barcode() method).

* rewrite test using pytest's parametrize functionality

* add test for the 'check' argument

* update authors list
2017-10-08 20:05:18 +02:00
Romain Porte
b648cfd67f First attempt at centering images and QRs (#250)
This was tested on ZJ-5890 with success. By default centering is
deactivated for backward compatibility. Trying to center a QR code in
native mode will raise an exception as we do not know ATM if the native
rendering is centered by default or not.

* Added basic tests for center feature

* Check image size before centering
2017-08-31 09:25:35 +02:00
Patrick Kanzler
281eea125f fix abstract read-function
read does not need msg-parameter
2017-08-10 21:51:51 +02:00
Romain Porte
b64b534394 Add methods for simpler newlines (#246) 2017-08-01 17:09:24 +02:00
Patrick Kanzler
f8a2174108 fix typo 2017-07-27 23:06:59 +02:00
csoft2k
1f57b04974 Paper sensor querying command (#242)
The DLE EOT command allows querying the status of several features of
the printer.
Added to the online/offline status developed in #237, this commit adds a
paper sensor querying.

Tested with an Epson TM-T20II, which only has an end-paper sensor. The
near-end paper sensor should be tested with a compatible printer.
However, the implementation is quite straight-forward.
2017-07-27 23:05:50 +02:00
csoft2k
82c67aa646 Fix tabs behaviour (#238)
The changes done in this commit should help with the open issues:
#5, #27 and #161.
The old implementation lacked the NUL char at the end of the command, as
defined on the Epson ESC/POS Reference Guide (see
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=53
). Also, the horizontal tab control character (CTL_HT) shouldn't be
there.

This implementation allows setting up to 32 tabs with a given tab width.
Both values are checked to be in the valid ranges defined on the guide.
Also, the TabPosError exception text has been rewritten to define the
stated above.
2017-07-26 10:01:08 +02:00
Romain Porte
9e47ff2505 Added test for cut without feed, fixed raw code for it 2017-07-26 09:09:32 +02:00
Romain Porte
9bc3b30a60 Optional feed for cut (closes #213) 2017-07-26 09:09:32 +02:00
Romain Porte
5bd6dcf471 Ensure QR codes have a border large enough (#235)
*  Ensure QR codes have a border large enough
(The QR code spec requires a border at least 4*box_size thick but we can't
 just set border=16 because that results in a QR code more than 255px tall
 and I'm not yet ready to use fullimage() as a backend for it)
This fix was originally commited by Stephan Sokolow on 2014-05-22
* Let the user print stuff using qr example
* fix tests
2017-07-24 15:04:54 +02:00
csoft2k
89dfb6cf86 Added the DLE EOT querying command. (#237)
* Added the DLE EOT querying command.
Added a function to check whether the printer is online or not, as well
as a reading method for USB printers.
* Update AUTHORS
* Add entry to .mailmap
* currently USB only
2017-07-24 13:57:02 +02:00
Patrick Kanzler
83b426f5fd Merge pull request #222 from MicroJoe/software-barcode
First implementation of software barcode
2017-06-19 12:57:05 +02:00
Romain Porte
c4dd4f2960 Added ImageWidthError and its implementation (#226)
* Added ImageWidthError and its implementation

* Added unit tests for ImageWidthError

* Parse max_width to int before compare
2017-05-23 15:13:28 +02:00
Romain Porte
22cf6ad00b Allow users to change impl for soft_barcode 2017-05-22 20:21:35 +02:00
TAHRI Ahmed
1f427953a8 Preliminary support of pos 'line display' printing 2017-05-22 00:40:40 +02:00
Romain Porte
a6e1d0df00 Using booleans for handling text size 2017-05-21 22:50:07 +02:00
Romain Porte
c0b4d03692 Updated documentation of set method 2017-05-21 22:50:07 +02:00