Implemented printer status retrieval

This commit is contained in:
2023-08-27 09:29:37 +02:00
parent 5644c84c83
commit f467a39919
9 changed files with 202 additions and 9 deletions

View File

@@ -15,10 +15,26 @@ void PtouchPrint::init() {
}
void PtouchPrint::run() {
if (getCompatiblePrinters() == 0) {
auto numFoundPrinters = getCompatiblePrinters();
if (numFoundPrinters == 0) {
spdlog::error(
"No compatible printers found, please make sure if they are turned on and connected");
return;
} else if (numFoundPrinters > 1) {
spdlog::warn("Found more than one compatible printer. Currently not supported.");
return;
}
auto printer = mCompatiblePrinters[0];
auto devices = mUsbDeviceFactory.findDevices(printer->getVid(), printer->getPid());
if (devices.size() != 1) {
spdlog::warn(
"Found more than one device of the same printer on bus. Currently not supported");
return;
}
printer->attachUsbDevice(devices[0]);
auto status = printer->getPrinterStatus();
spdlog::info("Detected tape width is {}mm", status.tapeWidthMm);
}
unsigned int PtouchPrint::getCompatiblePrinters() {