
#include "printer.h"

void printPrinterLine(String line) {
#if defined(PRT_ADAFRUIT_THERMAL_SERIAL)
if (line.length()>PRT_MAXLINECHARS) {
	line = line.substring(0,PRT_MAXLINECHARS);
}
#if defined(PRT_SERIAL1)
	Serial1.println(line);
#elif defined(PRT_SERIAL2)
	Serial2.println(line);
#else
#error unrecognized serial channel for PRT_ADAFRUIT_THERMAL_SERIAL in printLine()
#endif
#else
#error unrecognized PRT in printLine()
#endif
}

void printerPaperFeed() {
	printPrinterLine("");
}

void initPrinter() {
#if defined(PRT_ADAFRUIT_THERMAL_SERIAL)
#if defined(PRT_SERIAL1)
	Serial1.setTX(PRT_SERIAL1_TX_PIN);
	Serial1.setRX(PRT_SERIAL1_RX_PIN);
	Serial1.begin(PRT_SERIAL1_BAUDRATE);
#elif defined(PRT_SERIAL2)
	Serial2.setTX(PRT_SERIAL2_TX_PIN);
	Serial2.setRX(PRT_SERIAL2_RX_PIN);
	Serial2.begin(PRT_SERIAL2_BAUDRATE);
#else
#error unrecognized serial channel for PRT_ADAFRUIT_THERMAL_SERIAL in initPrinter()
#endif
#else
#error unrecognized PRT in initPrinter()
#endif
}