FEATURE: converted driver into singleton (only one display possible and necessary)
This commit is contained in:
parent
ece7ecf905
commit
e019c23620
@ -11,9 +11,24 @@ namespace floatpump{
|
|||||||
|
|
||||||
class LCD_I2C_Driver {
|
class LCD_I2C_Driver {
|
||||||
|
|
||||||
|
private:
|
||||||
|
LCD_I2C_Driver(I2C_HandleTypeDef &handle, uint16_t displayAddr);
|
||||||
|
|
||||||
|
// Disable following constructors
|
||||||
|
LCD_I2C_Driver(LCD_I2C_Driver const&);
|
||||||
|
void operator=(LCD_I2C_Driver const&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LCD_I2C_Driver(I2C_HandleTypeDef &handle, uint16_t displayAddr, uint8_t rows = 4, uint8_t cols = 20)
|
static LCD_I2C_Driver& getInstance(I2C_HandleTypeDef &handle, uint16_t displayAddr)
|
||||||
: m_handle(handle), m_displayAddr(displayAddr) {};
|
{
|
||||||
|
static LCD_I2C_Driver instance(handle, (uint16_t) displayAddr);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
//TODO: fix this
|
||||||
|
//LCD_I2C_Driver(LCD_I2C_Driver const&) = delete;
|
||||||
|
//void operator=(LCD_I2C_Driver const&) = delete;
|
||||||
|
|
||||||
// Functions sending text
|
// Functions sending text
|
||||||
void LCDSendCString(char *str);
|
void LCDSendCString(char *str);
|
||||||
@ -59,7 +74,6 @@ namespace floatpump{
|
|||||||
void m_lcdSendCmnd(char cmnd);
|
void m_lcdSendCmnd(char cmnd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // floatpump
|
} // floatpump
|
||||||
|
|
||||||
#endif //FLOATPUMP_LCD_I2C_DRIVER_H
|
#endif //FLOATPUMP_LCD_I2C_DRIVER_H
|
||||||
|
@ -39,7 +39,11 @@ namespace floatpump {
|
|||||||
HAL_I2C_Master_Transmit(&m_handle, m_displayAddr, (uint8_t *) data_t, 4, 100);
|
HAL_I2C_Master_Transmit(&m_handle, m_displayAddr, (uint8_t *) data_t, 4, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCD_I2C_Driver::LCDInitialize() {
|
LCD_I2C_Driver::LCD_I2C_Driver(I2C_HandleTypeDef &handle, uint16_t displayAddr) {
|
||||||
|
m_handle = handle;
|
||||||
|
m_displayAddr = displayAddr;
|
||||||
|
|
||||||
|
|
||||||
// Initialization by Instruction (from HD44780U Datasheet)
|
// Initialization by Instruction (from HD44780U Datasheet)
|
||||||
HAL_Delay(50); // wait for >40ms
|
HAL_Delay(50); // wait for >40ms
|
||||||
m_lcdSendCmnd(0x30);
|
m_lcdSendCmnd(0x30);
|
||||||
|
Loading…
Reference in New Issue
Block a user