python-escpos / python-escpos

Python library to manipulate ESC/POS printers
https://python-escpos.readthedocs.io
MIT License
1.01k stars 288 forks source link

Help adding a new Printer Brightek WH-U05 + reverted bits image printing #362

Open Sylvain303 opened 4 years ago

Sylvain303 commented 4 years ago

I have:

Feature description

I'm using a Kisok thermal printer Brightek WH-U05 I'm an ESC/POS newbie.

My printer seems to support some ESC/POS. I need to print QrCode on it, and I would like to add support for this printer to your code.

I tested the code from pip version v2.2.0 which wasn't working for my printer. I fixed the code for my problem and was finally able to print image and next QrCode.

Limitation for this Printer

After visually analyzing printed result it seems that the bit are send in the wrong order for this printer.

I coded a working version here:

https://github.com/Sylvain303/python-escpos/commit/37e99472b2a15ff2d68709ef986ab5ee785bbf82

Which can be tested:

cd example/
python3 image.py square_576x576_8pix_txt.png
# view intermediate result in output
xxd -b -s +8 -c 72  output  | less -S
# send to the printer
cat output > /dev/usb/lp0

results with a qrcode too:

Scan_ticket.pdf

Other print mode neither work: graphics, bitImageColumn (thought ESC * seems supported)

(this printer seems to also support ESC K bitmap Graphic print)

My question

I would like to add support for this printer.

It seems that reverted bits are not yet supported. I suppose that this feature should be added at Printer level (in my PoC I simply added at image() level). I would like to add new printer Capability (Limitation), are you agree with that? Could you point me how I should add this Capability? You may also suggest code improvement / testing.

Device info

Printer: Brightek WH-U05

Here follows the manual part which helped me the send the bits in the expected order:

manual_Brightek_WH-U05_Print_raster_GS_v_0

python-escpos version:

$ python-escpos version
3.0a7.dev6+g15dae8c.d20190923

python version:

$ python3 --version
Python 3.5.3

operating system:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.6 (stretch)
Release:    9.6
Codename:   stretch
patkan commented 4 years ago

Hi, thank you for your issue! Do you have to reverse the order of every sequence that is sent to the printer? if yes, you could try if you can just add this functionality to the _raw()-method. This could be set by the constructor of the escpos class.