moved menu lib to git server
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file displayWrapper.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the implementation of the class LcdWrapper
|
||||
* @version 0.1
|
||||
* @date 2023-01-08
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#include "LcdWrapper.h"
|
||||
|
||||
LcdWrapper::LcdWrapper(LiquidCrystal_I2C* lcd) {
|
||||
this->lcd = lcd;
|
||||
this->clear();
|
||||
this->changed = false;
|
||||
}
|
||||
|
||||
void LcdWrapper::loop() {
|
||||
if (this->changed) {
|
||||
this->lcd->clear();
|
||||
for (uint8_t i = 0; i < DISPLAY_WRAPPER_LINES; i++) {
|
||||
this->lcd->setCursor(0, i);
|
||||
this->lcd->print(this->data[i]);
|
||||
}
|
||||
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++) {
|
||||
data[i][j] = ' ';
|
||||
}
|
||||
}
|
||||
this->changed = true;
|
||||
}
|
||||
|
||||
void LcdWrapper::setCursor(uint8_t row, uint8_t line) {
|
||||
if (row > DISPLAY_WRAPPER_ROWS - 1)
|
||||
row = DISPLAY_WRAPPER_ROWS - 1;
|
||||
|
||||
if (line > DISPLAY_WRAPPER_LINES - 1)
|
||||
line = DISPLAY_WRAPPER_LINES - 1;
|
||||
|
||||
this->cursorRow = row;
|
||||
this->cursorLine = line;
|
||||
}
|
||||
|
||||
void LcdWrapper::print(const char *str) {
|
||||
uint8_t inputStringPosition = 0;
|
||||
for (uint8_t i = this->cursorRow; i < DISPLAY_WRAPPER_ROWS; i++) {
|
||||
if (str[inputStringPosition] == '\0')
|
||||
break;
|
||||
else
|
||||
this->data[this->cursorLine][i] = str[inputStringPosition];
|
||||
inputStringPosition++;
|
||||
}
|
||||
this->changed = true;
|
||||
}
|
||||
Reference in New Issue
Block a user