Implemented printer status retrieval
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user