Added B18 support (#6)
* Adding B18 support * B18 work * Removed some debugging print * Update readme, remove extra example image * Add extra printer models & density check --------- Co-authored-by: AndBondStyle <[email protected]>
This commit is contained in:
co-authored by
AndBondStyle
parent
2199e65588
commit
14237a9d05
@@ -11,7 +11,7 @@ from niimprint import BluetoothTransport, PrinterClient, SerialTransport
|
||||
@click.option(
|
||||
"-m",
|
||||
"--model",
|
||||
type=click.Choice(["b1", "b21", "d11"], False),
|
||||
type=click.Choice(["b1", "b18", "b21", "d11", "d110"], False),
|
||||
default="b21",
|
||||
show_default=True,
|
||||
help="Niimbot printer model",
|
||||
@@ -73,11 +73,15 @@ def print_cmd(model, conn, addr, density, rotate, image, verbose):
|
||||
port = addr if addr is not None else "auto"
|
||||
transport = SerialTransport(port=port)
|
||||
|
||||
if model in ("b1", "b21"):
|
||||
if model in ("b1", "b18", "b21"):
|
||||
max_width_px = 384
|
||||
if model == "d11":
|
||||
if model in ("d11", "d110"):
|
||||
max_width_px = 96
|
||||
|
||||
if model in ("b18", "d11", "d110") and density > 3:
|
||||
logging.warning(f"{model.upper()} only supports density up to 3")
|
||||
density = 3
|
||||
|
||||
image = Image.open(image)
|
||||
if rotate != "0":
|
||||
# PIL library rotates counter clockwise, so we need to multiply by -1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**Fork changelog & differences from original version:**
|
||||
|
||||
- Tested on Niimbot B21 and Python 3.11. Niimbot D11 support may be broken!
|
||||
- Tested on Niimbot B1, B18, B21, D11, D110 and Python 3.11
|
||||
- Added transport abstraction: switch between bluetooth and USB (serial)
|
||||
- Disabled checksum calculation for image encoding (works fine without it so far)
|
||||
- Switched to [click](https://click.palletsprojects.com/) CLI library instead of argparse
|
||||
@@ -22,7 +22,7 @@ $ python niimprint --help
|
||||
Usage: niimprint [OPTIONS]
|
||||
|
||||
Options:
|
||||
-m, --model [b1|b21|d11] Niimbot printer model [default: b21]
|
||||
-m, --model [b1|b18|b21|d11|d110] Niimbot printer model [default: b21]
|
||||
-c, --conn [usb|bluetooth] Connection type [default: usb]
|
||||
-a, --addr TEXT Bluetooth MAC address OR serial device path
|
||||
-d, --density INTEGER RANGE Print density [default: 5; 1<=x<=5]
|
||||
@@ -44,7 +44,7 @@ Generally, the image comes out of the printer with the same orientation you see
|
||||
|
||||
As far as we've tested, Niimbot printers have **8 pixels per mm** (~203 dpi) resolution. The CLI prints the image you provided as-is, without any checks of the actual label size, so be careful. However the script will check if the image width is too big for selected printer. The maximum width in pixels is usually slightly less than specified maximum width in mm:
|
||||
|
||||
- **B21, B1**: max 384 pixels (almost equal to 50 mm * 8 px/mm = 400)
|
||||
- **B21, B1, B18**: max 384 pixels (almost equal to 50 mm * 8 px/mm = 400)
|
||||
- **D11**: max 96 pixels (almost equal to 15 mm * 8 px/mm = 120)
|
||||
|
||||
### USB connection:
|
||||
@@ -73,10 +73,6 @@ python niimprint -c bluetooth -a "E2:E1:08:03:09:87" -r 90 -i examples/B21_80x50
|
||||
|
||||
[]()
|
||||
|
||||
**D11**
|
||||
|
||||
Completly untested yet, however original fork supports it. If you have D11 at hand and willing to test, please open an issue!
|
||||
|
||||
## Licence
|
||||
|
||||
[MIT](https://choosealicense.com/licenses/mit/). Originally developed by [kjy00302](https://github.com/kjy00302), forked & enhanced by [AndBondStyle](https://github.com/AndBondStyle)
|
||||
|
||||
Reference in New Issue
Block a user