Thermal printer hello world program.
Dependencies: Adafruit_Thermal_Printer mbed
main.cpp@0:6325abe92741, 2016-03-16 (annotated)
- Committer:
- aross34
- Date:
- Wed Mar 16 01:43:45 2016 +0000
- Revision:
- 0:6325abe92741
- Child:
- 1:9ccf98857297
Hello world program for Adafruit thermal printer. Updated API documentation.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aross34 | 0:6325abe92741 | 1 | #include "mbed.h" |
aross34 | 0:6325abe92741 | 2 | #include "AdafruitThermal.h" |
aross34 | 0:6325abe92741 | 3 | |
aross34 | 0:6325abe92741 | 4 | DigitalOut myled(LED1); |
aross34 | 0:6325abe92741 | 5 | AdafruitThermal Printer(p9, p10); |
aross34 | 0:6325abe92741 | 6 | |
aross34 | 0:6325abe92741 | 7 | int main() { |
aross34 | 0:6325abe92741 | 8 | myled = 1; |
aross34 | 0:6325abe92741 | 9 | Printer.begin(); |
aross34 | 0:6325abe92741 | 10 | //Printer.test(); |
aross34 | 0:6325abe92741 | 11 | // **char *OutputText = "Better Work Dammit\n"; |
aross34 | 0:6325abe92741 | 12 | // **Printer.print(OutputText); |
aross34 | 0:6325abe92741 | 13 | |
aross34 | 0:6325abe92741 | 14 | char *Testing_Foo = "Hello World!\n"; |
aross34 | 0:6325abe92741 | 15 | Printer.print(Testing_Foo); |
aross34 | 0:6325abe92741 | 16 | |
aross34 | 0:6325abe92741 | 17 | Printer.justify('C'); |
aross34 | 0:6325abe92741 | 18 | char *Text_Out11 = "normal\nline\nspacing\n"; |
aross34 | 0:6325abe92741 | 19 | Printer.print(Text_Out11); |
aross34 | 0:6325abe92741 | 20 | Printer.setLineHeight(50); |
aross34 | 0:6325abe92741 | 21 | char *Text_Out12 = "Taller\nline\nspacing\n"; |
aross34 | 0:6325abe92741 | 22 | Printer.print(Text_Out12); |
aross34 | 0:6325abe92741 | 23 | Printer.setLineHeight(); // Reset to default |
aross34 | 0:6325abe92741 | 24 | Printer.justify('L'); |
aross34 | 0:6325abe92741 | 25 | |
aross34 | 0:6325abe92741 | 26 | Printer.setSize('L'); |
aross34 | 0:6325abe92741 | 27 | char *Text_Out8 = "Large\n"; |
aross34 | 0:6325abe92741 | 28 | Printer.print(Text_Out8); |
aross34 | 0:6325abe92741 | 29 | |
aross34 | 0:6325abe92741 | 30 | Printer.setSize('M'); |
aross34 | 0:6325abe92741 | 31 | char *Text_Out9 = "Medium\n"; |
aross34 | 0:6325abe92741 | 32 | Printer.print(Text_Out9); |
aross34 | 0:6325abe92741 | 33 | |
aross34 | 0:6325abe92741 | 34 | Printer.setSize('S'); |
aross34 | 0:6325abe92741 | 35 | char *Text_Out10 = "Small\n"; |
aross34 | 0:6325abe92741 | 36 | Printer.print(Text_Out10); |
aross34 | 0:6325abe92741 | 37 | |
aross34 | 0:6325abe92741 | 38 | Printer.inverseOn(); |
aross34 | 0:6325abe92741 | 39 | char *Text_Out1 = "Inverse ON\n"; |
aross34 | 0:6325abe92741 | 40 | Printer.print(Text_Out1); |
aross34 | 0:6325abe92741 | 41 | Printer.inverseOff(); |
aross34 | 0:6325abe92741 | 42 | |
aross34 | 0:6325abe92741 | 43 | Printer.doubleHeightOn(); |
aross34 | 0:6325abe92741 | 44 | char *Text_Out2 = "Double Height ON\n"; |
aross34 | 0:6325abe92741 | 45 | Printer.print(Text_Out2); |
aross34 | 0:6325abe92741 | 46 | Printer.doubleHeightOff(); |
aross34 | 0:6325abe92741 | 47 | |
aross34 | 0:6325abe92741 | 48 | Printer.justify('R'); |
aross34 | 0:6325abe92741 | 49 | char *Text_Out3 = "Right Justified\n"; |
aross34 | 0:6325abe92741 | 50 | Printer.print(Text_Out3); |
aross34 | 0:6325abe92741 | 51 | |
aross34 | 0:6325abe92741 | 52 | Printer.justify('C'); |
aross34 | 0:6325abe92741 | 53 | char *Text_Out4 = "Center Justified\n"; |
aross34 | 0:6325abe92741 | 54 | Printer.print(Text_Out4); |
aross34 | 0:6325abe92741 | 55 | |
aross34 | 0:6325abe92741 | 56 | Printer.justify('L'); |
aross34 | 0:6325abe92741 | 57 | char *Text_Out5 = "Left Justified\n"; |
aross34 | 0:6325abe92741 | 58 | Printer.print(Text_Out5); |
aross34 | 0:6325abe92741 | 59 | |
aross34 | 0:6325abe92741 | 60 | Printer.boldOn(); |
aross34 | 0:6325abe92741 | 61 | char *Text_Out6 = "Bold Text\n"; |
aross34 | 0:6325abe92741 | 62 | Printer.print(Text_Out6); |
aross34 | 0:6325abe92741 | 63 | Printer.boldOff(); |
aross34 | 0:6325abe92741 | 64 | |
aross34 | 0:6325abe92741 | 65 | myled = 0; |
aross34 | 0:6325abe92741 | 66 | |
aross34 | 0:6325abe92741 | 67 | |
aross34 | 0:6325abe92741 | 68 | } |