Sticker printer

From Fixme.ch
Jump to: navigation, search

Print all the things!

Using the thermal sticker printer (located on the shelf with the coffee machine next to the fridge), you can print all sorts of fun things, notably QR codes (with links to stuff, text, phone numbers, btc addresses,...). The printer is a 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 go to the URL that's on the 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. bitcoin:161s5cgPRMvyVNaCu3zcgXxVeKpUTXGIOU). After you click the print button, make sure that the printer is on, then expect to wait 8~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 + bash (meh), and currently fetches the QR codes from Google's depreciated QR code generating service. It then spools it with lp, which prints it over CUPS. As soon as I can figure out how to print properly formatted pages with js in them, the service will likely be migrated locally, possibly even using things like 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 snapshots of pages using phantomjs - this allows you to take care of formatting with css and html instead of magic

Images

Supports printing images, but this feature is deactivated currently due to security considerations. Although it appears to print in greyscale, this scale isn't too large - so low contrast/dark pictures won't print well. Lots of fun things can be done with images:

Bitcoin wallets

In development. Uses electrum to generate new wallets, and then generates QR codes for the public and the private keys. If there is no activity with the wallet after 6 months, the bitcoins will be taken back to avoid loss.

Post stamps

Buy post stamps via webstamp with bitcoins and then print them out.

Bitcoin stamp.pngFixme stamp.png


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)[1] 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

   wget http://download.brother.com/welcome/dlfp002192/ql700lpr-1.0.1-1.i386.deb
   sudo dpkg -i --force-all ql700lpr-1.0.1-1.i386.deb
   sudo apt-get install cups
   sudo usermod -a -G lpadmin pi
   sudo nano /etc/cups/cupsd.conf   // I don't actually remember what I did here
   sudo service cups restart

Then print with lp -d Brother_QL-700 file.jpg. Use -o media=Custom.62x13mm for custom size (theoretically unlimited length, but do note that the roll costs ~18 chf).

Challenge: disable standby/find a way to wake form standby

http://download.brother.com/welcome/docp000675/ql700_ukeng_usr_b.pdf