2022-12-09 14:33:03 +00:00
|
|
|
//
|
|
|
|
// 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)
|
2022-12-09 14:54:45 +00:00
|
|
|
: m_handle(handle), m_displayAddr(displayAddr) {};
|
2022-12-09 14:33:03 +00:00
|
|
|
|
2022-12-09 14:47:07 +00:00
|
|
|
// Functions sending text
|
2022-12-09 14:33:03 +00:00
|
|
|
void LCDSendCString(char *str);
|
2022-12-09 14:47:07 +00:00
|
|
|
|
|
|
|
// Functions for configuration
|
2022-12-09 14:33:03 +00:00
|
|
|
void LCDInitialize(void);
|
|
|
|
void LCDClearDisplay(void);
|
|
|
|
void LCDSetBacklight(bool enabled);
|
|
|
|
void LCDPower(bool enabled);
|
|
|
|
void LCDCursor(bool enabled);
|
|
|
|
void LCDCursorBlink(bool enabled);
|
2022-12-09 14:47:07 +00:00
|
|
|
|
|
|
|
// These configurations are normally not necessary to change
|
2022-12-09 14:33:03 +00:00
|
|
|
void LCDCursorIncDec(bool enabled);
|
|
|
|
void LCDDisplayShift(bool enabled);
|
|
|
|
|
2022-12-09 14:47:07 +00:00
|
|
|
// Move Cursor
|
2022-12-09 14:33:03 +00:00
|
|
|
void LCDSetCursor(uint8_t x, uint8_t y);
|
|
|
|
|
2022-12-09 14:59:27 +00:00
|
|
|
// Position
|
|
|
|
typedef struct {
|
|
|
|
uint8_t x;
|
|
|
|
uint8_t y;
|
|
|
|
} pos_t;
|
2022-12-09 14:47:07 +00:00
|
|
|
|
2022-12-09 14:59:27 +00:00
|
|
|
// Getters
|
|
|
|
pos_t getPosition();
|
2022-12-09 14:47:07 +00:00
|
|
|
|
2022-12-09 14:33:03 +00:00
|
|
|
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;
|
|
|
|
|
2022-12-09 14:59:27 +00:00
|
|
|
pos_t m_curPos;
|
2022-12-09 14:33:03 +00:00
|
|
|
|
|
|
|
void m_lcdSendData(char data);
|
|
|
|
void m_lcdSendCmnd(char cmnd);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // floatpump
|
|
|
|
|
|
|
|
#endif //FLOATPUMP_LCD_I2C_DRIVER_H
|