Added initial interfaces and some sensors implementing them

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Stefanescu
2018-06-12 18:46:49 +03:00
committed by Mihai Tudor Panu
parent 6bf21a23e7
commit f035470822
102 changed files with 1183 additions and 182 deletions

View File

@ -81,7 +81,7 @@ SI1132::SI1132 (int bus) {
// Reset chip to defaults
status = reset();
if (status != mraa::SUCCESS)
UPM_THROW("config failure");
throw std::runtime_error(std::string(__FUNCTION__) + ": config failure");
}
SI1132::~SI1132() {
@ -138,7 +138,7 @@ mraa::Result SI1132::reset() {
uint16_t SI1132::getVisibleRaw() {
status = runCommand(SI1132_COMMAND_ALS_FORCE);
if (status != mraa::SUCCESS)
UPM_THROW("command failed");
throw std::runtime_error(std::string(__FUNCTION__) + ": command failed");
return i2c->readWordReg(SI1132_REG_ALS_VIS_DATA0);
}
@ -152,6 +152,9 @@ double SI1132::getVisibleLux() {
return static_cast<double>(rawValue);
}
float SI1132::getLuminance() {
return getVisibleLux();
}
mraa::Result SI1132::clearResponseRegister()
{

View File

@ -25,7 +25,7 @@
#include <string>
#include "mraa/i2c.hpp"
#include "interfaces/iLightSensor.hpp"
#include <interfaces/iLight.hpp>
namespace upm {
@ -56,7 +56,7 @@ namespace upm {
*
* @snippet si1132.cxx Interesting
*/
class SI1132 : public ILightSensor {
class SI1132 : virtual public iLight {
public:
/**
* Instanciates a Si1132 object
@ -80,6 +80,13 @@ class SI1132 : public ILightSensor {
*/
double getVisibleLux();
/**
* Gets the luminance value from the sensor
*
* @return The measured light intensity value in Lux
*/
virtual float getLuminance();
virtual const char* getModuleName() { return "si1132"; }
private: