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

Use 400 byte invalidate command for QL-8XX models. #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -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),
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