mirror of
https://github.com/eclipse/upm.git
synced 2025-07-12 06:41:12 +03:00
i2clcd: Reformat the lcd source code
Reformatted to prepare for improving the error handling. This reformatting was done using clang-format. Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
3abd3a5ee9
commit
bb59d5db7a
@ -29,7 +29,8 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
I2CLcd::I2CLcd (int bus, int lcdAddress) {
|
||||
I2CLcd::I2CLcd(int bus, int lcdAddress)
|
||||
{
|
||||
m_lcd_control_address = lcdAddress;
|
||||
m_bus = bus;
|
||||
|
||||
@ -42,13 +43,15 @@ I2CLcd::I2CLcd (int bus, int lcdAddress) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::write (int row, int column, std::string msg) {
|
||||
setCursor (row, column);
|
||||
write (msg);
|
||||
I2CLcd::write(int row, int column, std::string msg)
|
||||
{
|
||||
setCursor(row, column);
|
||||
write(msg);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::createChar(uint8_t charSlot, uint8_t charData[]) {
|
||||
I2CLcd::createChar(uint8_t charSlot, uint8_t charData[])
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
charSlot &= 0x07; // only have 8 positions we can set
|
||||
error = i2Cmd(m_i2c_lcd_control, LCD_SETCGRAMADDR | (charSlot << 3));
|
||||
@ -62,39 +65,49 @@ I2CLcd::createChar(uint8_t charSlot, uint8_t charData[]) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::close() {
|
||||
I2CLcd::close()
|
||||
{
|
||||
return mraa_i2c_stop(m_i2c_lcd_control);
|
||||
}
|
||||
|
||||
std::string
|
||||
I2CLcd::name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::i2cReg (mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t value) {
|
||||
I2CLcd::i2cReg(mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t value)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
uint8_t data[2] = { addr, value };
|
||||
error = mraa_i2c_address (ctx, deviceAdress);
|
||||
error = mraa_i2c_write (ctx, data, 2);
|
||||
error = mraa_i2c_address(ctx, deviceAdress);
|
||||
error = mraa_i2c_write(ctx, data, 2);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::i2Cmd (mraa_i2c_context ctx, uint8_t value) {
|
||||
I2CLcd::i2Cmd(mraa_i2c_context ctx, uint8_t value)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
uint8_t data[2] = { LCD_CMD, value };
|
||||
error = mraa_i2c_address (ctx, m_lcd_control_address);
|
||||
error = mraa_i2c_write (ctx, data, 2);
|
||||
error = mraa_i2c_address(ctx, m_lcd_control_address);
|
||||
error = mraa_i2c_write(ctx, data, 2);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::i2cData (mraa_i2c_context ctx, uint8_t value) {
|
||||
I2CLcd::i2cData(mraa_i2c_context ctx, uint8_t value)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
uint8_t data[2] = { LCD_DATA, value };
|
||||
error = mraa_i2c_address (ctx, m_lcd_control_address);
|
||||
error = mraa_i2c_write (ctx, data, 2);
|
||||
error = mraa_i2c_address(ctx, m_lcd_control_address);
|
||||
error = mraa_i2c_write(ctx, data, 2);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
Reference in New Issue
Block a user