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

Added pt12 label. Supports half cut. #95

Open
wants to merge 7 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion brother_ql/brother_ql_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 3 additions & 1 deletion brother_ql/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -104,7 +105,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):
Expand Down
22 changes: 18 additions & 4 deletions brother_ql/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.no_chain_printing = False


def _warn(self, problem, kind=BrotherQLRasterError):
"""
Expand Down Expand Up @@ -164,12 +167,17 @@ 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:
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])

Expand All @@ -182,9 +190,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.no_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):
Expand Down
15 changes: 11 additions & 4 deletions brother_ql/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand All @@ -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',
}
Expand All @@ -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',
}
Expand Down Expand Up @@ -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):
Expand Down