1.1 --- a/src/main.c Sat Aug 01 12:41:12 2009 +0100 1.2 +++ b/src/main.c Sat Aug 01 12:42:34 2009 +0100 1.3 @@ -1,12 +1,49 @@ 1.4 +/************************** 1.5 + * P-Touch PT-2450DX printer driver 1.6 + * 1.7 + * P. Pemberton, 2009 1.8 + * 1.9 + * Specs: 1.10 + * Printer head is 128 dots, 180dpi, for a total print area of ~18mm vertical 1.11 + * by however long your TZ label tape is. 1.12 + * Printhead size is (128/180)=0.711[.] inches, or 18.0622[.] mm 1.13 + * Each dot is (18.062/128) = 0.1411[.] mm 1.14 + * Printable area is (numdots * 0.1411) mm 1.15 + * 1.16 + * Tape width Margins Printable area 1.17 + * mm dots mm dots mm dots 1.18 + * 6mm 42 1.0mm 7 4mm 28 1.19 + * 9mm 63 1.0mm 7 7mm 49 1.20 + * 12mm 85 2.0mm 14 8mm 57 1.21 + * 18mm 127 3.0mm 21 12mm 85 1.22 + * 24mm 170 3.0mm 128 18mm 128 *** 1.23 + * 1.24 + * 24mm is slightly odd. Because the printhead is only 128 dots (18mm), the 1.25 + * margins are enforced by this, and not the driver software. It is impossible 1.26 + * to print right to the edge of a 24mm label in a PT-2450DX. 1.27 + * 1.28 + **************************/ 1.29 + 1.30 #include <stdio.h> 1.31 #include <stdlib.h> 1.32 -#include "hexdump.h" 1.33 +#include "ptouch.h" 1.34 +#include "pt_image.h" 1.35 1.36 -#define ESC 0x1b 1.37 +/****************************************************************************/ 1.38 1.39 int main(int argc, char **argv) 1.40 { 1.41 - FILE *prn; 1.42 + pt_Device *dev; 1.43 + 1.44 + pt_Image *im; 1.45 + 1.46 + printf("create image\n"); 1.47 + im = ptimage_Create(123, 456); 1.48 + 1.49 + printf("delete image\n"); 1.50 + ptimage_Free(im); 1.51 + 1.52 + return 0; 1.53 1.54 // check command line args 1.55 if (argc < 2) { 1.56 @@ -14,34 +51,16 @@ 1.57 return -1; 1.58 } 1.59 1.60 - // open printer device 1.61 - if ((prn = fopen(argv[1], "r+b")) == NULL) { 1.62 - printf("ERROR: couldn't open printer device '%s'\n", argv[1]); 1.63 + // Open and initialise the printer 1.64 + dev = pt_Initialise(argv[1]); 1.65 + 1.66 + if (dev == NULL) { 1.67 + printf("Error opening printer device.\n"); 1.68 return -1; 1.69 } 1.70 1.71 - // INITIALISE 1.72 - fprintf(prn, "%c%c", ESC, '@'); 1.73 - 1.74 - // REQUEST STATUS 1.75 - fprintf(prn, "%c%c%c", ESC, 'i', 'S'); 1.76 + // Close the printer device 1.77 + pt_Close(dev); 1.78 1.79 - // Read status buffer from printer 1.80 - unsigned char buf[32]; 1.81 - int timeout = 128; 1.82 - do { 1.83 - fread(buf, 1, 32, prn); 1.84 - } while ((buf[0] != 0x80) && (timeout-- > 0)); 1.85 - 1.86 - if (timeout > 0) { 1.87 - printf("Printer status:\n"); 1.88 - hex_dump(buf, 32); 1.89 - } else { 1.90 - printf("TIMEOUT\n"); 1.91 - return -1; 1.92 - } 1.93 - 1.94 - // Close the printer stream 1.95 - fclose(prn); 1.96 return 0; 1.97 }