Please confirm the position of jumper(JP5)
AS-289R2 Thermal Printer Shield Library for Mbed
/* * Thermal Printer Shield for Mbed OS * Model:AS-289R2 * Sample Sourcecode * Library : https://developer.mbed.org/components/AS-289R2-Thermal-Printer-Shield/ * NADA ELECTRONICS, LTD. * http://www.nada.co.jp * By. Takehiro Yamaguchi */ #include "mbed.h" #include "AS289R2.h" DigitalOut led1(LED1); AS289R2 tp(D1); const char url[] = "https://developer.mbed.org/components/AS-289R2-Thermal-Printer-Shield/"; void AS289R2_demo() { tp.initialize(); tp.putLineFeed(2); /* Text Print */ tp.printf("Thermal Printer Shield\r"); tp.printf("Model:AS-289R2\r"); tp.putLineFeed(4); tp.setANKFont(AS289R2::ANK_8x16); tp.printf(" 8x16: ABCDEF 012345\r"); tp.setANKFont(AS289R2::ANK_12x24); tp.printf("12x24: ABCDEF 012345\r"); tp.setANKFont(AS289R2::ANK_16x16); tp.printf("16x16: ABCDEF 012345\r"); tp.setANKFont(AS289R2::ANK_24x24); tp.printf("24x24: ABCDEF 012345\r"); tp.putLineFeed(4); tp.setANKFont(AS289R2::ANK_12x24); tp.printf("AS-289R2\r"); tp.setDoubleSizeWidth(); tp.printf("AS-289R2\r"); tp.clearDoubleSizeWidth(); tp.setDoubleSizeHeight(); tp.printf("AS-289R2\r"); tp.clearDoubleSizeHeight(); tp.setQuadrupleSize(); tp.printf("AS-289R2\r"); tp.clearQuadrupleSize(); tp.setEnlargement(3, 3); tp.printf("AS-289R2\r"); tp.clearEnlargement(); tp.putLineFeed(4); /* 日本語 Print */ tp.setKanjiFont(AS289R2::KANJI_16x16); tp.printf("Japanese Language\r"); tp.printf("16x16: 日本語印字\r"); tp.setKanjiFont(AS289R2::KANJI_24x24); tp.printf("24x24: 日本語印字\r"); tp.putLineFeed(4); /* QR code */ tp.setANKFont(AS289R2::ANK_8x16); tp.printf("QR\r"); tp.printQRCode(AS289R2::QR_ERR_LVL_M, url); tp.printf("\r%s\r", url); tp.putLineFeed(4); /* Barcode */ tp.printf("Barcode UPC-A\r"); tp.printBarCode(AS289R2::BCODE_UPC_A, "01234567890"); tp.printf("Barcode JAN13\r"); tp.printBarCode(AS289R2::BCODE_JAN13, "123456789012"); tp.printf("Barcode JAN8\r"); tp.printBarCode(AS289R2::BCODE_JAN8, "1234567"); tp.printf("Barcode CODE39\r"); tp.printBarCode(AS289R2::BCODE_CODE39, "123456"); tp.printf("Barcode ITF\r"); tp.printBarCode(AS289R2::BCODE_ITF, "01234567890123"); tp.printf("Barcode CODABAR(NW7)\r"); tp.printBarCode(AS289R2::BCODE_CODABAR, "A0123456789A"); tp.putLineFeed(4); } // main() runs in its own thread in the OS // (note the calls to wait below for delays) int main() { AS289R2_demo(); while (true) { led1 = !led1; wait(0.5); } }
Please confirm the position of jumper(JP5)
To use D1 serial pin of the Nucleo platforms, you have to remove SB13 and SB14 then bridge SB62 and SB63.
AS-289R2 Thermal Printer Shield Library for Mbed
/* * Thermal Printer Shield for Mbed 2.0(classic) * Model:AS-289R2 * Sample Sourcecode * Mbed Library : https://developer.mbed.org/components/AS-289R2-Thermal-Printer-Shield/ * NADA ELECTRONICS, LTD. * http://www.nada.co.jp * By. Takehiro Yamaguchi */ #include "mbed.h" #include "AS289R2.h" DigitalOut led1(LED1); AS289R2 tp(D1); const char url[] = "https://developer.mbed.org/components/AS-289R2-Thermal-Printer-Shield/"; void AS289R2_demo() { tp.initialize(); tp.putLineFeed(2); /* Text Print */ tp.printf("Thermal Printer Shield\r"); tp.printf("Model:AS-289R2\r"); tp.putLineFeed(4); tp.setANKFont(AS289R2::ANK_8x16); tp.printf(" 8x16: ABCDEF 012345\r"); tp.setANKFont(AS289R2::ANK_12x24); tp.printf("12x24: ABCDEF 012345\r"); tp.setANKFont(AS289R2::ANK_16x16); tp.printf("16x16: ABCDEF 012345\r"); tp.setANKFont(AS289R2::ANK_24x24); tp.printf("24x24: ABCDEF 012345\r"); tp.putLineFeed(4); tp.setANKFont(AS289R2::ANK_12x24); tp.printf("AS-289R2\r"); tp.setDoubleSizeWidth(); tp.printf("AS-289R2\r"); tp.clearDoubleSizeWidth(); tp.setDoubleSizeHeight(); tp.printf("AS-289R2\r"); tp.clearDoubleSizeHeight(); tp.putLineFeed(4); /* 日本語 Print */ tp.setKanjiFont(AS289R2::KANJI_16x16); tp.printf("Japanese Language\r"); tp.printf("16x16: 日本語印字\r"); tp.setKanjiFont(AS289R2::KANJI_24x24); tp.printf("24x24: 日本語印字\r"); tp.putLineFeed(4); /* QR code */ tp.setANKFont(AS289R2::ANK_8x16); tp.printf("QR\r"); tp.printQRCode(AS289R2::QR_ERR_LVL_M, url); tp.printf("\r%s\r", url); tp.putLineFeed(4); /* Barcode */ tp.printf("Barcode UPC-A\r"); tp.printBarCode(AS289R2::BCODE_UPC_A, "01234567890"); tp.printf("Barcode JAN13\r"); tp.printBarCode(AS289R2::BCODE_JAN13, "123456789012"); tp.printf("Barcode JAN8\r"); tp.printBarCode(AS289R2::BCODE_JAN8, "1234567"); tp.printf("Barcode CODE39\r"); tp.printBarCode(AS289R2::BCODE_CODE39, "123456"); tp.printf("Barcode ITF\r"); tp.printBarCode(AS289R2::BCODE_ITF, "01234567890123"); tp.printf("Barcode CODABAR(NW7)\r"); tp.printBarCode(AS289R2::BCODE_CODABAR, "A0123456789A"); tp.putLineFeed(4); } int main() { AS289R2_demo(); while (true) { led1 = !led1; wait(0.5); } }
Please confirm the position of jumper(JP5)
/* * Thermal Printer Shield for Mbed 2.0(classic) * Model:AS-289R2 * Sample Sourcecode * NADA ELECTRONICS, LTD. * http://www.nada.co.jp * By. Takehiro Yamaguchi */ #include "mbed.h" Serial device(p28, NC); // tx(p28) int main() { while(1) { /* Text Print */ device.printf("Thermal Printer Shield\r"); device.printf("Text Printing.\r"); device.printf("\r\r"); // Line Feed x 2 /* QRcode Print */ char GsQr[] = { 0x1D,0x78,0x4C,0x04,0x54,0x45,0x53,0x54 }; for (int i = 0; i < sizeof(GsQr); i++) { device.putc(GsQr[i]); } device.printf("\r\r\r\r\r\r"); // Line Feed x 6 /* Wait */ wait(5.0); // 5Sec } }