mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
AT42QT1070: Add string based constructor for QTouch
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
This commit is contained in:
parent
60a5500260
commit
ae55df8b75
@ -62,6 +62,32 @@ AT42QT1070::AT42QT1070(int bus, uint8_t address)
|
|||||||
m_overflow = false;
|
m_overflow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AT42QT1070::AT42QT1070(std::string initStr) : mraaIo(initStr)
|
||||||
|
{
|
||||||
|
mraa_io_descriptor* descs = mraaIo.getMraaDescriptors();
|
||||||
|
|
||||||
|
if(!descs->i2cs) {
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_i2c_init() failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( !(m_i2c = descs->i2cs[0]) ) {
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_i2c_init() failed");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readChipID() != 0x2E) {
|
||||||
|
throw std::runtime_error("Chip ID does not match the expected value (2Eh)");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_buttonStates = 0;
|
||||||
|
m_calibrating = false;
|
||||||
|
m_overflow = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
AT42QT1070::~AT42QT1070()
|
AT42QT1070::~AT42QT1070()
|
||||||
{
|
{
|
||||||
mraa_i2c_stop(m_i2c);
|
mraa_i2c_stop(m_i2c);
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <mraa/i2c.h>
|
#include <mraa/i2c.h>
|
||||||
|
#include <mraa/initio.hpp>
|
||||||
|
|
||||||
#define AT42QT1070_I2C_BUS 0
|
#define AT42QT1070_I2C_BUS 0
|
||||||
#define AT42QT1070_DEFAULT_I2C_ADDR 0x1b
|
#define AT42QT1070_DEFAULT_I2C_ADDR 0x1b
|
||||||
@ -149,6 +150,13 @@ class AT42QT1070
|
|||||||
*/
|
*/
|
||||||
AT42QT1070(int bus, uint8_t address = AT42QT1070_DEFAULT_I2C_ADDR);
|
AT42QT1070(int bus, uint8_t address = AT42QT1070_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates AT42QT1070 QTouch Sensor based on a given string.
|
||||||
|
*
|
||||||
|
* @param initStr string containing specific information for AT42QT1070 initialization.
|
||||||
|
*/
|
||||||
|
AT42QT1070(std::string initStr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AT42QT1070 destructor
|
* AT42QT1070 destructor
|
||||||
*/
|
*/
|
||||||
@ -309,6 +317,7 @@ class AT42QT1070
|
|||||||
bool m_overflow;
|
bool m_overflow;
|
||||||
|
|
||||||
mraa_i2c_context m_i2c;
|
mraa_i2c_context m_i2c;
|
||||||
|
mraa::MraaIo mraaIo;
|
||||||
uint8_t m_addr;
|
uint8_t m_addr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user