i2clcd: use the mraa C++ API instead of the C API

Rewrite the i2c module to be based around the MRAA C++ API,
since this makes resource management easier inside of the UPM
C++ classes.

i2clcd.{h,cxx}: remove the close() function. This now automatically gets
called when the object goes out of scope, inside the destructor.

examples/i2clcd: fix C++/Python/Javascript examples that explicitly called the close function.
The I2c context now gets called by the destructor of the sensor class. This
happens when the object goes out of scope or when it gets deleted, if the
object was created using the new keyword, as is the case here.

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:
Wouter van Verre
2015-04-20 14:15:41 +01:00
committed by Mihai Tudor Panu
parent 53b58225a4
commit 31c4f470fe
17 changed files with 130 additions and 154 deletions

View File

@ -24,7 +24,7 @@
#pragma once
#include <string>
#include <mraa/i2c.h>
#include <mraa/i2c.hpp>
namespace upm
{
@ -92,13 +92,13 @@ class I2CLcd
virtual mraa_result_t home() = 0;
virtual mraa_result_t createChar(uint8_t charSlot, uint8_t charData[]);
mraa_result_t close();
std::string name();
protected:
std::string m_name;
int m_lcd_control_address;
int m_bus;
mraa_i2c_context m_i2c_lcd_control;
mraa::I2c m_i2c_lcd_control;
};
}