diff --git a/brother_ql/models.py b/brother_ql/models.py index dd28c93..173aa59 100644 --- a/brother_ql/models.py +++ b/brother_ql/models.py @@ -35,6 +35,8 @@ class Model(object): #: Support for two color printing (black/red/white) #: available only on some newer models. two_color = attrib(type=bool, default=False) + #: Number of NULL bytes needed for the invalidate command. + num_invalidate_bytes = attrib(type=int, default=200) @property def name(self): @@ -50,9 +52,9 @@ def name(self): Model('QL-700', (150, 11811), compression=False, mode_setting=False), Model('QL-710W', (150, 11811)), Model('QL-720NW', (150, 11811)), - Model('QL-800', (150, 11811), two_color=True, compression=False), - Model('QL-810W', (150, 11811), two_color=True), - Model('QL-820NWB',(150, 11811), two_color=True), + Model('QL-800', (150, 11811), two_color=True, compression=False, num_invalidate_bytes=400), + Model('QL-810W', (150, 11811), two_color=True, num_invalidate_bytes=400), + Model('QL-820NWB',(150, 11811), two_color=True, num_invalidate_bytes=400), Model('QL-1050', (295, 35433), number_bytes_per_row=162, additional_offset_r=44), Model('QL-1060N', (295, 35433), number_bytes_per_row=162, additional_offset_r=44), Model('PT-P750W', (31, 14172), number_bytes_per_row=16), diff --git a/brother_ql/raster.py b/brother_ql/raster.py index 08db4d5..23ca405 100644 --- a/brother_ql/raster.py +++ b/brother_ql/raster.py @@ -16,6 +16,7 @@ from PIL import Image import io +from brother_ql.models import ModelsManager from .devicedependent import models, \ min_max_feed, \ min_max_length_dots, \ @@ -65,6 +66,12 @@ def __init__(self, model='QL-500'): self._compression = False self.exception_on_warning = False + self.num_invalidate_bytes = 200 + for m in ModelsManager().iter_elements(): + if self.model == m.identifier: + self.num_invalidate_bytes = m.num_invalidate_bytes + break + def _warn(self, problem, kind=BrotherQLRasterError): """ Logs the warning message `problem` or raises a @@ -114,7 +121,7 @@ def add_switch_mode(self): def add_invalidate(self): """ clear command buffer """ - self.data += b'\x00' * 200 + self.data += b'\x00' * self.num_invalidate_bytes @property def mtype(self): return self._mtype