clangtidy corrections part 1

This commit is contained in:
2023-10-11 17:35:40 +02:00
parent 77a52b82c3
commit 23d854a826
36 changed files with 2383 additions and 1165 deletions
+36 -18
View File
@@ -4,62 +4,80 @@
* @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;
LcdWrapper::LcdWrapper(LiquidCrystal_I2C *lcd)
: lcd{lcd}, changed{false}
{
this->clear();
this->changed = false;
}
void LcdWrapper::run() {
void LcdWrapper::run()
{
if (!this->changed)
{
return;
}
this->lcd->clear();
for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) {
for (uint8_t i = 0; i < LcdWrapper::totalLines; i++)
{
this->lcd->setCursor(0, i);
this->lcd->print(this->data[i]);
this->lcd->print(static_cast<const char *>(this->data[i]));
}
if (this->callback)
if (static_cast<bool>(this->callback))
{
this->callback(this->data, LcdWrapper::totalLines, LcdWrapper::totalRows);
}
this->changed = false;
}
void LcdWrapper::clear() {
for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) {
for (uint8_t j = 0; j < LcdWrapper::totalRows; j++) {
void LcdWrapper::clear()
{
for (uint8_t i = 0; i < LcdWrapper::totalLines; i++)
{
for (uint8_t j = 0; j < LcdWrapper::totalRows; j++)
{
data[i][j] = ' ';
}
}
this->changed = true;
}
void LcdWrapper::setCursor(uint8_t row, uint8_t line) {
void LcdWrapper::setCursor(uint8_t row, uint8_t line)
{
if (row > LcdWrapper::totalRows - 1)
{
row = LcdWrapper::totalRows - 1;
}
if (line > LcdWrapper::totalLines - 1)
{
line = LcdWrapper::totalLines - 1;
}
this->cursorRow = row;
this->cursorLine = line;
}
void LcdWrapper::print(const char *str) {
void LcdWrapper::print(const char *str)
{
uint8_t inputStringPosition = 0;
for (uint8_t i = this->cursorRow; i < LcdWrapper::totalRows; i++) {
for (uint8_t i = this->cursorRow; i < LcdWrapper::totalRows; i++)
{
if (str[inputStringPosition] == '\0')
{
break;
else
this->data[this->cursorLine][i] = str[inputStringPosition];
}
this->data[this->cursorLine][i] = str[inputStringPosition];
inputStringPosition++;
}
this->changed = true;
+45 -44
View File
@@ -4,9 +4,9 @@
* @brief Contains the LcdWrapper class
* @version 0.1
* @date 2023-01-08
*
*
* @copyright Copyright (c) 2023
*
*
*/
#ifndef LCD_WRAPPER_H
@@ -17,59 +17,60 @@
#include <displayWrapper.h>
#include <component.h>
typedef void (*LcdWrapperCallback) (const char data[][16], 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
*
* @brief A class for the Menu class to print information
*
* This class inherits the DisplayWrapper class as a interface.
* The class takes the information to print from any thread. The
* The class takes the information to print from any thread. The
* loop function has to be called to print the data.
*/
class LcdWrapper : public DisplayWrapper, public Component {
public:
/**
* @brief Construct a new Lcd Wrapper object
*
* @param lcd
*/
LcdWrapper(LiquidCrystal_I2C* lcd);
class LcdWrapper : public DisplayWrapper, public Component
{
public:
/**
* @brief Construct a new Lcd Wrapper object
*
* @param lcd
*/
LcdWrapper(LiquidCrystal_I2C *lcd);
/**
* @brief Empty the buffer
*
*/
void clear() override;
/**
* @brief Empty the buffer
*
*/
void clear() override;
/**
* @brief Set point where data to be saved
*
* @param row
* @param line
*/
void setCursor(uint8_t row, uint8_t line) override;
void setCallback(LcdWrapperCallback callback) { this->callback = callback; }
/**
* @brief Set point where data to be saved
*
* @param row
* @param line
*/
void setCursor(uint8_t row, uint8_t line) override;
void setCallback(LcdWrapperCallback callback) { this->callback = callback; }
/**
* @brief Save the data to be printed
*
* @param str
*/
void print(const char *str) override;
/**
* @brief Save the data to be printed
*
* @param str
*/
void print(const char *str) override;
static constexpr uint8_t totalRows = 16;
static constexpr uint8_t totalLines = 2;
private:
void run() override;
static constexpr uint8_t totalRows = 16;
static constexpr uint8_t totalLines = 2;
LiquidCrystal_I2C* lcd;
LcdWrapperCallback callback = nullptr;
char data[LcdWrapper::totalLines][LcdWrapper::totalRows];
private:
void run() override;
uint8_t cursorRow = 0;
uint8_t cursorLine = 0;
LiquidCrystal_I2C *lcd;
LcdWrapperCallback callback = nullptr;
char data[LcdWrapper::totalLines][LcdWrapper::totalRows];
bool changed = false;
uint8_t cursorRow = 0;
uint8_t cursorLine = 0;
bool changed = false;
};
#endif // DISPLAY_WRAPPER_H