1
0
mirror of https://git.familie-radermacher.ch/linux/ptouch-print.git synced 2025-05-13 15:22:56 +00:00

bugfix for PT D-450 - thanks to Nicklas Björk

This commit is contained in:
Dominic Radermacher 2021-08-29 21:32:04 +02:00
parent 97657da3f4
commit 4a79cdf1b1
3 changed files with 30 additions and 1 deletions

View File

@ -31,6 +31,7 @@ struct _pt_tape_info {
#define FLAG_RASTER_PACKBITS (1 << 1) #define FLAG_RASTER_PACKBITS (1 << 1)
#define FLAG_PLITE (1 << 2) #define FLAG_PLITE (1 << 2)
#define FLAG_P700_INIT (1 << 3) #define FLAG_P700_INIT (1 << 3)
#define FLAG_USE_INFO_CMD (1 << 4)
typedef enum _pt_page_flags { typedef enum _pt_page_flags {
FEED_NONE = 0x0, FEED_NONE = 0x0,
@ -102,6 +103,7 @@ int ptouch_eject(ptouch_dev ptdev);
int ptouch_getstatus(ptouch_dev ptdev); int ptouch_getstatus(ptouch_dev ptdev);
int ptouch_getmaxwidth(ptouch_dev ptdev); int ptouch_getmaxwidth(ptouch_dev ptdev);
int ptouch_enable_packbits(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_rasterstart(ptouch_dev ptdev);
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len); int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len);
void ptouch_list_supported(); void ptouch_list_supported();

View File

@ -69,7 +69,7 @@ struct _pt_dev_info ptdevs[] = {
{0x04f9, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, {0x04f9, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT},
{0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE},
{0x04f9, 0x2065, "PT-P750W (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 */ /* Notes about the PT-D450: I'm unsure if print width really is 128px */
{0x04f9, 0x2074, "PT-D600", 128, 180, FLAG_RASTER_PACKBITS}, {0x04f9, 0x2074, "PT-D600", 128, 180, FLAG_RASTER_PACKBITS},
/* PT-D600 was reported to work, but with some quirks (premature /* 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)); 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) int ptouch_rasterstart(ptouch_dev ptdev)
{ {
/* 1B 69 52 01 = Select graphics transfer mode = Raster */ /* 1B 69 52 01 = Select graphics transfer mode = Raster */

View File

@ -97,6 +97,12 @@ int print_img(ptouch_dev ptdev, gdImage *im)
printf(_("ptouch_rasterstart() failed\n")); printf(_("ptouch_rasterstart() failed\n"));
return -1; 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<gdImageSX(im); k+=1) { for (k=0; k<gdImageSX(im); k+=1) {
memset(rasterline, 0, sizeof(rasterline)); memset(rasterline, 0, sizeof(rasterline));
for (i=0; i<gdImageSY(im); i+=1) { for (i=0; i<gdImageSY(im); i+=1) {