Got it almost working...
This commit is contained in:
@@ -123,21 +123,23 @@ bool P700Printer::detachUsbDevice() {
|
||||
}
|
||||
|
||||
bool P700Printer::printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap) {
|
||||
auto bm = graphics::Bitmap<graphics::ALPHA8>(512, 128);
|
||||
{
|
||||
auto img = graphics::Label();
|
||||
bm.setPixels(std::vector<uint8_t>(img.getRaw(), img.getRaw() + 512 * 128));
|
||||
#ifdef DRYRUN
|
||||
SPDLOG_DEBUG("DRYRUN enabled");
|
||||
for (unsigned int lineNo = 0; lineNo < bitmap.getHeight(); lineNo++) {
|
||||
auto line = bitmap.getLine(lineNo);
|
||||
auto monoLine = graphics::Monochrome(*line);
|
||||
monoLine.visualize();
|
||||
}
|
||||
#endif
|
||||
|
||||
send(commands["rasterstart"]);
|
||||
|
||||
std::vector<uint8_t> rastercmd(4);
|
||||
rastercmd[0] = 0x47;
|
||||
rastercmd[1] = 0x00; // size +1
|
||||
rastercmd[2] = 0x00;
|
||||
rastercmd[3] = 0x00; // size -1
|
||||
for (unsigned int i = 0; i < bm.getWidth(); i++) {
|
||||
auto bmcol = bm.getCol(i);
|
||||
for (unsigned int i = 0; i < bitmap.getWidth(); i++) {
|
||||
auto bmcol = bitmap.getCol(i);
|
||||
if (!bmcol) {
|
||||
spdlog::error("Out of bounds bitmap access");
|
||||
break;
|
||||
@@ -152,6 +154,7 @@ bool P700Printer::printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap)
|
||||
buf[1] = col.size() + 1;
|
||||
buf[3] = col.size() - 1;
|
||||
if (!send(buf)) {
|
||||
spdlog::error("Error sending buffer to printer");
|
||||
break;
|
||||
};
|
||||
}
|
||||
@@ -203,11 +206,11 @@ bool P700Printer::send(std::vector<uint8_t>& data) {
|
||||
}
|
||||
#else
|
||||
tx = data.size();
|
||||
SPDLOG_DEBUG("USB raw data(len {}): {}", data.size(), spdlog::to_hex(data));
|
||||
spdlog::info("USB raw data(len {}): {}", data.size(), spdlog::to_hex(data));
|
||||
#endif
|
||||
|
||||
if (tx != static_cast<int>(data.size())) {
|
||||
spdlog::error("Could not transfer all data via USB bulk transfer. Only send {} of {} bytes",
|
||||
spdlog::error("Could not transfer all data via USB bulk transfer. Only sent {} of {} bytes",
|
||||
tx, data.size());
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user