From 08a67f7b5a21298c11213328838f13c6696f8a40 Mon Sep 17 00:00:00 2001 From: NaitLee Date: Sun, 2 Apr 2023 21:58:23 +0800 Subject: [PATCH] =?UTF-8?q?Workaround=20paper=20feeding=20for=20MX05/MX06;?= =?UTF-8?q?=20Better=20Models=20code,=20categorized;=20Follow=20up=20newer?= =?UTF-8?q?=20Bleak,=20handle=20=E2=80=9Cno=20powered=20Bluetooth=20adapte?= =?UTF-8?q?rs=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO | 9 ++++----- dev-diary.txt | 8 ++++++++ printer.py | 6 +++++- printer_lib/models.py | 34 +++++++++++++++++++--------------- www/main.js | 1 + 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index f9736b0..165b1ff 100644 --- a/TODO +++ b/TODO @@ -7,17 +7,16 @@ Note: not ordered. do whatever I/you want + Make error notice short while let users see detailed help/manual for what-to-do + Even better CUPS/IPP support + Even better frontend, language-friendly text printing -+ Tcl/Tk frontend. More in dev-diary.txt, July 7th. -+ Make a build guide for android: - Summary the hacks to p4a, bleak p4a recipe, p4a webview bootstrap, and AdvancedWebView ++ Tcl/Tk frontend. More in dev-diary.txt, July 7th 2022. + Try to implement enough without more dependencies + More funny "languages" (now there's lolcat; I think the next is 文言) + Arch Linux package / AUR, package for other distros + Service for other init systems (a systemd unit file is there) + ... -? Optimize PF2 text printing? It seems a bit slow (in bit processing). -? Use something else as server part of backend? This can boost things up, and build some (essential) image manipulation in, quicker. And strip some way-too-big Python libs away (for smaller Windows/Android dist). +? Optimize PF2 text printing? It seems a bit slow (in bit processing) +? Fix feeding command for MX05/MX06 +? Use something else as server part of backend? This can boost things up, and build some (essential) image manipulation in, quicker. And strip some way-too-big Python libs away (for smaller Windows/Android dist) ? Built-in PostScript (Even if very basic) ? Data compression for GB03 alike. Optional ? Plugin, for including community features (that involves usefulness but also bloatness) diff --git a/dev-diary.txt b/dev-diary.txt index ad97ae1..1bc6f23 100644 --- a/dev-diary.txt +++ b/dev-diary.txt @@ -196,3 +196,11 @@ But hey, in this rewrite some algorithm practial overhead was removed, thus much In main.js the event handler was reworked too. No more double event dispatches. Thanks to this, another image processing performance problem is fixed. + +YEAR 2023 + +APRIL + +2nd + +Anniversary days to Cat-Printer! Thank all of you! Keep it up! diff --git a/printer.py b/printer.py index 5fd517e..08eb97c 100644 --- a/printer.py +++ b/printer.py @@ -462,7 +462,11 @@ class PrinterDriver(Commander): def _finish(self): self.end_lattice() self.set_speed(8) - self.feed_paper(128) + if self.model.problem_feeding: + for _ in range(128): + self.draw_bitmap(bytes(self.model.paper_width // 8)) + else: + self.feed_paper(128) self.get_device_state() self.flush() diff --git a/printer_lib/models.py b/printer_lib/models.py index c825b77..a181a7f 100644 --- a/printer_lib/models.py +++ b/printer_lib/models.py @@ -8,20 +8,24 @@ License CC0-1.0-only: https://directory.fsf.org/wiki/License:CC0 class Model(): ''' A printer model `paper_width`: pixels per line for the model/paper - `is_new`: some models can use compressed data. the algorithm isn't implemented in Cat-Printer yet, but should be no harm. + `is_new_kind`: some models have new "start print" command and can understand compressed data. + the algorithm isn't implemented in Cat-Printer yet, but this should be no harm. + `problem_feeding`: didn't yet figure out MX05/MX06 bad behavior giving feed command, use workaround for them ''' - paper_width: int - is_new_kind: bool - def __init__(self, width, is_new): - self.paper_width = width - self.is_new_kind = is_new + paper_width: int = 384 + is_new_kind: bool = False + problem_feeding: bool = False -Models = { - 'YT01': Model(384, False), - 'MX05': Model(384, False), - 'MX06': Model(384, False), - 'GB01': Model(384, False), - 'GB02': Model(384, False), - 'GB03': Model(384, True), - 'GT01': Model(384, False), -} +Models = {} + +# all known supported models +for name in 'GB01 GB02 GB03 GT01 MX05 MX06 YT01'.split(' '): + Models[name] = Model() + +# that can receive compressed data +for name in 'GB03'.split(' '): + Models[name].is_new_kind = True + +# that have problem giving feed command +for name in 'MX05 MX06'.split(' '): + Models[name].problem_feeding = True diff --git a/www/main.js b/www/main.js index 6dda0d6..2bcde0c 100644 --- a/www/main.js +++ b/www/main.js @@ -924,6 +924,7 @@ class Main { error_details.name === 'org.freedesktop.DBus.Error.UnknownObject' || error_details.name === 'org.bluez.Error.NotReady' || error_details.details.includes('not turned on') || + error_details.details.includes('No powered Bluetooth adapter') || error_details.details.includes('WinError -2147020577') ) Notice.warn('please-enable-bluetooth'); else if (