mirror of
https://github.com/eclipse/upm.git
synced 2025-07-04 10:51:12 +03:00
mraa: change all existing code to use libmraa.
* Made CMake depend on 0.4 libmraa Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
@ -33,7 +33,7 @@
|
||||
using namespace upm;
|
||||
|
||||
Lcm1602::Lcm1602(int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
usleep(50000);
|
||||
expandWrite(LCD_BACKLIGHT);
|
||||
@ -69,18 +69,18 @@ Lcm1602::~Lcm1602 () {
|
||||
* virtual area
|
||||
* **************
|
||||
*/
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::write (std::string msg) {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
for (std::string::size_type i = 0; i < msg.size(); ++i) {
|
||||
error = send (msg[i], LCD_RS);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::setCursor (int row, int column) {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
int row_addr[] = { 0x80, 0xc0, 0x14, 0x54};
|
||||
uint8_t offset = ((column % 16) + row_addr[row]);
|
||||
@ -88,12 +88,12 @@ Lcm1602::setCursor (int row, int column) {
|
||||
return send (LCD_CMD | offset, 0);
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::clear () {
|
||||
return send(LCD_CLEARDISPLAY, 0);
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::home () {
|
||||
return send(LCD_RETURNHOME, 0);
|
||||
}
|
||||
@ -103,9 +103,9 @@ Lcm1602::home () {
|
||||
* private area
|
||||
* **************
|
||||
*/
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::send (uint8_t value, int mode) {
|
||||
maa_result_t ret = MAA_SUCCESS;
|
||||
mraa_result_t ret = MRAA_SUCCESS;
|
||||
uint8_t h = value & 0xf0;
|
||||
uint8_t l = (value << 4) & 0xf0;
|
||||
ret = write4bits(h | mode);
|
||||
@ -113,26 +113,26 @@ Lcm1602::send (uint8_t value, int mode) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::write4bits(uint8_t value)
|
||||
{
|
||||
maa_result_t ret = MAA_SUCCESS;
|
||||
mraa_result_t ret = MRAA_SUCCESS;
|
||||
ret = expandWrite(value);
|
||||
ret = pulseEnable(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::expandWrite(uint8_t value)
|
||||
{
|
||||
uint8_t buffer = value | LCD_BACKLIGHT;
|
||||
return maa_i2c_write_byte(m_i2c_lcd_control, buffer);
|
||||
return mraa_i2c_write_byte(m_i2c_lcd_control, buffer);
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
Lcm1602::pulseEnable(uint8_t value)
|
||||
{
|
||||
maa_result_t ret = MAA_SUCCESS;
|
||||
mraa_result_t ret = MRAA_SUCCESS;
|
||||
ret = expandWrite(value | LCD_EN);
|
||||
usleep(1);
|
||||
ret = expandWrite(value & ~LCD_EN);
|
||||
|
Reference in New Issue
Block a user