commands restructured to be const vectors
Some checks failed
Build ptprnt / build (push) Failing after 1m1s

This commit is contained in:
2024-04-20 12:03:20 +02:00
parent b42e866a49
commit 2d54e583b7
8 changed files with 33 additions and 30 deletions

View File

@@ -31,13 +31,23 @@
#pragma once
namespace ptprnt::printer {
namespace p700::commands {
const cmd_T GET_STATUS{0x1b, 0x69, 0x53};
const cmd_T RASTER_START{0x1b, 0x69, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const cmd_T INFO{0x1b, 0x69, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const cmd_T PACKBITSON{0x02};
const cmd_T LF{0x5a};
const cmd_T FF{0x0c};
const cmd_T EJECT{0x1a};
const cmd_T PRINTER_INFO{0x81};
} // namespace p700::commands
constexpr uint8_t MAX_TRIES_GET_STATUS = 10;
class P700Printer : public ::ptprnt::IPrinterDriver {
public:
P700Printer() = default;
~P700Printer();
~P700Printer() override;
// delete copy ctor and assignment
P700Printer(const P700Printer&) = default;
@@ -59,7 +69,7 @@ class P700Printer : public ::ptprnt::IPrinterDriver {
bool printText(const std::string& text, uint16_t fontSize) override;
private:
bool send(std::vector<uint8_t>& data);
bool send(const std::vector<uint8_t>& data);
bool init();
std::shared_ptr<libusbwrap::IUsbDevice> mUsbHndl{nullptr};
@@ -70,16 +80,6 @@ class P700Printer : public ::ptprnt::IPrinterDriver {
.vid = 0x04f9,
.pid = 0x2061,
.pixelLines = 128};
std::map<std::string, std::vector<uint8_t>> commands{
{"rasterstart",
{0x1b, 0x69, 0x61,
0x01}}, // unique for P700, other printers have the 2 byte set to 0x52 instead of 0x61
{"info", {0x1b, 0x69, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
{"packbitson", {0x02}},
{"lf", {0x5a}},
{"ff", {0x0c}},
{"eject", {0x1a}},
{"printerinfo", {0x81}}};
};
} // namespace ptprnt::printer