floatpump-firmware/Middlewares/floatpump/Inc/LCD_I2C_Driver.h

66 lines
1.6 KiB
C++

//
// Created by robtor on 09.12.22.
//
#ifndef FLOATPUMP_LCD_I2C_DRIVER_H
#define FLOATPUMP_LCD_I2C_DRIVER_H
#include "stm32f4xx_hal.h"
namespace floatpump{
class LCD_I2C_Driver {
public:
LCD_I2C_Driver(I2C_HandleTypeDef &handle, uint16_t displayAddr, uint8_t rows = 4, uint8_t cols = 20)
: m_handle(handle), m_displayAddr(displayAddr) {};
// Functions sending text
void LCDSendCString(char *str);
// Functions for configuration
void LCDInitialize(void);
void LCDClearDisplay(void);
void LCDSetBacklight(bool enabled);
void LCDPower(bool enabled);
void LCDCursor(bool enabled);
void LCDCursorBlink(bool enabled);
// These configurations are normally not necessary to change
void LCDCursorIncDec(bool enabled);
void LCDDisplayShift(bool enabled);
// Move Cursor
void LCDSetCursor(uint8_t x, uint8_t y);
// Position
typedef struct {
uint8_t x;
uint8_t y;
} pos_t;
// Getters
pos_t getPosition();
private:
I2C_HandleTypeDef m_handle;
uint16_t m_displayAddr;
bool m_backlight{};
bool m_cursor{};
bool m_cursorBlink{};
bool m_incrementDecrement{};
bool m_autoShift{};
bool m_powered;
pos_t m_curPos;
void m_lcdSendData(char data);
void m_lcdSendCmnd(char cmnd);
};
} // floatpump
#endif //FLOATPUMP_LCD_I2C_DRIVER_H