diff --git a/include/ptouch.h b/include/ptouch.h index f32f358..b56a349 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -31,6 +31,7 @@ struct _pt_tape_info { #define FLAG_RASTER_PACKBITS (1 << 1) #define FLAG_PLITE (1 << 2) #define FLAG_P700_INIT (1 << 3) +#define FLAG_USE_INFO_CMD (1 << 4) typedef enum _pt_page_flags { FEED_NONE = 0x0, @@ -102,6 +103,7 @@ int ptouch_eject(ptouch_dev ptdev); int ptouch_getstatus(ptouch_dev ptdev); int ptouch_getmaxwidth(ptouch_dev ptdev); int ptouch_enable_packbits(ptouch_dev ptdev); +int ptouch_info_cmd(ptouch_dev ptdev, int size_x); int ptouch_rasterstart(ptouch_dev ptdev); int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len); void ptouch_list_supported(); diff --git a/src/libptouch.c b/src/libptouch.c index 440e195..1647628 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -69,7 +69,7 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, {0x04f9, 0x2065, "PT-P750W (PLite Mode)", 128, 180, FLAG_PLITE}, - {0x04f9, 0x2073, "PT-D450", 128, 180, FLAG_RASTER_PACKBITS}, + {0x04f9, 0x2073, "PT-D450", 128, 180, FLAG_USE_INFO_CMD}, /* Notes about the PT-D450: I'm unsure if print width really is 128px */ {0x04f9, 0x2074, "PT-D600", 128, 180, FLAG_RASTER_PACKBITS}, /* PT-D600 was reported to work, but with some quirks (premature @@ -196,6 +196,27 @@ int ptouch_enable_packbits(ptouch_dev ptdev) return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); } +/* print information command */ +int ptouch_info_cmd(ptouch_dev ptdev, int size_x) +{ + /* 1B 69 7A {n1} {n2} {n3} {n4} {n5} {n6} {n7} {n8} {n9} {n10} */ + uint8_t cmd[] = "\x1b\x69\x7a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + + /* {n3}: Media width (mm) + {n4}: Media length (mm) + For the media of width 24 mm, specify as n3 = 18h and n4 = 00h. + n4 is normally 00h, regardless of the paper length. */ + cmd[5] = ptdev->status->media_width; + + /* {n5} -{n8}: Raster number + n8*256*256*256 + n7*256*256 + n6*256 + n5 */ + cmd[7] = (uint8_t) size_x & 0xff; + cmd[8] = (uint8_t) (size_x >> 8) & 0xff; + cmd[9] = (uint8_t) (size_x >> 16) & 0xff; + cmd[10] = (uint8_t) (size_x >> 24) & 0xff; + return ptouch_send(ptdev, cmd, sizeof(cmd)-1); +} + int ptouch_rasterstart(ptouch_dev ptdev) { /* 1B 69 52 01 = Select graphics transfer mode = Raster */ diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 71b6eca..1e7ef5b 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -97,6 +97,12 @@ int print_img(ptouch_dev ptdev, gdImage *im) printf(_("ptouch_rasterstart() failed\n")); return -1; } + if ((ptdev->devinfo->flags & FLAG_USE_INFO_CMD) == FLAG_USE_INFO_CMD) { + ptouch_info_cmd(ptdev, gdImageSX(im)); + if (debug) { + printf(_("send print information command\n")); + } + } for (k=0; k