Changes

Sticker printer

1,431 bytes added, 10:27, 4 February 2016
Added file generation and printing methods
Print all the things!
Using the thermal sticker printer (located on the wooden crate across from tron shelf with the coffee machine next to the elevatorsfridge), you can print all sorts of fun things, notably QR codes (with links to stuff, text, phone numbers, btc addresses,...). The printer is a [http://support.brother.com/g/b/producttop.aspx?c=gb&lang=en&prod=lpql700euk Brother QL-700], a 300dpi b/w thermal (no ink) sticker/label printer that is connected via the Pi used for the [[doorbell]].
== Features ==
=== QR codes ===
Printing QR codes is quite easy, all you need to do is to type in your URLs or text go to the URL that's on the giant screen behind sticker on the printer, and you can print directly URLs or text. For vcards, btc addresses, and other 'fancy' QR codes, you will need to write in the syntax yourself (e.g. <code>bitcoin:161s5cgPRMvyVNaCu3zcgXxVeKpUTXGIOU</code>). After you click the print button, it will take 3make sure that the printer is on, then expect to wait 8~5 15 seconds for the QR code to generate, spool, and print. The auto-cut functionality is disabled (otherwise all the stickers would fall into the void), so you need to push the cut button to get the sticker from the printer. You are encouraged to use these stickers responsibly (for example, shalf doesn't like when a qr code with 'penis' is stuck on his macbook charger).
The interface is written in html + php + pythonbash (meh), and currently generates fetches the QR codes using [[QR_codes#QR_from_stdin | pythonfrom Google's qrcode library]], and then resizes them to max size (720x720px - somewhere bigger than that the printer crashes) using the imaging library. It then prints directly to the printer device file using a depreciated QR code generating [https://githubchart.googleapis.com/sudomeshchart?cht=qr&chs=300x300&chl=text service]. It then spools it with <code>lp</ql570 reverse engineered program] code>, which is significantly faster than prints it over CUPS. Whereas in the first iteration (generating QR codes using Google's API + spooling and printing over CUPS) took 15-20 seconds per sticker, the current version takes 3-5 seconds and As soon as I can be optimized figure out how to print almost instantly properly formatted pages with a bit of hacking. If someone wants to write an app js in C that generates them, the right kind of QR code and then prints it with the ql570 printer libraryservice will likely be migrated locally, please feel free to do so!  possibly even using things like [http://bitcoinqrcode.org/ this] for bitcoins. Other future feature ideas include: detailed print status, advanced QR code generation (vcard, sms, geolocation, calendar, wifi,...), QR code settings, or even your suggestions.
=== Text ===
Prints in a monospaced font, 24 columns, no margins. A bit ugly, but there isn't an easy way to change the print settings. What I'm trying to do right now is to figure out how to print a properly formatted page, and if that's possible, then printing text or other fancy elements would be easier.
 
Take [https://www.youtube.com/watch?v=hr42JjCRM-0 snapshots of pages] using [http://phantomjs.org/ phantomjs] - this allows you to take care of formatting with css and html instead of magic
=== Images ===
[[File:Bitcoin_stamp.png|300px]][[File:Fixme_stamp.png|300px]]
 
 
== Printing methods ==
=== Serial print ===
Prints PNG files *instantly*. Can print various formats of labels, but has very strict sizing limits (printer crashes and must be physically powered off) which require image pre-processing. Uses (ql570)[https://github.com/sudomesh/ql570] library. You must have write permissions to the right /dev/usb or something like that.
 
=== CUPS print ===
Prints anything, but is a pain to set up and insecure. Also takes quite a long time to spool the file (5-10 seconds), can be a bit confusing to orient/scale document correctly.
 
== File generation methods ==
=== Phantomjs ===
Works great and reduces hassle of generating images (you just take a screenshot of any page), however takes ~4 seconds to launch browser. Screenshotting and all other things take less than a second. Potential solutions:
* Generate all pngs on first run or have a button to generate them
* Keep phantomjs running and pass it items (can this be done?)
* Upgrade to RPi2
 
=== QRencode + PIL ===
Works but takes ~5 seconds, closer to ~8s on cold run. PIL takes the longest to resize the image. A solution could be to figure out which pixel size to define for qrencode.
 
=== Google Chart API ===
Took ~20 seconds in total with CUPS printing and the requests. Also loss of privacy.
 
=== Client side generation (future) ===
Generate the image in client's browser and POST it to the printer. Haven't tried it yet.
== Resources ==
Then print with <code>lp -d Brother_QL-700 file.jpg</code>. Use <code>-o media=Custom.62x13mm</code> for custom size (theoretically unlimited length, but do note that the roll costs ~18 chf).
<s>Challenge: disable standby/find a way to wake form standby</s> use the brother utility on a windows or mac to disable this
http://download.brother.com/welcome/docp000675/ql700_ukeng_usr_b.pdf
462
edits