diff --git a/include/ptouch.h b/include/ptouch.h index bf8fcd6..63376ca 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -1,17 +1,17 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - + Copyright (C) 2015-2019 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -23,19 +23,21 @@ struct _pt_tape_info { uint8_t mm; /* Tape width in mm */ uint8_t px; /* Printing area in px */ + double margins; /* default tape margins in mm */ }; -#define FLAG_NONE (0x00) -#define FLAG_UNSUP_RASTER (0x01) -#define FLAG_RASTER_PACKBITS (0x02) -#define FLAG_PLITE (0x04) -#define FLAG_P700_INIT (0x08) +#define FLAG_NONE (0) +#define FLAG_UNSUP_RASTER (1 << 0) +#define FLAG_RASTER_PACKBITS (1 << 1) +#define FLAG_PLITE (1 << 2) +#define FLAG_P700_INIT (1 << 3) struct _pt_dev_info { int vid; /* USB vendor ID */ int pid; /* USB product ID */ char *name; int max_px; /* Maximum pixel width that can be printed */ + int dpi; /* Dots per inch of the printhead */ int flags; }; typedef struct _pt_dev_info *pt_dev_info; @@ -73,7 +75,7 @@ struct _ptouch_dev { libusb_device_handle *h; pt_dev_info devinfo; pt_dev_stat status; - uint8_t tape_width_px; + uint16_t tape_width_px; }; typedef struct _ptouch_dev *ptouch_dev; @@ -83,6 +85,9 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len); int ptouch_init(ptouch_dev ptdev); int ptouch_lf(ptouch_dev ptdev); int ptouch_ff(ptouch_dev ptdev); +size_t ptouch_get_max_pixel_width(ptouch_dev ptdev); +int ptouch_get_tape_pixel_width(ptouch_dev ptdev); +int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); int ptouch_eject(ptouch_dev ptdev); int ptouch_getstatus(ptouch_dev ptdev); int ptouch_getmaxwidth(ptouch_dev ptdev); diff --git a/src/libptouch.c b/src/libptouch.c index d88fa03..c3cce9c 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -34,35 +34,36 @@ /* Print area width in 180 DPI pixels */ struct _pt_tape_info tape_info[]= { - { 6, 32}, /* 6 mm tape */ - { 9, 52}, /* 9 mm tape */ - {12, 76}, /* 12 mm tape */ - {18, 120}, /* 18 mm tape */ - {24, 128}, /* 24 mm tape */ - {36, 192}, /* 36 mm tape */ - { 0, 0} /* terminating entry */ + { 6, 32, 1.0}, /* 6 mm tape */ + { 9, 52, 1.0}, /* 9 mm tape */ + {12, 76, 2.0}, /* 12 mm tape */ + {18, 120, 3.0}, /* 18 mm tape */ + {24, 128, 3.0}, /* 24 mm tape */ + {36, 192, 4.5}, /* 36 mm tape */ + { 0, 0, 0.0} /* terminating entry */ }; struct _pt_dev_info ptdevs[] = { - {0x04f9, 0x2007, "PT-2420PC", 128, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */ - {0x04f9, 0x202c, "PT-1230PC", 128, FLAG_NONE}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ + {0x04f9, 0x2007, "PT-2420PC", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */ + {0x04f9, 0x202c, "PT-1230PC", 128, 180, FLAG_NONE}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ /* Notes about the PT-1230PC: While it is true that this printer supports max 12mm tapes, it apparently expects > 76px data - the first 32px must be blank. */ - {0x04f9, 0x202d, "PT-2430PC", 128, FLAG_NONE}, /* 180dpi, maximum 128px */ - {0x04f9, 0x2030, "PT-1230PC (PLite Mode)", 128, FLAG_PLITE}, - {0x04f9, 0x2031, "PT-2430PC (PLite Mode)", 128, FLAG_PLITE}, - {0x04f9, 0x2041, "PT-2730", 128, FLAG_NONE}, /* 180dpi, maximum 128px, max tape width 24mm - reported to work with some quirks */ + {0x04f9, 0x202d, "PT-2430PC", 128, 180, FLAG_NONE}, /* 180dpi, maximum 128px */ + {0x04f9, 0x2030, "PT-1230PC (PLite Mode)", 128, 180, FLAG_PLITE}, + {0x04f9, 0x2031, "PT-2430PC (PLite Mode)", 128, 180, FLAG_PLITE}, + {0x04f9, 0x2041, "PT-2730", 128, 180, FLAG_NONE}, /* 180dpi, maximum 128px, max tape width 24mm - reported to work with some quirks */ /* Notes about the PT-2730: was reported to need 48px whitespace within png-images before content is actually printed - can not check this */ - {0x04f9, 0x205f, "PT-E500", 128, FLAG_RASTER_PACKBITS}, + {0x04f9, 0x205f, "PT-E500", 128, 180, FLAG_RASTER_PACKBITS}, /* Note about the PT-E500: was reported by Jesse Becker with the remark that it also needs some padding (white pixels) */ - {0x04f9, 0x2061, "PT-P700", 128, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, - {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, FLAG_PLITE}, - {0x04f9, 0x2073, "PT-D450", 128, FLAG_RASTER_PACKBITS}, + {0x04f9, 0x2061, "PT-P700", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, + {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, + {0x04f9, 0x2073, "PT-D450", 128, 180, FLAG_RASTER_PACKBITS}, /* Notes about the PT-D450: I'm unsure if print width really is 128px */ - {0,0,"",0,0} + //{0x04f9, 0x200d, "PT-3600", 384, 360, FLAG_RASTER_PACKBITS}, + {0,0,"",0,0,0} }; void ptouch_rawstatus(uint8_t raw[32]); @@ -133,6 +134,7 @@ int ptouch_open(ptouch_dev *ptdev) return -1; } (*ptdev)->h=handle; + (*ptdev)->devinfo->dpi=ptdevs[k].dpi; (*ptdev)->devinfo->max_px=ptdevs[k].max_px; (*ptdev)->devinfo->flags=ptdevs[k].flags; return 0;