#include "QR204.h" static bool initialized = false; static uint8_t uart = 0; static const char initCmd[] = { 0x1b, '@' }; // ***** INIT ***** void tp_init(uint8_t uartNo) { if (!initialized) { uart = uartNo; mgos_uart_write(uart, initCmd, sizeof(initCmd)); initialized = true; } } // ***** End of INIT ***** // ***** MODE Handling ***** static uint8_t currentMode = 0; void tp_set_mode(uint8_t addModes) { currentMode |= addModes; char setModeCmd[3] = {0x1b, '!', currentMode}; mgos_uart_write(uart, setModeCmd, 3); } void tp_reset_mode(uint8_t removeModes) { currentMode &= ~removeModes; char setModeCmd[3] = {0x1b, '!', currentMode}; mgos_uart_write(uart, setModeCmd, 3); } void tp_reverse_feed(uint8_t numLines) { char cmd[3] = { 0x1b, 'e', numLines }; mgos_uart_write(uart, cmd, 3); } void tp_linefeed(uint8_t numLines) { char cmd[3] = { 0x1b, 'd', numLines }; mgos_uart_write(uart, cmd, 3); } void tp_cutpaper(bool fullcut) { char cmd[3] = { 0x1d, 'V', fullcut ? '0' : '1' }; mgos_uart_write(uart, cmd, 3); } // ***** End of MODE Handling ***** /* PRINT #1, CHR$(&H1B);"@"; 'Initializes the printer (ESC @) PRINT #1, CHR$(&H1B);"a";CHR$(1);'Specifies a centered printing position (ESC a) PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Specifies font A (ESC !) PRINT #1, "January 14, 2002 15:00"; PRINT #1, CHR$(&H1B);"d";CHR$(3); 'Prints and 3 line feeding (ESC d) PRINT #1, CHR$(&H1B);"a";CHR$(0); 'Selects the left print position (ESC a) PRINT #1, CHR$(&H1B);"!";CHR$(1); 'Selects font B PRINT #1, "TM-U210B" PRINT #1, "TM-U210D" PRINT #1, "PS-170" PRINT #1, CHR$(&HA); $20.00";CHR$(&HA); $21.00";CHR$(&HA); $17.00";CHR$(&HA); 'Line feeding (LF) PRINT #1, CHR$(&H1B);"!";CHR$(17); 'Selects double-height mode PRINT #1, "TOTAL $58.00"; CHR$(&HA); PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Cancels double-height mode PRINT #1, "------------------------------";CHR$(&HA); PRINT #1, "PAID $60.00";CHR$(&HA); PRINT #1, "CHANGE $ 2.00";CHR$(&HA); PRINT #1, CHR$(&H1D);"V";CHR$(66);CHR$(0); 'Feeds paper & cut ’Drawer Kick (ESC p) PRINT #1, CHR$(&H1B); CHR$(&H70); CHR$(&H0); CHR$(60); CHR$(120); */