Skip to content

Commit

Permalink
Use 400 byte invalidate command for QL-8XX models.
Browse files Browse the repository at this point in the history
matmair#26

QL-800, QL-810W, and QL-820NWB need 400 byte long invalidate commands,
as seen on page 5 of the manual [1].

This PR specifically avoids the use of the deprecated devicedependent
module.

[1] https://download.brother.com/welcome/docp100278/cv_ql800_eng_raster_100.pdf

Co-authored-by: Kevin Ku <[email protected]>
  • Loading branch information
2 people authored and LunarEclipse363 committed Nov 12, 2023
1 parent 62f6045 commit f19ce79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions brother_ql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -51,9 +53,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('QL-1100', (301, 35434), number_bytes_per_row=162, additional_offset_r=44),
Expand Down
9 changes: 8 additions & 1 deletion brother_ql/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f19ce79

Please sign in to comment.