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

Slow printing text #5

Closed
niktses opened this issue Mar 13, 2020 · 6 comments
Closed

Slow printing text #5

niktses opened this issue Mar 13, 2020 · 6 comments

Comments

@niktses
Copy link

niktses commented Mar 13, 2020

Resetting the image after every added text slows printing but changing the styling every time does not.
Removed reset() from here:
void textEncoded(
Uint8List textBytes, {
PosStyles styles = const PosStyles(),
int linesAfter = 0,
}) {
_text(textBytes, styles: styles);
// Ensure at least one line break after the text
emptyLines(linesAfter + 1);
reset();
}

and changed this:
bytes += styles.bold ? cBoldOn.codeUnits : [];
bytes += styles.turn90 ? cTurn90On.codeUnits : [];
bytes += styles.reverse ? cReverseOn.codeUnits : [];
bytes += styles.underline ? cUnderline1dot.codeUnits : [];
bytes += styles.fontType == PosFontType.fontB ? cFontB.codeUnits : [];
// Characters size
if (styles.height.value != PosTextSize.size1.value ||
styles.width.value != PosTextSize.size1.value) {
bytes += Uint8List.fromList(
List.from(cSizeGSn.codeUnits)
..add(PosTextSize.decSize(styles.height, styles.width)),
);
}

to this:
bytes += styles.bold ? cBoldOn.codeUnits : cBoldOff.codeUnits;
bytes += styles.turn90 ? cTurn90On.codeUnits : cTurn90Off.codeUnits;
bytes += styles.reverse ? cReverseOn.codeUnits : cReverseOff.codeUnits;
bytes += styles.underline ? cUnderline1dot.codeUnits : cUnderlineOff.codeUnits;
bytes += styles.fontType == PosFontType.fontB ? cFontB.codeUnits : cFontA.codeUnits;
// Characters size
bytes += Uint8List.fromList(
List.from(cSizeGSn.codeUnits)
..add(PosTextSize.decSize(styles.height, styles.width)),
);

and performance improvements were huge.
Consider testing this and if it works for you too consider changing it.

@andrey-ushakov
Copy link
Owner

Thank you for this!
It seems that it may explain this issue!

Actually, with my Xprinter XP-N160I I have no performance issues, that's why I haven't noticed this.
I will try to test soon and improve the library!

BTW, I'm not sure if you have mentioned it somewhere already, but what's your printer brand and model, please?

@niktses
Copy link
Author

niktses commented Mar 13, 2020

I'm using an Epson TM-T20ii-003. I also use a rongta rpp300 for its bluetooth but this one is pretty much garbage. Actually if you are interested the rongst has an issue that for some unknown to me reason exposes 2 bluetooth signals one of which does absolutely nothing and unfortunately this is the one your bluetooth library catches. The other one requires password so it probably affects it somehow. I fix this by bonding it beforehand and using this library as well "flutter_bluetooth_serial" to get the already bonded devices. The epson works fine. I have only tested in android so far.

@andrey-ushakov
Copy link
Owner

Resetting the image after every added text slows printing but changing the styling every time does not.

Unfortunately, changing the styling every time creates this issue (for some printers only): andrey-ushakov/esc_pos_bluetooth#1

However, it seems I've found a way how to avoid this. Could you please test the performance issue using your Epson TM-T20ii-003 and the latest library?

Here there is a good test: andrey-ushakov/esc_pos_printer#39 (comment)

Thanks!

@niktses
Copy link
Author

niktses commented Mar 16, 2020

In my case it works fine now.

@andrey-ushakov
Copy link
Owner

Ok! I'm closing this issue

@Fethi-Hamdani
Copy link

I'm having the same performance issue with an SPRT L31 printer, any help

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

No branches or pull requests

3 participants