From 2353c629f4928f448ae0d51985c536376c485a16 Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Thu, 1 Oct 2020 15:08:27 +0800 Subject: [PATCH 1/7] Added pt12 label. Supports half_cut. Added definition of media types and extra error information. --- brother_ql/labels.py | 3 ++- brother_ql/raster.py | 15 ++++++++++++--- brother_ql/reader.py | 15 +++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/brother_ql/labels.py b/brother_ql/labels.py index 2becdd7..58635c8 100644 --- a/brother_ql/labels.py +++ b/brother_ql/labels.py @@ -104,7 +104,8 @@ def name(self): # type: str Label("d12", ( 12, 12), FormFactor.ROUND_DIE_CUT, ( 142, 142), ( 94, 94), 113 , feed_margin=35), Label("d24", ( 24, 24), FormFactor.ROUND_DIE_CUT, ( 284, 284), ( 236, 236), 42 ), Label("d58", ( 58, 58), FormFactor.ROUND_DIE_CUT, ( 688, 688), ( 618, 618), 51 ), - Label("pt24", ( 24, 0), FormFactor.PTOUCH_ENDLESS,( 128, 0), ( 128, 0), 0, feed_margin=14), + Label("pt12", ( 12, 0), FormFactor.PTOUCH_ENDLESS,( 84, 0), ( 83, 0), 23, feed_margin=14), + Label("pt24", ( 24, 0), FormFactor.PTOUCH_ENDLESS,( 168, 0), ( 128, 0), 0, feed_margin=14), ) class LabelsManager(ElementsManager): diff --git a/brother_ql/raster.py b/brother_ql/raster.py index 08db4d5..eb8e010 100644 --- a/brother_ql/raster.py +++ b/brother_ql/raster.py @@ -64,6 +64,9 @@ def __init__(self, model='QL-500'): self.two_color_printing = False self._compression = False self.exception_on_warning = False + self.half_cut = True + self.chain_printing = False + def _warn(self, problem, kind=BrotherQLRasterError): """ @@ -182,9 +185,15 @@ def add_expanded_mode(self): return self.data += b'\x1B\x69\x4B' # ESC i K flags = 0x00 - flags |= self.cut_at_end << 3 - flags |= self.dpi_600 << 6 - flags |= self.two_color_printing << 0 + if self.model.startswith('PT'): + flags |= self.half_cut << 2 + flags |= self.chain_printing << 3 + flags |= self.dpi_600 << 5 + else: + flags |= self.cut_at_end << 3 + flags |= self.dpi_600 << 6 + flags |= self.two_color_printing << 0 + self.data += bytes([flags]) def add_margins(self, dots=0x23): diff --git a/brother_ql/reader.py b/brother_ql/reader.py index b5d817d..031afb4 100755 --- a/brother_ql/reader.py +++ b/brother_ql/reader.py @@ -45,7 +45,7 @@ 0: 'No media when printing', 1: 'End of media (die-cut size only)', 2: 'Tape cutter jam', - 3: 'Not used', + 3: 'Weak batteries', 4: 'Main unit in use (QL-560/650TD/1050)', 5: 'Printer turned off', 6: 'High-voltage adapter (not used)', @@ -58,13 +58,16 @@ 2: 'Transmission / Communication error', 3: 'Communication buffer full error (not used)', 4: 'Cover opened while printing (Except QL-500)', - 5: 'Cancel key (not used)', + 5: 'Cancel key (not used) or Overheating error (PT-E550W/P750W/P710BT)', 6: 'Media cannot be fed (also when the media end is detected)', 7: 'System error', } RESP_MEDIA_TYPES = { 0x00: 'No media', + 0x01: 'Laminated tape', + 0x03: 'Non-laminated type', + 0x11: 'Heat-Shrink Tube', 0x0A: 'Continuous length tape', 0x0B: 'Die-cut labels', } @@ -73,6 +76,8 @@ 0x00: 'Reply to status request', 0x01: 'Printing completed', 0x02: 'Error occurred', + 0x03: 'Exit IF mode', + 0x04: 'Turned off', 0x05: 'Notification', 0x06: 'Phase change', } @@ -106,8 +111,10 @@ 'Phase number (high)', 'Phase number (low)', 'Notification number', - 'Reserved', - 'Reserved', + 'Expansion area', + 'Tape color information', + 'Text color information', + 'Hardware settings', ] def hex_format(data): From f6cfb6186a08529f206d87ed31093b24fc2f332f Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Thu, 1 Oct 2020 15:19:00 +0800 Subject: [PATCH 2/7] Added label 12+17. --- brother_ql/labels.py | 1 + 1 file changed, 1 insertion(+) diff --git a/brother_ql/labels.py b/brother_ql/labels.py index 58635c8..56fa99e 100644 --- a/brother_ql/labels.py +++ b/brother_ql/labels.py @@ -82,6 +82,7 @@ def name(self): # type: str ALL_LABELS = ( Label("12", ( 12, 0), FormFactor.ENDLESS, ( 142, 0), ( 106, 0), 29 , feed_margin=35), + Label("12+17", ( 12, 0), FormFactor.ENDLESS, ( 342, 0), ( 306, 0), 29 , feed_margin=35), Label("29", ( 29, 0), FormFactor.ENDLESS, ( 342, 0), ( 306, 0), 6 , feed_margin=35), Label("38", ( 38, 0), FormFactor.ENDLESS, ( 449, 0), ( 413, 0), 12 , feed_margin=35), Label("50", ( 50, 0), FormFactor.ENDLESS, ( 590, 0), ( 554, 0), 12 , feed_margin=35), From 88eb42188b34b4f53d74f341bddeaa5d93f72e16 Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Fri, 2 Oct 2020 00:00:13 +0800 Subject: [PATCH 3/7] s/chain_printing/no_chain_printing/ for clarity. --- brother_ql/raster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brother_ql/raster.py b/brother_ql/raster.py index eb8e010..0dc5262 100644 --- a/brother_ql/raster.py +++ b/brother_ql/raster.py @@ -65,7 +65,7 @@ def __init__(self, model='QL-500'): self._compression = False self.exception_on_warning = False self.half_cut = True - self.chain_printing = False + self.no_chain_printing = True def _warn(self, problem, kind=BrotherQLRasterError): @@ -187,7 +187,7 @@ def add_expanded_mode(self): flags = 0x00 if self.model.startswith('PT'): flags |= self.half_cut << 2 - flags |= self.chain_printing << 3 + flags |= self.no_chain_printing << 3 flags |= self.dpi_600 << 5 else: flags |= self.cut_at_end << 3 From 88107a09720a769cb7774ebfc840e646743d113f Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Fri, 2 Oct 2020 14:29:00 +0800 Subject: [PATCH 4/7] updated auto cut --- brother_ql/raster.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/brother_ql/raster.py b/brother_ql/raster.py index 0dc5262..7488456 100644 --- a/brother_ql/raster.py +++ b/brother_ql/raster.py @@ -167,7 +167,10 @@ def add_autocut(self, autocut = False): self._unsupported("Trying to call add_autocut with a printer that doesn't support it") return self.data += b'\x1B\x69\x4D' # ESC i M - self.data += bytes([autocut << 6]) + if self.model.startswith('PT'): + self.data += bytes([autocut << 5]) + else: + self.data += bytes([autocut << 6]) def add_cut_every(self, n=1): if self.model not in cuttingsupport: From 29fe1906ae08efa3c92a8837fb5d175241d54070 Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Fri, 2 Oct 2020 14:30:33 +0800 Subject: [PATCH 5/7] added array check for images --- brother_ql/brother_ql_create.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/brother_ql/brother_ql_create.py b/brother_ql/brother_ql_create.py index 7d19fc5..19ce057 100755 --- a/brother_ql/brother_ql_create.py +++ b/brother_ql/brother_ql_create.py @@ -51,7 +51,9 @@ def main(): args.outfile.write(qlr.data) def create_label(qlr, image, label_size, threshold=70, cut=True, dither=False, compress=False, red=False, **kwargs): - convert(qlr, [image], label_size, threshold=threshold, cut=cut, dither=dither, compress=compress, red=red, **kwargs) + if not isinstance(image, list): + image = [image] + convert(qlr, image, label_size, threshold=threshold, cut=cut, dither=dither, compress=compress, red=red, **kwargs) if __name__ == "__main__": main() From 582767e59292000ef759440fda3e3f5aa18a3cb0 Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Fri, 2 Oct 2020 14:55:24 +0800 Subject: [PATCH 6/7] Set no chain printing default to False, which mean chain printing. --- brother_ql/raster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brother_ql/raster.py b/brother_ql/raster.py index 7488456..02a7cb9 100644 --- a/brother_ql/raster.py +++ b/brother_ql/raster.py @@ -65,7 +65,7 @@ def __init__(self, model='QL-500'): self._compression = False self.exception_on_warning = False self.half_cut = True - self.no_chain_printing = True + self.no_chain_printing = False def _warn(self, problem, kind=BrotherQLRasterError): From 9c43c7510f1ea841b4d75d5288eee7376532f64a Mon Sep 17 00:00:00 2001 From: Yung-chung Lin Date: Fri, 2 Oct 2020 15:30:25 +0800 Subject: [PATCH 7/7] ignore cut every for model PT- --- brother_ql/raster.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/brother_ql/raster.py b/brother_ql/raster.py index 02a7cb9..b5b4ef7 100644 --- a/brother_ql/raster.py +++ b/brother_ql/raster.py @@ -176,6 +176,8 @@ def add_cut_every(self, n=1): if self.model not in cuttingsupport: self._unsupported("Trying to call add_cut_every with a printer that doesn't support it") return + if self.model.startswith('PT'): + return self.data += b'\x1B\x69\x41' # ESC i A self.data += bytes([n & 0xFF])