mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-05-13 15:22:56 +00:00
Fix chain print support for the D460BT family (thanks to Guilherme Espada)
This commit is contained in:
parent
b904e22cf1
commit
9a0ef8c7d6
@ -109,6 +109,7 @@ int ptouch_finalize(ptouch_dev ptdev, int chain);
|
|||||||
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_send_d460bt_magic(ptouch_dev ptdev);
|
int ptouch_send_d460bt_magic(ptouch_dev ptdev);
|
||||||
|
int ptouch_send_d460bt_chain(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_info_cmd(ptouch_dev ptdev, int size_x);
|
||||||
int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut);
|
int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut);
|
||||||
|
@ -195,6 +195,14 @@ int ptouch_init(ptouch_dev ptdev)
|
|||||||
return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd));
|
return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sends some magic commands to enable chaining on the PT-D460BT.
|
||||||
|
These should go out right before magic commands. */
|
||||||
|
int ptouch_send_d460bt_chain(ptouch_dev ptdev)
|
||||||
|
{
|
||||||
|
uint8_t cmd[] = "\x1b\x69\x4b\x00";
|
||||||
|
return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
/* Sends some magic commands to make prints work on the PT-D460BT.
|
/* Sends some magic commands to make prints work on the PT-D460BT.
|
||||||
These should go out after info_cmd and right before the raster data. */
|
These should go out after info_cmd and right before the raster data. */
|
||||||
int ptouch_send_d460bt_magic(ptouch_dev ptdev)
|
int ptouch_send_d460bt_magic(ptouch_dev ptdev)
|
||||||
@ -286,7 +294,8 @@ int ptouch_finalize(ptouch_dev ptdev, int chain)
|
|||||||
char cmd_eject[]="\x1a"; /* Print command with feeding */
|
char cmd_eject[]="\x1a"; /* Print command with feeding */
|
||||||
char cmd_chain[]="\x0c"; /* Print command (no cut) */
|
char cmd_chain[]="\x0c"; /* Print command (no cut) */
|
||||||
|
|
||||||
char *cmd = chain ? cmd_chain : cmd_eject;
|
// The D460BT devices use a leading packet to indicate chaining instead.
|
||||||
|
char *cmd = (chain && (!(ptdev->devinfo->flags & FLAG_D460BT_MAGIC))) ? cmd_chain : cmd_eject;
|
||||||
return ptouch_send(ptdev, (uint8_t *)cmd, 1);
|
return ptouch_send(ptdev, (uint8_t *)cmd, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel);
|
|||||||
int get_baselineoffset(char *text, char *font, int fsz);
|
int get_baselineoffset(char *text, char *font, int fsz);
|
||||||
int find_fontsize(int want_px, char *font, char *text);
|
int find_fontsize(int want_px, char *font, char *text);
|
||||||
int needed_width(char *text, char *font, int fsz);
|
int needed_width(char *text, char *font, int fsz);
|
||||||
int print_img(ptouch_dev ptdev, gdImage *im);
|
int print_img(ptouch_dev ptdev, gdImage *im, int chain);
|
||||||
int write_png(gdImage *im, const char *file);
|
int write_png(gdImage *im, const char *file);
|
||||||
gdImage *img_append(gdImage *in_1, gdImage *in_2);
|
gdImage *img_append(gdImage *in_1, gdImage *in_2);
|
||||||
gdImage *img_cutmark(int tape_width);
|
gdImage *img_cutmark(int tape_width);
|
||||||
@ -74,7 +74,7 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int print_img(ptouch_dev ptdev, gdImage *im)
|
int print_img(ptouch_dev ptdev, gdImage *im, int chain)
|
||||||
{
|
{
|
||||||
int d,i,k,offset,tape_width;
|
int d,i,k,offset,tape_width;
|
||||||
uint8_t rasterline[(ptdev->devinfo->max_px)/8];
|
uint8_t rasterline[(ptdev->devinfo->max_px)/8];
|
||||||
@ -112,6 +112,12 @@ int print_img(ptouch_dev ptdev, gdImage *im)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) {
|
if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) {
|
||||||
|
if (chain) {
|
||||||
|
ptouch_send_d460bt_chain(ptdev);
|
||||||
|
if (debug) {
|
||||||
|
printf(_("send PT-D460BT chain commands\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
ptouch_send_d460bt_magic(ptdev);
|
ptouch_send_d460bt_magic(ptdev);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf(_("send PT-D460BT magic commands\n"));
|
printf(_("send PT-D460BT magic commands\n"));
|
||||||
@ -631,7 +637,7 @@ int main(int argc, char *argv[])
|
|||||||
if (save_png) {
|
if (save_png) {
|
||||||
write_png(out, save_png);
|
write_png(out, save_png);
|
||||||
} else {
|
} else {
|
||||||
print_img(ptdev, out);
|
print_img(ptdev, out, chain);
|
||||||
if (ptouch_finalize(ptdev, chain) != 0) {
|
if (ptouch_finalize(ptdev, chain) != 0) {
|
||||||
printf(_("ptouch_finalize(%d) failed\n"), chain);
|
printf(_("ptouch_finalize(%d) failed\n"), chain);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user