Simplify the OLED initialisation.

This commit is contained in:
Jonathan Naylor 2021-04-11 20:43:28 +01:00
parent a3e0ad82e2
commit 4f3e6935d2
4 changed files with 5 additions and 11 deletions

View File

@ -30,7 +30,7 @@ CI2C3::CI2C3()
{ {
} }
bool CI2C3::init() void CI2C3::init()
{ {
// Enable I2C3 // Enable I2C3
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C3, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C3, ENABLE);
@ -73,8 +73,6 @@ bool CI2C3::init()
// I2C Peripheral Enable // I2C Peripheral Enable
I2C_Cmd(I2C3, ENABLE); I2C_Cmd(I2C3, ENABLE);
return true;
} }
uint8_t CI2C3::write(uint8_t addr, const uint8_t* data, uint16_t length) uint8_t CI2C3::write(uint8_t addr, const uint8_t* data, uint16_t length)

2
I2C3.h
View File

@ -33,7 +33,7 @@ class CI2C3 {
public: public:
CI2C3(); CI2C3();
bool init(); void init();
uint8_t write(uint8_t addr, const uint8_t* data, uint16_t length); uint8_t write(uint8_t addr, const uint8_t* data, uint16_t length);

View File

@ -313,11 +313,9 @@ m_oledBuffer(NULL)
clear(); clear();
} }
bool CI2COLED::init() void CI2COLED::init()
{ {
bool ret = m_i2c.init(); m_i2c.init();
if (!ret)
return false;
// Initialise the VG-6432TSWEG02 OLED display // Initialise the VG-6432TSWEG02 OLED display
sendCommand(0xAEU); /*display off*/ sendCommand(0xAEU); /*display off*/
@ -352,8 +350,6 @@ bool CI2COLED::init()
sendCommand(0x8DU, 0x10U); /*set charge pump enable*/ sendCommand(0x8DU, 0x10U); /*set charge pump enable*/
sendCommand(0xAFU); /*display ON*/ sendCommand(0xAFU); /*display ON*/
return true;
} }
void CI2COLED::setMode(int state) void CI2COLED::setMode(int state)

View File

@ -29,7 +29,7 @@ class CI2COLED {
public: public:
CI2COLED(); CI2COLED();
bool init(); void init();
void setMode(int state); void setMode(int state);