luopio / py-thermal-printer Goto Github PK
View Code? Open in Web Editor NEWPython library to control mini thermal printers connected to devices like the BeagleBone
Python library to control mini thermal printers connected to devices like the BeagleBone
Hi,
I'm generating qrcodes to be used with the thermal printer using the qrcode library (https://pypi.python.org/pypi/qrcode). The codes generate fine (I can see them on the file system and scan them from my phone) however when I try and print them using the barcode call, the first couple of rows of the image get chopped off giving me an invalid barcode.
The code is as follows:
#!/usr/bin/env python
import printer
import qrcode
from qrcode.image.pure import PymagingImage
p = printer.ThermalPrinter(serialport="/dev/ttyAMA0")
qr = qrcode.QRCode(
version=None,
error_correction=qrcode.constants.ERROR_CORRECT_M
)
qr.add_data('TEST')
qr.make(fit=True)
im = qr.make_image()
w, h = im.size
data = list(im.getdata())
p.linefeed()
p.linefeed()
p.print_text("TEST")
p.linefeed()
p.linefeed()
p.print_bitmap(data,w,h,True)
p.linefeed()
p.linefeed()
p.linefeed()
p.linefeed()
If anyone can shed light on why I'm missing some of the QRcode that would be great!
Cheers,
Matt
P.S. FWIW, Text prints fine :)
Hi,
This is not working with the new raspbian version (2016-05-10).
I had to install back the 2016-03-18-raspbian version to be able to print the example.
I'm using a raspberry pi v2.
Regards,
Renaud.
I believe this printer is capable of cutting paper, but the function is not implemented... have you ever try that?
I am using your library to print photos but the print-output is somehow disappointing because the contrast is too high. I put an example below.
I tried to tune the black_threshold and alpha_threshold but it did not quite resolve my problem. What I would like is to get the same rendering as with the LittlePrinter project http://littleprinter.com/ (see the picture printed at the end of the video).
I will investigate the problem, but if you have ideas on where to start, I would appreciate.
The readme file doesn't say whether this will work okay with ubuntu or another x86 linux. Is there any reason why it would not work if you have an available serial port? I briefly looked through the code and didn't see any obvious reasons. Are there? I would just like to know before I go and purchase an appropriate printer.
hey, it's possible to set different encoding? My printer is printing chinese chars by default.
thanks
Hi,
Can you use this script with a networked printer?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.