diff --git a/NiimPrintX/cli/command.py b/NiimPrintX/cli/command.py index f7b1090..af9e145 100644 --- a/NiimPrintX/cli/command.py +++ b/NiimPrintX/cli/command.py @@ -32,7 +32,7 @@ def niimbot_cli(ctx, verbose): @click.option( "-m", "--model", - type=click.Choice(["b1", "b18", "b21", "d11", "d110"], False), + type=click.Choice(["b1", "b18", "b21", "d11", "d11_h", "d110"], False), default="d110", show_default=True, help="Niimbot printer model", @@ -86,10 +86,10 @@ def print_command(model, density, rotate, image, quantity, vertical_offset, hori if model in ("b1", "b18", "b21"): max_width_px = 384 - if model in ("d11", "d110"): + if model in ("d11", "d11_h", "d110"): max_width_px = 240 - if model in ("b18", "d11", "d110") and density > 3: + if model in ("b18", "d11", "d11_h", "d110") and density > 3: density = 3 try: image = Image.open(image) @@ -123,7 +123,7 @@ async def _print(model, density, image, quantity, vertical_offset, horizontal_of @click.option( "-m", "--model", - type=click.Choice(["b1", "b18", "b21", "d11", "d110"], False), + type=click.Choice(["b1", "b18", "b21", "d11", "d11_h", "d110"], False), default="d110", show_default=True, help="Niimbot printer model", diff --git a/NiimPrintX/nimmy/printer.py b/NiimPrintX/nimmy/printer.py index 299de90..fa52095 100644 --- a/NiimPrintX/nimmy/printer.py +++ b/NiimPrintX/nimmy/printer.py @@ -294,7 +294,7 @@ async def set_quantity(self, n): async def get_print_status(self): packet = await self.send_command(RequestCodeEnum.GET_PRINT_STATUS, b"\x01") - page, progress1, progress2 = struct.unpack(">HBB", packet.data) + page, progress1, progress2 = struct.unpack(">HBB", packet.data[:4]) return {"page": page, "progress1": progress1, "progress2": progress2} def __del__(self): diff --git a/NiimPrintX/ui/AppConfig.py b/NiimPrintX/ui/AppConfig.py index fba35a1..fea3ad4 100644 --- a/NiimPrintX/ui/AppConfig.py +++ b/NiimPrintX/ui/AppConfig.py @@ -4,7 +4,6 @@ class AppConfig: def __init__(self): self.os_system = platform.system() - self.print_dpi = 203 # DPI value for printing self.screen_dpi = 72 self.text_items = {} self.image_items = {} @@ -24,7 +23,8 @@ def __init__(self): "75mm x 12mm": (75, 12), "109mm x 12.5mm": (109, 12.5), }, - "density": 3 + "density": 3, + "print_dpi": 203 }, "d11": { "size": { @@ -34,7 +34,20 @@ def __init__(self): "75mm x 12mm": (75, 12), "109mm x 12.5mm": (109, 12.5), }, - "density": 3 + "density": 3, + "print_dpi": 203 + + }, + "d11_h": { + "size": { + "30mm x 14mm": (30, 14), + "40mm x 12mm": (40, 12), + "50mm x 14mm": (50, 14), + "75mm x 12mm": (75, 12), + "109mm x 12.5mm": (109, 12.5), + }, + "density": 3, + "print_dpi": 300 }, "d101": { "size": { @@ -44,7 +57,9 @@ def __init__(self): "75mm x 12mm": (75, 12), "109mm x 12.5mm": (109, 12.5), }, - "density": 3 + "density": 3, + "print_dpi": 203 + }, "b18": { "size": { @@ -52,7 +67,9 @@ def __init__(self): "50mm x 14mm": (50, 14), "120mm x 14mm": (120, 14), }, - "density": 3 + "density": 3, + "print_dpi": 203 + } } self.current_label_size = None diff --git a/NiimPrintX/ui/widget/CanvasSelector.py b/NiimPrintX/ui/widget/CanvasSelector.py index ee3050c..82f62cf 100644 --- a/NiimPrintX/ui/widget/CanvasSelector.py +++ b/NiimPrintX/ui/widget/CanvasSelector.py @@ -46,6 +46,7 @@ def update_device_label_size(self, event=None): self.label_size_option.current(0) else: self.selected_label_size.set('') + self.update_canvas_size() def update_canvas_size(self, event=None): """Update the canvas size based on the selected label size.""" @@ -108,4 +109,4 @@ def update_canvas_size(self, event=None): def mm_to_pixels(self, mm): inches = mm / 25.4 - return int(inches * self.config.print_dpi) + return int(inches * self.config.label_sizes[self.config.device]["print_dpi"]) diff --git a/NiimPrintX/ui/widget/PrintOption.py b/NiimPrintX/ui/widget/PrintOption.py index 9778951..dcff833 100644 --- a/NiimPrintX/ui/widget/PrintOption.py +++ b/NiimPrintX/ui/widget/PrintOption.py @@ -111,7 +111,7 @@ def save_image(self): def mm_to_pixels(self, mm): inches = mm / 25.4 - return int(inches * self.config.print_dpi) + return int(inches * self.config.label_sizes[self.config.device]["print_dpi"]) def export_to_png(self, output_filename=None, horizontal_offset=0.0, vertical_offset=0.0): width = self.config.canvas.winfo_reqwidth() diff --git a/README.md b/README.md index 160a84e..9b84e64 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Commands: Usage: python -m NiimPrintX.cli print [OPTIONS] Options: - -m, --model [b1|b18|b21|d11|d110] + -m, --model [b1|b18|b21|d11|d11_h|d110] Niimbot printer model [default: d110] -d, --density INTEGER RANGE Print density [default: 3; 1<=x<=5] -n, --quantity INTEGER Print quantity [default: 1]