more flexible, slight sanity fixes

This commit is contained in:
Drath
2025-10-03 15:54:58 +02:00
parent 5f29a9138c
commit c6175fbd99
2 changed files with 42 additions and 23 deletions

View File

@@ -1,6 +1,9 @@
#ifndef LCDDISPLAY_HPP
#define LCDDISPLAY_HPP
#define LCD_LINES 4
#define LCD_COLS 40
#include <array>
#include <cstdint>
#include <sstream>
@@ -9,29 +12,30 @@
class LCDDisplay {
private:
uint8_t _lcd;
char writebuf[4 * 40 + 8]; // 4x40 chars + 2x4 setcursor commands
void writeStr(std::string str); // do not use
void writeLines(std::array<std::string, 4> lines); // do not use
char writebuf[LCD_LINES * LCD_COLS + 8]; // 4x40 chars + 2x4 setcursor commands
static constexpr bool dualDisp = (LCD_LINES * LCD_COLS > 80); // is it dual display device or not, evauluated from the size at compile time
void writeLines(std::array<std::string, 4> lines); // do not use
public:
LCDDisplay(std::string dev, uint32_t baud = 0010002); // from termios-baud.h, B115200
~LCDDisplay();
// custom char array
char cc[8] = {'\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7'};
void clear();
void setContrast(uint8_t contrast);
void setBacklight(bool enabled);
void setBacklight(uint8_t brightness);
void setCursor(uint8_t row, uint8_t col);
void setCustomChar(uint8_t index, std::array<uint8_t, 8> cchar);
void writeStr(std::string str);
void writeStr(uint8_t row, uint8_t col, std::string str);
void writeBuf(uint8_t row, uint8_t col, std::string str);
void clearBuf();
void flushBuf();
// returns custom char no. c, small enough to define in header
constexpr char cc(uint8_t c) { return c % 8; }
char bar(uint8_t char_id, double value);
};