Toyomasa Watarai
/
AS-289R2_Hello-World
AS-289R2 library test code for mbed 2 (classic)
main.cpp@8:daab85e207b5, 2017-02-03 (annotated)
- Committer:
- MACRUM
- Date:
- Fri Feb 03 10:08:03 2017 +0000
- Revision:
- 8:daab85e207b5
- Parent:
- 5:53deb3bfdd08
Update library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 2:89363d1cba42 | 1 | /* AS289R2 library test program |
MACRUM | 5:53deb3bfdd08 | 2 | * Copyright (c) 2016, Toyomasa Watarai |
MACRUM | 2:89363d1cba42 | 3 | * |
MACRUM | 2:89363d1cba42 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
MACRUM | 2:89363d1cba42 | 5 | * of this software and associated documentation files (the "Software"), to deal |
MACRUM | 2:89363d1cba42 | 6 | * in the Software without restriction, including without limitation the rights |
MACRUM | 2:89363d1cba42 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
MACRUM | 2:89363d1cba42 | 8 | * copies of the Software, and to permit persons to whom the Software is |
MACRUM | 2:89363d1cba42 | 9 | * furnished to do so, subject to the following conditions: |
MACRUM | 2:89363d1cba42 | 10 | * |
MACRUM | 2:89363d1cba42 | 11 | * The above copyright notice and this permission notice shall be included in |
MACRUM | 2:89363d1cba42 | 12 | * all copies or substantial portions of the Software. |
MACRUM | 2:89363d1cba42 | 13 | * |
MACRUM | 2:89363d1cba42 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
MACRUM | 2:89363d1cba42 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
MACRUM | 2:89363d1cba42 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
MACRUM | 2:89363d1cba42 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
MACRUM | 2:89363d1cba42 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
MACRUM | 2:89363d1cba42 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
MACRUM | 2:89363d1cba42 | 20 | * THE SOFTWARE. |
MACRUM | 2:89363d1cba42 | 21 | */ |
MACRUM | 0:c407b8539f80 | 22 | #include "mbed.h" |
MACRUM | 2:89363d1cba42 | 23 | #include "AS289R2.h" |
MACRUM | 1:3a6d4c7a3a73 | 24 | |
MACRUM | 2:89363d1cba42 | 25 | Serial pc(USBTX, USBRX); |
MACRUM | 2:89363d1cba42 | 26 | AS289R2 tp(D1); |
MACRUM | 1:3a6d4c7a3a73 | 27 | |
MACRUM | 5:53deb3bfdd08 | 28 | const char url[] = "https://developer.mbed.org/components/AS-289R2-Thermal-Printer-Shield/"; |
MACRUM | 5:53deb3bfdd08 | 29 | |
MACRUM | 0:c407b8539f80 | 30 | int main() |
MACRUM | 0:c407b8539f80 | 31 | { |
MACRUM | 2:89363d1cba42 | 32 | tp.initialize(); |
MACRUM | 2:89363d1cba42 | 33 | tp.putLineFeed(2); |
MACRUM | 2:89363d1cba42 | 34 | |
MACRUM | 2:89363d1cba42 | 35 | tp.printf("** Thermal Printer Shield **\r\r"); |
MACRUM | 2:89363d1cba42 | 36 | |
MACRUM | 2:89363d1cba42 | 37 | tp.setDoubleSizeWidth(); |
MACRUM | 2:89363d1cba42 | 38 | tp.printf(" AS-289R2\r\r"); |
MACRUM | 2:89363d1cba42 | 39 | tp.clearDoubleSizeWidth(); |
MACRUM | 0:c407b8539f80 | 40 | |
MACRUM | 2:89363d1cba42 | 41 | tp.printf("日本語文字列の印字テスト:24x24\r"); |
MACRUM | 2:89363d1cba42 | 42 | tp.setKanjiFont(AS289R2::KANJI_16x16); |
MACRUM | 2:89363d1cba42 | 43 | tp.setANKFont(AS289R2::ANK_8x16); |
MACRUM | 2:89363d1cba42 | 44 | tp.printf("日本語文字列の印字テスト:16x16\r\r"); |
MACRUM | 2:89363d1cba42 | 45 | |
MACRUM | 2:89363d1cba42 | 46 | tp.setKanjiFont(AS289R2::KANJI_DEFAULT); |
MACRUM | 2:89363d1cba42 | 47 | tp.setANKFont(AS289R2::ANK_DEFAULT); |
MACRUM | 2:89363d1cba42 | 48 | tp.setDoubleSizeWidth(); |
MACRUM | 2:89363d1cba42 | 49 | tp.printf("ABCDEFG 0123456789\r"); |
MACRUM | 2:89363d1cba42 | 50 | tp.clearDoubleSizeWidth(); |
MACRUM | 2:89363d1cba42 | 51 | |
MACRUM | 2:89363d1cba42 | 52 | tp.setDoubleSizeHeight(); |
MACRUM | 2:89363d1cba42 | 53 | tp.printf("ABCDEFG 0123456789\r"); |
MACRUM | 2:89363d1cba42 | 54 | tp.clearDoubleSizeHeight(); |
MACRUM | 2:89363d1cba42 | 55 | |
MACRUM | 2:89363d1cba42 | 56 | tp.putLineFeed(2); |
MACRUM | 0:c407b8539f80 | 57 | |
MACRUM | 2:89363d1cba42 | 58 | tp.setANKFont(AS289R2::ANK_8x16); |
MACRUM | 2:89363d1cba42 | 59 | tp.printf("8x16: Test 012345 アイウエオ\r\r"); |
MACRUM | 2:89363d1cba42 | 60 | tp.setANKFont(AS289R2::ANK_12x24); |
MACRUM | 2:89363d1cba42 | 61 | tp.printf("12x24: Test 012345 アイウエオ\r\r"); |
MACRUM | 2:89363d1cba42 | 62 | tp.setANKFont(AS289R2::ANK_16x16); |
MACRUM | 2:89363d1cba42 | 63 | tp.printf("16x16: Test 012345 アイウエオ\r\r"); |
MACRUM | 2:89363d1cba42 | 64 | tp.setANKFont(AS289R2::ANK_24x24); |
MACRUM | 2:89363d1cba42 | 65 | tp.printf("24x24: Test 012345 アイウエオ\r\r"); |
MACRUM | 2:89363d1cba42 | 66 | tp.putLineFeed(1); |
MACRUM | 0:c407b8539f80 | 67 | |
MACRUM | 2:89363d1cba42 | 68 | tp.setANKFont(AS289R2::ANK_8x16); |
MACRUM | 2:89363d1cba42 | 69 | tp.printf("QR\r"); |
MACRUM | 5:53deb3bfdd08 | 70 | tp.printQRCode(AS289R2::QR_ERR_LVL_M, url); |
MACRUM | 5:53deb3bfdd08 | 71 | tp.printf("\r%s\r", url); |
MACRUM | 2:89363d1cba42 | 72 | tp.putLineFeed(2); |
MACRUM | 2:89363d1cba42 | 73 | |
MACRUM | 2:89363d1cba42 | 74 | tp.printf("UPC-A\r"); |
MACRUM | 2:89363d1cba42 | 75 | tp.printBarCode(AS289R2::BCODE_UPC_A, "01234567890"); |
MACRUM | 2:89363d1cba42 | 76 | tp.putLineFeed(4); |
MACRUM | 0:c407b8539f80 | 77 | |
MACRUM | 2:89363d1cba42 | 78 | pc.printf("AS-289R2 thermal printer shield test\n\n"); |
MACRUM | 2:89363d1cba42 | 79 | while(1) { |
MACRUM | 2:89363d1cba42 | 80 | if (pc.readable()) { |
MACRUM | 2:89363d1cba42 | 81 | int c = pc.getc(); |
MACRUM | 2:89363d1cba42 | 82 | pc.putc(c); |
MACRUM | 2:89363d1cba42 | 83 | tp.putc(c); |
MACRUM | 2:89363d1cba42 | 84 | } |
MACRUM | 2:89363d1cba42 | 85 | } |
MACRUM | 2:89363d1cba42 | 86 | |
MACRUM | 0:c407b8539f80 | 87 | } |