remove most of the defines

This commit is contained in:
2023-08-18 15:34:56 +02:00
parent 4cd2b9368d
commit a82b32087c
21 changed files with 155 additions and 285 deletions
+9 -9
View File
@@ -22,20 +22,20 @@ void LcdWrapper::run() {
return;
this->lcd->clear();
for (uint8_t i = 0; i < DISPLAY_WRAPPER_LINES; i++) {
for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) {
this->lcd->setCursor(0, i);
this->lcd->print(this->data[i]);
}
if (this->callback)
this->callback(this->data, DISPLAY_WRAPPER_LINES, DISPLAY_WRAPPER_ROWS);
this->callback(this->data, LcdWrapper::totalLines, LcdWrapper::totalRows);
this->changed = false;
}
void LcdWrapper::clear() {
for (uint8_t i = 0; i < DISPLAY_WRAPPER_LINES; i++) {
for (uint8_t j = 0; j < DISPLAY_WRAPPER_ROWS; j++) {
for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) {
for (uint8_t j = 0; j < LcdWrapper::totalRows; j++) {
data[i][j] = ' ';
}
}
@@ -43,11 +43,11 @@ void LcdWrapper::clear() {
}
void LcdWrapper::setCursor(uint8_t row, uint8_t line) {
if (row > DISPLAY_WRAPPER_ROWS - 1)
row = DISPLAY_WRAPPER_ROWS - 1;
if (row > LcdWrapper::totalRows - 1)
row = LcdWrapper::totalRows - 1;
if (line > DISPLAY_WRAPPER_LINES - 1)
line = DISPLAY_WRAPPER_LINES - 1;
if (line > LcdWrapper::totalLines - 1)
line = LcdWrapper::totalLines - 1;
this->cursorRow = row;
this->cursorLine = line;
@@ -55,7 +55,7 @@ void LcdWrapper::setCursor(uint8_t row, uint8_t line) {
void LcdWrapper::print(const char *str) {
uint8_t inputStringPosition = 0;
for (uint8_t i = this->cursorRow; i < DISPLAY_WRAPPER_ROWS; i++) {
for (uint8_t i = this->cursorRow; i < LcdWrapper::totalRows; i++) {
if (str[inputStringPosition] == '\0')
break;
else
+5 -7
View File
@@ -17,11 +17,7 @@
#include <displayWrapper.h>
#include <component.h>
#define DISPLAY_WRAPPER_ROWS 16
#define DISPLAY_WRAPPER_LINES 2
typedef void (*LcdWrapperCallback) (const char data[][DISPLAY_WRAPPER_ROWS], uint8_t lines, uint8_t rows);
typedef void (*LcdWrapperCallback) (const char data[][16], uint8_t lines, uint8_t rows);
/**
* @brief A class for the Menu class to print information
*
@@ -60,13 +56,15 @@ class LcdWrapper : public DisplayWrapper, public Component {
*/
void print(const char *str) override;
static constexpr uint8_t totalRows = 16;
static constexpr uint8_t totalLines = 2;
private:
void run() override;
LiquidCrystal_I2C* lcd;
LcdWrapperCallback callback = nullptr;
char data[DISPLAY_WRAPPER_LINES][DISPLAY_WRAPPER_ROWS];
char data[LcdWrapper::totalLines][LcdWrapper::totalRows];
uint8_t cursorRow = 0;
uint8_t cursorLine = 0;