Small Todos for the next session, some clean up
Some checks failed
Build ptprnt / build (push) Failing after 32s

This commit is contained in:
2024-04-28 20:44:13 +02:00
parent 59ef4189c4
commit f702ec5473
5 changed files with 9 additions and 12 deletions

View File

@@ -33,7 +33,7 @@
#include "spdlog/fmt/bin_to_hex.h" #include "spdlog/fmt/bin_to_hex.h"
// as long as DRYRUN is defined, no data is actually send to the printer, we need to save some tape ;) // as long as DRYRUN is defined, no data is actually send to the printer, we need to save some tape ;)
//#define DRYRUN #define DRYRUN
namespace ptprnt::printer { namespace ptprnt::printer {

View File

@@ -178,7 +178,8 @@ void PtouchPrint::setupLogger(spdlog::level::level_enum lvl) {
consoleSink->set_level(lvl); consoleSink->set_level(lvl);
if (spdlog::level::level_enum::debug == lvl || spdlog::level::level_enum::trace == lvl) { if (spdlog::level::level_enum::debug == lvl || spdlog::level::level_enum::trace == lvl) {
// This will enable file and line number for debug and trace macros // This will enable file and line number for debug and trace macros
consoleSink->set_pattern("%^%L:%$ %v (%s:%#)"); // TODO: line number and functions only work with macros
consoleSink->set_pattern("%^%L:%$ %v");
} else { } else {
consoleSink->set_pattern("%^%L:%$ %v"); consoleSink->set_pattern("%^%L:%$ %v");
} }

View File

@@ -19,18 +19,15 @@
#include "Bitmap.hpp" #include "Bitmap.hpp"
#include <algorithm>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <iostream>
#include <iterator> #include <iterator>
#include <optional> #include <optional>
#include <vector> #include <vector>
namespace ptprnt::graphics { namespace ptprnt::graphics {
template <class T> template <class T>
Bitmap<T>::Bitmap(uint16_t width, uint16_t height) Bitmap<T>::Bitmap(uint16_t width, uint16_t height) : mWidth{width}, mHeight{height}, mPixels(width * height) {}
: mWidth{width}, mHeight{height}, mPixels(width * height) {}
template <class T> template <class T>
[[nodiscard]] uint16_t Bitmap<T>::getWidth() const { [[nodiscard]] uint16_t Bitmap<T>::getWidth() const {
@@ -45,8 +42,7 @@ template <class T>
template <class T> template <class T>
bool Bitmap<T>::setPixels(const std::vector<T>& pixels) { bool Bitmap<T>::setPixels(const std::vector<T>& pixels) {
if (pixels.size() != mPixels.size()) { if (pixels.size() != mPixels.size()) {
spdlog::error("Invalid pixel buffer size (got {} vs. {} bitmap size).", pixels.size(), spdlog::error("Invalid pixel buffer size (got {} vs. {} bitmap size).", pixels.size(), mPixels.size());
mPixels.size());
return false; return false;
} }
@@ -71,6 +67,7 @@ template <class T>
return std::vector<T>(lineStart, lineEnd); return std::vector<T>(lineStart, lineEnd);
} }
// TODO: I guess this is borked
template <class T> template <class T>
[[nodiscard]] std::optional<std::vector<T>> Bitmap<T>::getCol(uint16_t col) const { [[nodiscard]] std::optional<std::vector<T>> Bitmap<T>::getCol(uint16_t col) const {
if (col >= mWidth) { if (col >= mWidth) {

View File

@@ -118,7 +118,9 @@ bool Label::create(const std::string& labelText) {
mLayoutHeight /= PANGO_SCALE; mLayoutHeight /= PANGO_SCALE;
spdlog::debug("Layout width: {}, height: {}", mLayoutWidth, mLayoutHeight); spdlog::debug("Layout width: {}, height: {}", mLayoutWidth, mLayoutHeight);
mSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, mLayoutWidth, mPrinterHeight); auto alignedWidth = mLayoutWidth + (8 - (mLayoutWidth % 8));
mSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, alignedWidth, mPrinterHeight);
cairo_t* cr = cairo_create(mSurface); cairo_t* cr = cairo_create(mSurface);
// Adjust Cairo cursor position to respect the vertical alignment // Adjust Cairo cursor position to respect the vertical alignment

View File

@@ -21,8 +21,6 @@
#include <cmath> #include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@@ -40,7 +38,6 @@ void Monochrome::invert(bool shouldInvert) {
std::vector<uint8_t> Monochrome::get() { std::vector<uint8_t> Monochrome::get() {
std::vector<uint8_t> outPixels( std::vector<uint8_t> outPixels(
(static_cast<unsigned int>((mPixels.size() / 8)) + (std::floor(mPixels.size() % 8 + 0.9)))); (static_cast<unsigned int>((mPixels.size() / 8)) + (std::floor(mPixels.size() % 8 + 0.9))));
unsigned int outIndex = 0; unsigned int outIndex = 0;
for (unsigned int byteNo = 0; byteNo < mPixels.size(); byteNo += 8) { for (unsigned int byteNo = 0; byteNo < mPixels.size(); byteNo += 8) {