1
0
mirror of https://git.familie-radermacher.ch/linux/ptouch-print.git synced 2025-11-21 04:42:04 +00:00

Add chain mode and set precut flag for PT-2700

This commit is contained in:
Kevin Thibedeau
2024-06-10 16:54:07 +02:00
committed by Dominic Radermacher
parent a51fcf98f8
commit da9ed2600a
6 changed files with 286 additions and 168 deletions

View File

@@ -48,7 +48,7 @@ struct _pt_dev_info ptdevs[] = {
{0x04f9, 0x2007, "PT-2420PC", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */
{0x04f9, 0x2011, "PT-2450PC", 128, 180, FLAG_RASTER_PACKBITS},
{0x04f9, 0x2019, "PT-1950", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */
{0x04f9, 0x201f, "PT-2700", 128, 180, FLAG_NONE},
{0x04f9, 0x201f, "PT-2700", 128, 180, FLAG_HAS_PRECUT},
{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
@@ -280,13 +280,17 @@ int ptouch_ff(ptouch_dev ptdev)
return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd));
}
/* print and cut tape */
int ptouch_eject(ptouch_dev ptdev)
/* finish print and either cut or leave tape in machine */
int ptouch_finalize(ptouch_dev ptdev, int chain)
{
char cmd[]="\x1a";
return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd));
char cmd_eject[]="\x1a"; /* Print command with feeding */
char cmd_chain[]="\x0c"; /* Print command (no cut) */
char *cmd = chain ? cmd_chain : cmd_eject;
return ptouch_send(ptdev, (uint8_t *)cmd, 1);
}
void ptouch_rawstatus(uint8_t raw[32])
{
fprintf(stderr, _("debug: dumping raw status bytes\n"));

View File

@@ -57,6 +57,7 @@ char *save_png=NULL;
int verbose=0;
int fontsize=0;
bool debug=false;
bool chain=false;
/* --------------------------------------------------------------------
-------------------------------------------------------------------- */
@@ -428,6 +429,7 @@ void usage(char *progname)
printf("\t\t\t\tIf the text contains spaces, use quotation marks\n\t\t\t\taround it.\n");
printf("\t--cutmark\t\tPrint a mark where the tape should be cut\n");
printf("\t--pad <n>\t\tAdd n pixels padding (blank tape)\n");
printf("\t--chain\t\t\tSkip final feed of label and any automatic cut\n");
printf("other commands:\n");
printf("\t--version\t\tshow version info (required for bug report)\n");
printf("\t--info\t\t\tshow info about detected tape\n");
@@ -464,6 +466,8 @@ int parse_args(int argc, char **argv)
}
} else if (strcmp(&argv[i][1], "-cutmark") == 0) {
continue; /* not done here */
} else if (strcmp(&argv[i][1], "-chain") == 0) {
chain=true;
} else if (strcmp(&argv[i][1], "-debug") == 0) {
debug=true;
} else if (strcmp(&argv[i][1], "-info") == 0) {
@@ -595,6 +599,8 @@ int main(int argc, char *argv[])
out=img_append(out, im);
gdImageDestroy(im);
im = NULL;
} else if (strcmp(&argv[i][1], "-chain") == 0) {
chain = true;
} else if (strcmp(&argv[i][1], "-debug") == 0) {
debug = true;
} else {
@@ -606,8 +612,8 @@ int main(int argc, char *argv[])
write_png(out, save_png);
} else {
print_img(ptdev, out);
if (ptouch_eject(ptdev) != 0) {
printf(_("ptouch_eject() failed\n"));
if (ptouch_finalize(ptdev, chain) != 0) {
printf(_("ptouch_finalize(%d) failed\n"), chain);
return -1;
}
}