58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
#include <sys/types.h>
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "interface/IPrinterDriver.hpp"
|
|
#include "interface/IPrinterTypes.hpp"
|
|
#include "libusbwrap/interface/IUsbDevice.hpp"
|
|
|
|
#pragma once
|
|
|
|
namespace ptprnt::printer {
|
|
|
|
class P700Printer : public ::ptprnt::IPrinterDriver {
|
|
public:
|
|
P700Printer();
|
|
~P700Printer();
|
|
|
|
// delete copy ctor and assignment
|
|
P700Printer(const P700Printer&) = delete;
|
|
P700Printer& operator=(P700Printer&) = delete;
|
|
|
|
// 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;
|
|
bool attachUsbDevice(std::shared_ptr<libusbwrap::IUsbDevice> usbHndl) override;
|
|
bool detachUsbDevice() override;
|
|
bool printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap) override;
|
|
bool printText(const std::string& text, uint16_t fontSize) override;
|
|
|
|
private:
|
|
bool send(std::vector<uint8_t>& data);
|
|
bool init();
|
|
|
|
std::shared_ptr<libusbwrap::IUsbDevice> mUsbHndl{nullptr};
|
|
|
|
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, 0x52, 0x01}},
|
|
{"info", {0x1b, 0x69, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
|
|
{"packbitson", {0x02}},
|
|
{"lf", {0x5a}},
|
|
{"ff", {0x0c}},
|
|
{"eject", {0x1a}},
|
|
};
|
|
};
|
|
|
|
} // namespace ptprnt::printer
|