81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
/**
|
|
* @file displayWrapper.h
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief Contains the LcdWrapper class
|
|
* @version 0.1
|
|
* @date 2023-01-08
|
|
*
|
|
* @copyright Copyright (c) 2023
|
|
*
|
|
*/
|
|
|
|
#ifndef LCD_WRAPPER_H
|
|
#define LCD_WRAPPER_H
|
|
|
|
#include <iostream>
|
|
#include <LiquidCrystal_I2C.h>
|
|
#include <displayWrapper.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);
|
|
|
|
/**
|
|
* @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
|
|
* loop function has to be called to print the data.
|
|
*/
|
|
class LcdWrapper : public DisplayWrapper {
|
|
public:
|
|
/**
|
|
* @brief Construct a new Lcd Wrapper object
|
|
*
|
|
* @param lcd
|
|
*/
|
|
LcdWrapper(LiquidCrystal_I2C* lcd);
|
|
|
|
/**
|
|
* @brief Print the saved data
|
|
*
|
|
*/
|
|
void loop();
|
|
|
|
/**
|
|
* @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 Save the data to be printed
|
|
*
|
|
* @param str
|
|
*/
|
|
void print(const char *str) override;
|
|
|
|
|
|
private:
|
|
LiquidCrystal_I2C* lcd;
|
|
LcdWrapperCallback callback = nullptr;
|
|
char data[DISPLAY_WRAPPER_LINES][DISPLAY_WRAPPER_ROWS];
|
|
|
|
uint8_t cursorRow = 0;
|
|
uint8_t cursorLine = 0;
|
|
|
|
bool changed = false;
|
|
};
|
|
|
|
#endif // DISPLAY_WRAPPER_H
|