lcm1602,jhd1313m1: throw exception(s) on fatal errors

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson 2015-09-09 12:18:52 -06:00 committed by Mihai Tudor Panu
parent fbbc0de6fb
commit f29141087e
2 changed files with 5 additions and 2 deletions

View File

@ -42,7 +42,8 @@ Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress)
mraa::Result ret = m_i2c_lcd_rgb.address(m_rgb_address);
if (ret != mraa::SUCCESS) {
fprintf(stderr, "Messed up i2c bus\n");
throw std::invalid_argument(std::string(__FUNCTION__) +
": I2c.address() failed");
}
usleep(50000);

View File

@ -31,6 +31,7 @@
*/
#include <string>
#include <stdexcept>
#include <unistd.h>
#include "hd44780_bits.h"
@ -51,7 +52,8 @@ Lcm1602::Lcm1602(int bus_in, int addr_in, bool isExpander) :
error = m_i2c_lcd_control->address(m_lcd_control_address);
if (error != mraa::SUCCESS) {
fprintf(stderr, "Failed to initialize i2c bus\n");
throw std::invalid_argument(std::string(__FUNCTION__) +
": I2c.address() failed");
return;
}