Mon, 03 Aug 2009 23:41:04 +0100
added dep/*.d and obj/*.o to hgignore
1 /****************************************************************************
2 * Project: P-touch printer driver library
3 * Developer: Philip Pemberton
4 * Purpose: Make Brother P-touch (PT-series) printers do something besides
5 * gather dust.
6 *
7 * Currently supports:
8 * PT-2450DX
9 ****************************************************************************/
11 #ifndef PTOUCH_H
12 #define PTOUCH_H
14 #include <gd.h>
16 /**
17 * @brief Device information structure
18 *
19 * This is used to store the state of the printer as of the last call to
20 * pt_GetStatus(), the current job settings, and other details required
21 * by the printer driver.
22 */
23 typedef struct {
24 /// Reference to the printer device
25 FILE *fp;
26 /// Error information
27 int errorInfo[2];
28 /// Label width, type and length
29 int mediaWidth, mediaType, mediaLength;
30 /// Label width in pixels
31 int pixelWidth;
32 /// Status type, phase type, and phase number
33 int statusType, phaseType, phaseHi, phaseLo;
34 /// Notification number
35 int notification;
37 /// Print parameter: autocutter enable
38 int autocut;
39 /// Print parameter: mirror printing enable
40 int mirror;
41 /// Print parameter: half-cut enable
42 /// Print parameter: chainprint enable
43 /// Print parameter: label end cut
44 } pt_Device;
46 /*
47 * Function return codes
48 */
49 enum {
50 /// Operation completed successfully
51 PT_ERR_SUCCESS = 0,
53 /// Data transfer timed out
54 PT_ERR_TIMEOUT = -1,
56 /// Invalid parameter
57 PT_ERR_BAD_PARAMETER = -2,
59 /// Label image is too large for this label tape
60 PT_ERR_LABEL_TOO_WIDE = -3,
62 /// Printer is not ready
63 PT_ERR_PRINTER_NOT_READY = -4
64 };
67 /**
68 * @brief Initialise the printer
69 *
70 * Initialises the printer and returns a pointer to a pt_Device struct
71 * describing it.
72 *
73 * @param path Path to the printer device file (e.g. /dev/usb/lp0)
74 * @return On success, a pt_Device struct referring to the printer.
75 * On failure, NULL.
76 */
77 pt_Device *pt_Initialise(char *path);
79 /**
80 * @brief Close a printer device
81 *
82 * Closes the connection to the printer, and destroys the pt_Device struct.
83 *
84 * @param dev A pt_Device struct created by pt_Initialise.
85 */
86 void pt_Close(pt_Device *dev);
88 /**
89 * @brief Get the current status of the printer
90 *
91 * Queries the printer for its current status, then returns the result.
92 *
93 * @param dev A pt_Device struct created by pt_Initialise.
94 * @return Any valid PT_ERR_* constant. The pt_Device struct passed in
95 * is also updated with the current status of the printer.
96 */
97 int pt_GetStatus(pt_Device *dev);
99 /**
100 * @brief Print one or more labels
101 *
102 * Takes a pointer to an array of Libgd images, and prints each of them.
103 *
104 * @param dev A pt_Device struct created by pt_Initialise.
105 * @param labels A pointer to an array of gdImagePtr objects containing
106 * the labels to be printed.
107 * @param count The number of labels to be printed.
108 * @return Any valid PT_ERR_* constant.
109 */
110 int pt_Print(pt_Device *dev, gdImagePtr *labels, int count);
112 #endif // PTOUCH_H