Skip to content
Draft
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
3 changes: 2 additions & 1 deletion src/labelle/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
SUPPORTED_PRODUCTS = {
0x0011: "DYMO LabelMANAGER PC",
0x0015: "LabelPoint 350",
0x0016: f"Rhino 6000+ {UNCONFIRMED_MESSAGE}",
0x1001: "LabelManager PnP (no mode switch)",
0x1002: "LabelManager PnP (mode switch)",
0x1003: f"LabelManager 420P (no mode switch) {UNCONFIRMED_MESSAGE}",
Expand All @@ -52,7 +53,7 @@
PRINTER_INTERFACE_CLASS = 0x07
HID_INTERFACE_CLASS = 0x03

# Escape character preceeding all commands
# Escape character preceding all commands
ESC = 0x1B

# Synchronization character preceding uncompressed print data
Expand Down
13 changes: 11 additions & 2 deletions src/labelle/lib/devices/dymo_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class DymoLabeler:

LABELER_DISTANCE_BETWEEN_PRINT_HEAD_AND_CUTTER_MM = 8.1
LABELER_PRINT_HEAD_HEIGHT_MM = 8.2
SUPPORTED_TAPE_SIZES_MM = (19, 12, 9, 6)
SUPPORTED_TAPE_SIZES_MM = (24, 19, 12, 9, 6)
DEFAULT_TAPE_SIZE_MM = 12

def __init__(
Expand Down Expand Up @@ -313,10 +313,19 @@ def print(
The label bitmap is a PIL image in 1-bit format (mode=1), and pixels with value
equal to 1 are burned.
"""

def mirror_byte(byte):
mirrored = 0
for i in range(8):
mirrored = (mirrored << 1) | (byte & 1) # Shift mirrored left and add LSB of byte
byte >>= 1 # Shift byte right
return mirrored

# Convert the image to the proper matrix for the dymo labeler object so that
# rows span the width of the label, and the first row corresponds to the left
# edge of the label.
rotated_bitmap = bitmap.transpose(Image.Transpose.ROTATE_270)
rotated_bitmap = rotated_bitmap.transpose(Image.Transpose.FLIP_LEFT_RIGHT)

# Convert the image to raw bytes. Pixels along rows are chunked into groups of
# 8 pixels, and subsequent rows are concatenated.
Expand All @@ -330,7 +339,7 @@ def print(
"label bitmap!"
)
label_rows: list[bytes] = [
stream[i : i + stream_row_length]
bytes(mirror_byte(b) for b in stream[i: i + stream_row_length])
for i in range(0, len(stream), stream_row_length)
]

Expand Down
Loading