Skip to content
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
8 changes: 4 additions & 4 deletions NiimPrintX/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion NiimPrintX/nimmy/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
27 changes: 22 additions & 5 deletions NiimPrintX/ui/AppConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -44,15 +57,19 @@ def __init__(self):
"75mm x 12mm": (75, 12),
"109mm x 12.5mm": (109, 12.5),
},
"density": 3
"density": 3,
"print_dpi": 203

},
"b18": {
"size": {
"40mm x 14mm": (40, 14),
"50mm x 14mm": (50, 14),
"120mm x 14mm": (120, 14),
},
"density": 3
"density": 3,
"print_dpi": 203

}
}
self.current_label_size = None
Expand Down
3 changes: 2 additions & 1 deletion NiimPrintX/ui/widget/CanvasSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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"])
2 changes: 1 addition & 1 deletion NiimPrintX/ui/widget/PrintOption.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down