Formatting...

This commit is contained in:
2022-11-12 18:37:24 +01:00
parent d7dfdc4739
commit f09e4ab5c8
6 changed files with 37 additions and 36 deletions

View File

@@ -1,7 +1,7 @@
#include "UsbTypes.hpp" #include "UsbTypes.hpp"
#include <vector>
#include <optional> #include <optional>
#include <vector>
#pragma once #pragma once

View File

@@ -11,7 +11,8 @@ namespace ptprnt::driver {
class P700Driver : public IDriver { class P700Driver : public IDriver {
public: public:
P700Driver(std::shared_ptr<Usb> usbDriver, uint16_t usbDevVendor = 0x04f9, uint16_t usbDevId = 0x2061); P700Driver(std::shared_ptr<Usb> usbDriver, uint16_t usbDevVendor = 0x04f9,
uint16_t usbDevId = 0x2061);
~P700Driver() override; ~P700Driver() override;
driver::info getInfo() override; driver::info getInfo() override;

View File

@@ -7,16 +7,16 @@
namespace ptprnt::driver { namespace ptprnt::driver {
P700Driver::P700Driver(std::shared_ptr<Usb> usbDriver, uint16_t usbDevVendor, uint16_t usbProductId) P700Driver::P700Driver(std::shared_ptr<Usb> usbDriver, uint16_t usbDevVendor,
: mUsbDriver{std::move(usbDriver)} uint16_t usbProductId)
, mUsbDev{.vendorId = usbDevVendor, .productId = usbProductId} : mUsbDriver{std::move(usbDriver)},
mUsbDev{.vendorId = usbDevVendor, .productId = usbProductId}
{ {
spdlog::debug("P700Driver constructing"); spdlog::debug("P700Driver constructing");
if (!init()) { if (!init()) {
spdlog::error("Could not find any P700 Printers."); spdlog::error("Could not find any P700 Printers.");
} } else {
else {
spdlog::info("Found P700 Printer :-)."); spdlog::info("Found P700 Printer :-).");
} }
} }
@@ -49,12 +49,15 @@ bool P700Driver::init() {
return false; return false;
} }
auto devIt = std::find_if(devs.value().begin(), devs.value().end(), auto devIt =
[=] (auto dev) { return mUsbDev.vendorId == dev.vendorId && mUsbDev.productId == dev.productId;} std::find_if(devs.value().begin(), devs.value().end(), [=](auto dev) {
); return mUsbDev.vendorId == dev.vendorId &&
mUsbDev.productId == dev.productId;
});
if (devIt == devs.value().end()) { if (devIt == devs.value().end()) {
spdlog::error("No device with {0:04X}:{1:04X}", mUsbDev.vendorId, mUsbDev.productId); spdlog::error("No device with {0:04X}:{1:04X}", mUsbDev.vendorId,
mUsbDev.productId);
return false; return false;
} }

View File

@@ -1,9 +1,9 @@
#include "Usb.hpp" #include "Usb.hpp"
#include <iostream>
#include <iomanip>
#include <optional>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <iomanip>
#include <iostream>
#include <optional>
namespace ptprnt::driver { namespace ptprnt::driver {
@@ -11,6 +11,7 @@ Usb::Usb() {
spdlog::debug("Usb constructing"); spdlog::debug("Usb constructing");
libusb_init(NULL); libusb_init(NULL);
} }
Usb::~Usb() { Usb::~Usb() {
spdlog::debug("Usb destructing"); spdlog::debug("Usb destructing");
} }

View File

@@ -13,7 +13,6 @@ using namespace ptprnt;
void setupLogger() { void setupLogger() {
spdlog::set_level(spdlog::level::debug); spdlog::set_level(spdlog::level::debug);
spdlog::info("Starting ptprnt {}", PROJ_VERSION); spdlog::info("Starting ptprnt {}", PROJ_VERSION);
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
@@ -32,6 +31,3 @@ int main(int argc, char** argv) {
return 0; return 0;
} }