From 4d8bb9179fe44de4cd12ea6abafeb9ecc70ca547 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sat, 10 Dec 2016 09:57:33 +0100 Subject: [PATCH] added more devices, even though printing does NOT work with them --- include/ptouch.h | 2 ++ src/libptouch.c | 17 +++++++++++++++-- src/ptouch-print.c | 10 ++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/ptouch.h b/include/ptouch.h index 4be15aa..76ccd96 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -25,6 +25,8 @@ struct _pt_tape_info { uint8_t px; /* Printing area in px */ }; +#define FLAG_NONE 0 +#define FLAG_UNSUP_RASTER 1 struct _pt_dev_info { int vid; /* USB vendor ID */ int pid; /* USB product ID */ diff --git a/src/libptouch.c b/src/libptouch.c index c7949e5..f0f69f0 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -42,8 +42,13 @@ struct _pt_tape_info tape_info[6]= { }; struct _pt_dev_info ptdevs[] = { - {0x04f9, 0x202d, "PT-2430PC", 128, 0}, /* 180dpi, maximum 128px */ - {0x04f9, 0x202c, "PT-1230PC", 76, 0}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ + {0x04f9, 0x202d, "PT-2430PC", 128, FLAG_NONE}, /* 180dpi, maximum 128px */ + {0x04f9, 0x202c, "PT-1230PC", 76, FLAG_NONE}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ + {0x04f9, 0x2061, "PT-P700", 120, FLAG_UNSUP_RASTER}, /* DOES NOT WORK */ + {0x04f9, 0x2073, "PT-D450VP", 120, FLAG_UNSUP_RASTER}, /* DOES NOT WORK */ + /* Notes about the PT-D450VP: Tape detecting works, but printing does + not. The tape is just blank. I assume, the printer does not understand + the sent rasterdata. I'm also unsure about how many dots width we have */ {0,0,"",0,0} }; @@ -62,6 +67,10 @@ int ptouch_open(ptouch_dev *ptdev) fprintf(stderr, _("out of memory\n")); return -1; } + if (((*ptdev)->devinfo=malloc(sizeof(struct _pt_dev_info))) == NULL) { + fprintf(stderr, _("out of memory\n")); + return -1; + } if ((libusb_init(NULL)) < 0) { fprintf(stderr, _("libusb_init() failed\n")); return -1; @@ -97,6 +106,8 @@ int ptouch_open(ptouch_dev *ptdev) return -1; } (*ptdev)->h=handle; + (*ptdev)->devinfo->max_px=ptdevs[k].max_px; + (*ptdev)->devinfo->flags=ptdevs[k].flags; return 0; } } @@ -272,6 +283,8 @@ int ptouch_getstatus(ptouch_dev ptdev) int ptouch_getmaxwidth(ptouch_dev ptdev) { + /* TODO: should also check what the device supports. but I assume, + you can't use a large tape in a printe that doesn't support it anyways */ return ptdev->tape_width_px; } diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 890db4e..b2a08be 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -59,11 +59,21 @@ void rasterline_setpixel(uint8_t rasterline[16], int pixel) return; } +void unsupported_printer(ptouch_dev ptdev) +{ + printf(_("your printer unfortunately is not supported by this tool\n")); + printf(_("the rasterdata a transferred in some other (unknown) format\n")); + exit(1); +} + int print_img(ptouch_dev ptdev, gdImage *im) { int d,i,k,offset,tape_width; uint8_t rasterline[16]; + if ((ptdev->devinfo->flags & FLAG_UNSUP_RASTER) == FLAG_UNSUP_RASTER) { + unsupported_printer(ptdev); + } tape_width=ptouch_getmaxwidth(ptdev); /* find out whether color 0 or color 1 is darker */ d=(gdImageRed(im,1)+gdImageGreen(im,1)+gdImageBlue(im,1) < gdImageRed(im,0)+gdImageGreen(im,0)+gdImageBlue(im,0))?1:0; -- 2.39.5