src/ptouch.h

Mon, 03 Aug 2009 23:39:53 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Mon, 03 Aug 2009 23:39:53 +0100
changeset 10
604c205d9163
parent 9
ebce4a7615e9
child 14
088286f9e1e4
permissions
-rw-r--r--

add basic test routine for Ptouch library

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