Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for printers with TSPL protocol #73

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

thefelixno
Copy link

Added support for TSPL protocol.

Allows printing to TSC-based printers including the majority of cheap generic thermal label printers, for usually less than 100€ (e.g. TSC, Yinleader, Vretti, Vevor, Phomemo, …)

Features:

  • tested and working over Bluetooth and USB
  • applies floyd-steinberg-dithering on the android device, because TSPL printers only support threshold-dithering.
  • supports different page sensors: gap, black mark or continuous

Seeking help and opinion:

  • The default page size is that of KLT-labels (Kleinlastenträger). We use them, because they're cheap and so are we. Anyone who uses these printers probably is, too. I'm open to changing it to default ticket sizes.
  • The settings might be too powerful and confuse users. Please remove any options you consider too much (except the print height, which is required)
  • The settings fragment has many duplicate calls to view.findById. For the sake of consistency with other modules, I did not DRY them.
  • Might work over LAN, but I don't have a testing device with ethernet/wifi. I excluded ethernet for now.
  • Although it works great, I marked it as experimental. I think anyone who's afraid of that, probably shouldn't use such cheap printers anyways ...

This is my first pull request, so please forgive any foolish mistakes. I'm open to feedback, roasting and rejection.

@raphaelm
Copy link
Member

Oh wow, nice work! We'll look into this in detail in the next weeks, please have a little patience :) As we don't have a TSPL printer, we will probably need to mark the integration as "experimental" to clarify that we cannot provide support on it to our customers.

Implementing Floyd-Steinberg in the pretixPRINT layer is something we deliberately not do in the other protocols because in our experience it is a quite significant performance difference, but it's also not something I'd have too much trouble with for this one, it just feels a little inconsistent.

@thefelixno
Copy link
Author

Thanks!

I understand, that dithering in pretixPRINT feels wrong and admittedly is a bit slow on the older devices I tested (sunmi v2 pro).
Initially I wanted to use the library provided by TSC. That would have produced much cleaner code, similar to the other protocols. Unfortunately it is really bad in performance (uses like five loops, where I used one).

So yeah, it was a tradeoff in favor of performance. These printers just can't dither, the protocol explicitly only accepts binary bitmap data. (pg 43: https://shop.mediaform.de/media/wysiwyg/downloads/armilla/TSC_TSPL_TSPL2_Programming.pdf)

What do you think about putting dithering as an option into the settings? Defaulting to the much quicker threshold-dithering.

Let me know when you get a chance to have a look at it. I appreciate your feedback and am in no hurry, so take your time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants