Add a printer factory to simplify construction of printer drivers (#11)
All checks were successful
Build ptprnt / build (push) Successful in 1m1s
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:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "interface/IPrinterDriver.hpp"
|
||||
#include "interface/IPrinterTypes.hpp"
|
||||
#include "libusbwrap/LibUsbTypes.hpp"
|
||||
#include "libusbwrap/interface/IUsbDevice.hpp"
|
||||
|
||||
#pragma once
|
||||
@@ -44,30 +45,31 @@ class P700Printer : public ::ptprnt::IPrinterDriver {
|
||||
P700Printer(P700Printer&&) = default;
|
||||
P700Printer& operator=(P700Printer&&) = default;
|
||||
|
||||
// Printer info has to be static to be accessed without instantiation
|
||||
static const PrinterInfo mInfo;
|
||||
|
||||
// IPrinterDriver
|
||||
const std::string_view getDriverName() override;
|
||||
const std::string_view getName() override;
|
||||
const uint16_t getPid() override;
|
||||
const uint16_t getVid() override;
|
||||
const std::string_view getVersion() override;
|
||||
const PrinterInfo getPrinterInfo() override;
|
||||
const PrinterStatus getPrinterStatus() override;
|
||||
[[nodiscard]] const std::string_view getDriverName() override;
|
||||
[[nodiscard]] const std::string_view getName() override;
|
||||
[[nodiscard]] const libusbwrap::usbId getUsbId() override;
|
||||
[[nodiscard]] const std::string_view getVersion() override;
|
||||
[[nodiscard]] const PrinterInfo getPrinterInfo() override;
|
||||
[[nodiscard]] const PrinterStatus getPrinterStatus() override;
|
||||
bool attachUsbDevice(std::shared_ptr<libusbwrap::IUsbDevice> usbHndl) override;
|
||||
bool detachUsbDevice() override;
|
||||
bool setText(const std::string& text) override;
|
||||
bool setFont(const std::string& text) override;
|
||||
bool setFontSize(uint8_t fontSize) override;
|
||||
bool setHAlign(HAlignPosition hpos) override;
|
||||
bool setVAlign(VAlignPosition vpos) override;
|
||||
bool printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap) override;
|
||||
bool printText(const std::string& text, uint16_t fontSize) override;
|
||||
bool print() override;
|
||||
|
||||
private:
|
||||
bool send(std::vector<uint8_t>& data);
|
||||
bool init();
|
||||
|
||||
std::shared_ptr<libusbwrap::IUsbDevice> mUsbHndl{nullptr};
|
||||
|
||||
static constexpr PrinterInfo mInfo{.driverName = "P700",
|
||||
.name = "Brother P-touch P700",
|
||||
.version = "v1.0",
|
||||
.vid = 0x04f9,
|
||||
.pid = 0x2061};
|
||||
std::map<std::string, std::vector<uint8_t>> commands{
|
||||
{"rasterstart",
|
||||
{0x1b, 0x69, 0x61,
|
||||
|
Reference in New Issue
Block a user