This is the Adafruit thermal printer, whose Arduino library is published here: http://www.ladyada.net/products/thermalprinter/. This is a basic port to mbed that needs proper testing. The first printBitmap function is implemented but not fully tested, the stream versions are not ported yet.

Dependents:   SMS_LEDMatrixPrinter

Fork of AdafruitThermalPrinter by Ashley Mills

Committer:
ashleymills
Date:
Fri Jun 29 08:42:23 2012 +0000
Revision:
1:315c49946ded
Parent:
0:c4a48036e46f
Child:
2:6c38e763c285
Initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 0:c4a48036e46f 1 /***************************************************
ashleymills 0:c4a48036e46f 2 This is a library for the Adafruit Thermal Printer
ashleymills 0:c4a48036e46f 3
ashleymills 0:c4a48036e46f 4 Pick one up at --> http://www.adafruit.com/products/597
ashleymills 0:c4a48036e46f 5 These printers use TTL serial to communicate, 2 pins are required
ashleymills 0:c4a48036e46f 6
ashleymills 0:c4a48036e46f 7 Adafruit invests time and resources providing this open source code,
ashleymills 0:c4a48036e46f 8 please support Adafruit and open-source hardware by purchasing
ashleymills 0:c4a48036e46f 9 products from Adafruit!
ashleymills 0:c4a48036e46f 10
ashleymills 0:c4a48036e46f 11 Written by Limor Fried/Ladyada for Adafruit Industries.
ashleymills 0:c4a48036e46f 12 MIT license, all text above must be included in any redistribution
ashleymills 0:c4a48036e46f 13 ****************************************************/
ashleymills 0:c4a48036e46f 14
ashleymills 1:315c49946ded 15 /** Ported hastily to mbed by Ashley Mills - NOTE: printBitmap not ported, nothing tested **/
ashleymills 0:c4a48036e46f 16
ashleymills 0:c4a48036e46f 17 #pragma once
ashleymills 0:c4a48036e46f 18
ashleymills 0:c4a48036e46f 19 #include "mbed.h"
ashleymills 0:c4a48036e46f 20
ashleymills 0:c4a48036e46f 21 #define UPC_A 0
ashleymills 0:c4a48036e46f 22 #define UPC_E 1
ashleymills 0:c4a48036e46f 23 #define EAN13 2
ashleymills 0:c4a48036e46f 24 #define EAN8 3
ashleymills 0:c4a48036e46f 25 #define CODE39 4
ashleymills 0:c4a48036e46f 26 #define I25 5
ashleymills 0:c4a48036e46f 27 #define CODEBAR 6
ashleymills 0:c4a48036e46f 28 #define CODE93 7
ashleymills 0:c4a48036e46f 29 #define CODE128 8
ashleymills 0:c4a48036e46f 30 #define CODE11 9
ashleymills 0:c4a48036e46f 31 #define MSI 10
ashleymills 0:c4a48036e46f 32
ashleymills 0:c4a48036e46f 33
ashleymills 0:c4a48036e46f 34 #define PRINTER_PRINT(a) _printer->putc(a);
ashleymills 0:c4a48036e46f 35 #define delay(a) wait(a/1000)
ashleymills 0:c4a48036e46f 36
ashleymills 0:c4a48036e46f 37
ashleymills 0:c4a48036e46f 38
ashleymills 0:c4a48036e46f 39 class AdafruitThermal {
ashleymills 0:c4a48036e46f 40 public:
ashleymills 0:c4a48036e46f 41
ashleymills 0:c4a48036e46f 42 AdafruitThermal(PinName RX_Pin, PinName TX_Pin); // constructor
ashleymills 0:c4a48036e46f 43 void begin(int heatTime=255);
ashleymills 0:c4a48036e46f 44 void reset();
ashleymills 0:c4a48036e46f 45 void setDefault();
ashleymills 0:c4a48036e46f 46 void test();
ashleymills 0:c4a48036e46f 47 void testPage();
ashleymills 0:c4a48036e46f 48
ashleymills 0:c4a48036e46f 49 size_t write(uint8_t c);
ashleymills 0:c4a48036e46f 50
ashleymills 0:c4a48036e46f 51
ashleymills 0:c4a48036e46f 52 void normal();
ashleymills 0:c4a48036e46f 53 void inverseOn();
ashleymills 0:c4a48036e46f 54 void inverseOff();
ashleymills 0:c4a48036e46f 55 void upsideDownOn();
ashleymills 0:c4a48036e46f 56 void upsideDownOff();
ashleymills 0:c4a48036e46f 57 void doubleHeightOn();
ashleymills 0:c4a48036e46f 58 void doubleHeightOff();
ashleymills 0:c4a48036e46f 59 void doubleWidthOn();
ashleymills 0:c4a48036e46f 60 void doubleWidthOff();
ashleymills 0:c4a48036e46f 61 void boldOn();
ashleymills 0:c4a48036e46f 62 void boldOff();
ashleymills 0:c4a48036e46f 63 void underlineOn(uint8_t weight=1);
ashleymills 0:c4a48036e46f 64 void underlineOff();
ashleymills 0:c4a48036e46f 65 void strikeOn();
ashleymills 0:c4a48036e46f 66 void strikeOff();
ashleymills 0:c4a48036e46f 67
ashleymills 0:c4a48036e46f 68 void justify(char value);
ashleymills 0:c4a48036e46f 69 void feed(uint8_t x = 1);
ashleymills 0:c4a48036e46f 70 void feedRows(uint8_t);
ashleymills 0:c4a48036e46f 71 void flush();
ashleymills 0:c4a48036e46f 72 void online();
ashleymills 0:c4a48036e46f 73 void offline();
ashleymills 0:c4a48036e46f 74 void sleep();
ashleymills 0:c4a48036e46f 75 void sleepAfter(uint8_t seconds);
ashleymills 0:c4a48036e46f 76 void wake();
ashleymills 0:c4a48036e46f 77 void print(char *string);
ashleymills 0:c4a48036e46f 78
ashleymills 0:c4a48036e46f 79 void setCharSpacing(int spacing);
ashleymills 0:c4a48036e46f 80 void setSize(char value);
ashleymills 0:c4a48036e46f 81 void setLineHeight(int val = 32);
ashleymills 0:c4a48036e46f 82
ashleymills 0:c4a48036e46f 83 void printBarcode(char * text, uint8_t type);
ashleymills 0:c4a48036e46f 84 void setBarcodeHeight(int val);
ashleymills 0:c4a48036e46f 85
ashleymills 1:315c49946ded 86 // not ported
ashleymills 1:315c49946ded 87 //void printBitmap(int w, int h, const uint8_t *bitmap);
ashleymills 1:315c49946ded 88 //void printBitmap(int w, int h, Stream *stream);
ashleymills 1:315c49946ded 89 //void printBitmap(Stream *stream);
ashleymills 0:c4a48036e46f 90
ashleymills 0:c4a48036e46f 91 // ??
ashleymills 0:c4a48036e46f 92 void tab();
ashleymills 0:c4a48036e46f 93
ashleymills 0:c4a48036e46f 94 protected:
ashleymills 0:c4a48036e46f 95 Serial * _printer;
ashleymills 0:c4a48036e46f 96 bool linefeedneeded;
ashleymills 0:c4a48036e46f 97
ashleymills 0:c4a48036e46f 98 // little helpers to make code easier to read&use
ashleymills 0:c4a48036e46f 99 void writeBytes(uint8_t a);
ashleymills 0:c4a48036e46f 100 void writeBytes(uint8_t a, uint8_t b);
ashleymills 0:c4a48036e46f 101 void writeBytes(uint8_t a, uint8_t b, uint8_t c);
ashleymills 0:c4a48036e46f 102 void writeBytes(uint8_t a, uint8_t b, uint8_t c, uint8_t d);
ashleymills 0:c4a48036e46f 103
ashleymills 0:c4a48036e46f 104 int printMode;
ashleymills 0:c4a48036e46f 105 void writePrintMode();
ashleymills 0:c4a48036e46f 106 void setPrintMode(uint8_t mask);
ashleymills 0:c4a48036e46f 107 void unsetPrintMode(uint8_t mask);
ashleymills 0:c4a48036e46f 108
ashleymills 0:c4a48036e46f 109 PinName _RX_Pin;
ashleymills 0:c4a48036e46f 110 PinName _TX_Pin;
ashleymills 0:c4a48036e46f 111 };