Add a printer factory to simplify construction of printer drivers (#11)
All checks were successful
Build ptprnt / build (push) Successful in 1m1s

Co-authored-by: Moritz Martinius <mm@cloudprinters.de>
Reviewed-on: #11
This commit is contained in:
2024-04-20 11:10:30 +00:00
parent 5b3148cb65
commit ad0b2c91ae
17 changed files with 231 additions and 87 deletions

View File

@@ -41,6 +41,11 @@
namespace ptprnt::printer {
const PrinterInfo P700Printer::mInfo = {.driverName = "P700",
.name = "Brother P-touch P700",
.version = "v1.0",
.usbId{0x04f9, 0x2061}};
P700Printer::~P700Printer() {
detachUsbDevice();
if (mUsbHndl) {
@@ -80,12 +85,8 @@ const PrinterStatus P700Printer::getPrinterStatus() {
return PrinterStatus{.tapeWidthMm = recvBuf[10]};
}
const uint16_t P700Printer::getVid() {
return mInfo.vid;
}
const uint16_t P700Printer::getPid() {
return mInfo.pid;
const libusbwrap::usbId P700Printer::getUsbId() {
return mInfo.usbId;
}
bool P700Printer::attachUsbDevice(std::shared_ptr<libusbwrap::IUsbDevice> usbHndl) {
@@ -159,7 +160,27 @@ bool P700Printer::printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap)
return true;
}
bool P700Printer::printText(const std::string& text, uint16_t fontSize) {
bool P700Printer::setText(const std::string& text) {
return true;
};
bool P700Printer::setFont(const std::string& text) {
return true;
};
bool P700Printer::setFontSize(uint8_t fontSize) {
return true;
};
bool P700Printer::setHAlign(HAlignPosition hpos) {
return true;
};
bool P700Printer::setVAlign(VAlignPosition vpos) {
return true;
}
bool P700Printer::print() {
send(commands["lf"]);
send(commands["ff"]);
send(commands["eject"]);