Moved graphics classes into own namespace, added unit testing with gtest

This commit is contained in:
2023-09-23 13:29:54 +02:00
parent 7ab817793d
commit c0811df4bb
18 changed files with 334 additions and 136 deletions

View File

@@ -1,6 +1,8 @@
#include <sys/types.h>
#include <map>
#include <memory>
#include <vector>
#include "interface/IPrinterDriver.hpp"
#include "interface/IPrinterTypes.hpp"
@@ -29,11 +31,12 @@ class P700Printer : public ::ptprnt::IPrinterDriver {
const PrinterStatus getPrinterStatus() override;
bool attachUsbDevice(std::shared_ptr<libusbwrap::IUsbDevice> usbHndl) override;
bool detachUsbDevice() override;
bool printBitmap(const Bitmap& bitmap) 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};
@@ -42,6 +45,14 @@ class P700Printer : public ::ptprnt::IPrinterDriver {
.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