mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 17:30:01 +03:00
interfaces: Removed isConfigured() from IModuleStaus
Signed-off-by: Henry Bruce <henry.bruce@intel.com> Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
parent
f268437cd5
commit
9bc3d2ded0
@ -53,11 +53,6 @@ ADS1015::ADS1015(int bus, uint8_t address, float vref) : ADS1X15(bus, address) {
|
||||
|
||||
ADS1015::~ADS1015(){};
|
||||
|
||||
bool
|
||||
ADS1015::isConfigured() {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char*
|
||||
ADS1015::getModuleName() {
|
||||
return m_name.c_str();
|
||||
|
@ -165,13 +165,6 @@ namespace upm {
|
||||
*/
|
||||
unsigned int getResolutionInBits();
|
||||
|
||||
/**
|
||||
* Returns whether the sensor is detected and correctly configured.
|
||||
*
|
||||
* @return true if is detected and correctly configured, otherwise false
|
||||
*/
|
||||
bool isConfigured();
|
||||
|
||||
/**
|
||||
* Returns module name
|
||||
*
|
||||
|
@ -80,18 +80,6 @@ BME280::~BME280() {
|
||||
delete m_i2c;
|
||||
}
|
||||
|
||||
bool
|
||||
BME280::isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BME280::isConfigured() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This function is an example for reading sensor temperature
|
||||
* \param: None
|
||||
* \return: compensated temperature
|
||||
|
@ -31,9 +31,7 @@ class BME280 : public ITemperatureSensor, public IHumiditySensor, public IPressu
|
||||
* @param devAddr address of used i2c device
|
||||
* @param mode BME280 mode
|
||||
*/
|
||||
BME280();
|
||||
//BME280 (int bus, int devAddr= 0x77 , uint8_t mode = 0x03 );
|
||||
BME280 (int bus, int devAddr = BME280_I2C_ADDRESS1);
|
||||
BME280 (int bus, int devAddr = BME280_I2C_ADDRESS1);
|
||||
|
||||
/**
|
||||
* BME280 object destructor, basicaly it close i2c connection.
|
||||
@ -79,41 +77,32 @@ class BME280 : public ITemperatureSensor, public IHumiditySensor, public IPressu
|
||||
/**
|
||||
* Return temperature
|
||||
*/
|
||||
int32_t getTemperatureInternal(void);
|
||||
int32_t getTemperatureInternal(void);
|
||||
|
||||
/**
|
||||
* Return pressure
|
||||
*/
|
||||
int32_t getPressureInternal(void);
|
||||
/**
|
||||
int32_t getPressureInternal(void);
|
||||
|
||||
/**
|
||||
* Return humidity
|
||||
*/
|
||||
int32_t getHumidityInternal(void);
|
||||
int32_t getHumidityInternal(void);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return temperature
|
||||
*/
|
||||
int32_t getTemperatureRawInternal(void);
|
||||
int32_t getTemperatureRawInternal(void);
|
||||
|
||||
/**
|
||||
* Return pressure
|
||||
*/
|
||||
int32_t getPressureRawInternal(void);
|
||||
/**
|
||||
int32_t getPressureRawInternal(void);
|
||||
|
||||
/**
|
||||
* Return humidity
|
||||
*/
|
||||
int32_t getHumidityRawInternal(void);
|
||||
|
||||
|
||||
|
||||
|
||||
//int32_t getTemperatureRaw(void);
|
||||
|
||||
/**
|
||||
* Returns whether the sensor is configured.
|
||||
*/
|
||||
bool isConfigured();
|
||||
int32_t getHumidityRawInternal(void);
|
||||
|
||||
/**
|
||||
* Returns whether the correct chip is present at the given address.
|
||||
|
@ -98,7 +98,6 @@ BMP180::BMP180 (int bus, int devAddr, uint8_t mode) {
|
||||
m_name = "BMP180";
|
||||
m_controlAddr = devAddr;
|
||||
m_bus = bus;
|
||||
configured = false;
|
||||
|
||||
m_i2c = new mraa::I2c(m_bus);
|
||||
|
||||
@ -113,7 +112,6 @@ BMP180::BMP180 (int bus, int devAddr, uint8_t mode) {
|
||||
UPM_THROW("Init failed");
|
||||
|
||||
getTemperatureCelcius();
|
||||
configured = true;
|
||||
}
|
||||
|
||||
BMP180::~BMP180() {
|
||||
@ -286,7 +284,3 @@ BMP180::isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BMP180::isConfigured() {
|
||||
return configured;
|
||||
}
|
||||
|
@ -100,16 +100,11 @@ class BMP180 : public IPressureSensor, public ITemperatureSensor {
|
||||
*/
|
||||
int getTemperatureCelcius();
|
||||
|
||||
/**
|
||||
* Returns whether the sensor is configured.
|
||||
*/
|
||||
bool isConfigured();
|
||||
|
||||
/**
|
||||
* Returns whether the correct chip is present at the given address.
|
||||
*/
|
||||
bool isAvailable();
|
||||
const char* getModuleName() { return "bmp180"; }
|
||||
const char* getModuleName() { return m_name.c_str(); }
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
@ -125,8 +120,6 @@ class BMP180 : public IPressureSensor, public ITemperatureSensor {
|
||||
|
||||
int32_t b5;
|
||||
|
||||
bool configured;
|
||||
|
||||
bool getCalibrationData();
|
||||
};
|
||||
|
||||
|
@ -93,7 +93,8 @@ BMPX8X::getPressure () {
|
||||
B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling );
|
||||
|
||||
if (B7 < 0x80000000) {
|
||||
p = (B7 * 2) / B4;
|
||||
p = (B7 * 2) / B4
|
||||
;
|
||||
} else {
|
||||
p = (B7 / B4) * 2;
|
||||
}
|
||||
@ -169,6 +170,18 @@ BMPX8X::getAltitude (float sealevelPressure) {
|
||||
return altitude;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
BMPX8X::getTemperatureCelcius() {
|
||||
return static_cast<int>(getTemperature() + 0.5);
|
||||
}
|
||||
|
||||
const char*
|
||||
BMPX8X::getModuleName() {
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
BMPX8X::computeB5(int32_t UT) {
|
||||
int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <math.h>
|
||||
#include "upm/iTemperatureSensor.h"
|
||||
|
||||
#define ADDR 0x77 // device address
|
||||
|
||||
@ -88,7 +89,7 @@ namespace upm {
|
||||
* @snippet bmpx8x.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMPX8X {
|
||||
class BMPX8X : public ITemperatureSensor {
|
||||
public:
|
||||
/**
|
||||
* Instantiates a BMPX8X object
|
||||
@ -141,6 +142,19 @@ class BMPX8X {
|
||||
*/
|
||||
float getAltitude (float sealevelPressure = 101325);
|
||||
|
||||
/**
|
||||
* Return latest calculated temperature value in Celcius
|
||||
* See ITemperatureSensor
|
||||
*/
|
||||
int getTemperatureCelcius();
|
||||
|
||||
/**
|
||||
* Returns name of module. This is the string in library name after libupm_
|
||||
|
||||
* @return name of module
|
||||
*/
|
||||
const char* getModuleName();
|
||||
|
||||
/**
|
||||
* Calculates B5 (check the spec for more information)
|
||||
*
|
||||
|
@ -27,11 +27,6 @@ DS1808LC::~DS1808LC()
|
||||
}
|
||||
|
||||
|
||||
bool DS1808LC::isConfigured()
|
||||
{
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
||||
bool DS1808LC::isPowered()
|
||||
{
|
||||
return static_cast<bool>(MraaUtils::getGpio(pinPower));
|
||||
|
@ -57,7 +57,6 @@ public:
|
||||
~DS1808LC();
|
||||
|
||||
protected:
|
||||
bool isConfigured();
|
||||
const char* getModuleName() { return "ds1808lc"; }
|
||||
bool isPowered();
|
||||
void setPowerOn();
|
||||
|
@ -19,7 +19,7 @@ HLG150H::HLG150H(int pinRelay, int pinPWM)
|
||||
UPM_THROW("pwm init failed");
|
||||
status = pwmBrightness->enable(true);
|
||||
status = pwmBrightness->period_us(PWM_PERIOD);
|
||||
if (!isConfigured())
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("pwm config failed.");
|
||||
dutyPercent = getBrightness();
|
||||
isPoweredShadow = dutyPercent > 10;
|
||||
@ -30,12 +30,6 @@ HLG150H::~HLG150H()
|
||||
delete pwmBrightness;
|
||||
}
|
||||
|
||||
bool HLG150H::isConfigured()
|
||||
{
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void HLG150H::setPowerOn()
|
||||
{
|
||||
isPoweredShadow = true;
|
||||
@ -68,14 +62,11 @@ void HLG150H::setBrightness(int dutyPercent)
|
||||
{
|
||||
if (dutyPercent < 10)
|
||||
dutyPercent = 10;
|
||||
if (isConfigured())
|
||||
{
|
||||
int dutyUs = (PWM_PERIOD * dutyPercent) / 100;
|
||||
dutyUs = PWM_PERIOD - dutyUs;
|
||||
status = pwmBrightness->pulsewidth_us(dutyUs);
|
||||
// std::cout << "Brightness = " << dutyPercent << "%, duty = " << dutyUs << "us" << std::endl;
|
||||
}
|
||||
else
|
||||
int dutyUs = (PWM_PERIOD * dutyPercent) / 100;
|
||||
dutyUs = PWM_PERIOD - dutyUs;
|
||||
status = pwmBrightness->pulsewidth_us(dutyUs);
|
||||
// std::cout << "Brightness = " << dutyPercent << "%, duty = " << dutyUs << "us" << std::endl;
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("setBrightness failed");
|
||||
|
||||
}
|
||||
@ -83,14 +74,9 @@ void HLG150H::setBrightness(int dutyPercent)
|
||||
|
||||
int HLG150H::getBrightness()
|
||||
{
|
||||
if (isConfigured())
|
||||
{
|
||||
float duty = pwmBrightness->read();
|
||||
int dutyPercent = static_cast<int>(100.0 * (1.0 - duty) + 0.5);
|
||||
return dutyPercent;
|
||||
}
|
||||
else
|
||||
UPM_THROW("getBrightness failed");
|
||||
float duty = pwmBrightness->read();
|
||||
int dutyPercent = static_cast<int>(100.0 * (1.0 - duty) + 0.5);
|
||||
return dutyPercent;
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
~HLG150H();
|
||||
|
||||
protected:
|
||||
bool isConfigured();
|
||||
const char* getModuleName() { return "hlg150h"; }
|
||||
void setPowerOn();
|
||||
void setPowerOff();
|
||||
|
@ -110,7 +110,7 @@ LP8860::LP8860(int gpioPower, int i2cBus)
|
||||
i2c->address(LP8860_I2C_ADDR);
|
||||
if (isAvailable())
|
||||
status = mraa::SUCCESS;
|
||||
if (!isConfigured())
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("i2c config failed.");
|
||||
}
|
||||
|
||||
@ -120,11 +120,6 @@ LP8860::~LP8860()
|
||||
}
|
||||
|
||||
|
||||
bool LP8860::isConfigured()
|
||||
{
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
||||
bool LP8860::isAvailable()
|
||||
{
|
||||
bool wasPowered = true;
|
||||
@ -247,7 +242,7 @@ void LP8860::i2cWriteByte(int reg, int value)
|
||||
{
|
||||
i2c->address(LP8860_I2C_ADDR);
|
||||
status = i2c->writeReg(static_cast<uint8_t>(reg), static_cast<uint8_t>(value));
|
||||
if (!isConfigured())
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("i2cWriteByte failed");
|
||||
}
|
||||
|
||||
@ -275,7 +270,7 @@ void LP8860::i2cWriteBuffer(int reg, uint8_t* buf, int length)
|
||||
}
|
||||
else
|
||||
status = mraa::ERROR_INVALID_PARAMETER;
|
||||
if (!isConfigured())
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("i2cWriteBuffer failed");
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,6 @@ class LP8860 : public upm::ILightController
|
||||
public:
|
||||
LP8860(int gpioPower, int i2cBus);
|
||||
~LP8860();
|
||||
bool isConfigured();
|
||||
const char* getModuleName() { return "lp8860"; }
|
||||
bool isPowered();
|
||||
void setPowerOn();
|
||||
|
@ -40,7 +40,7 @@ MAX44009::MAX44009 (int bus, int devAddr) {
|
||||
// Reset chip to defaults
|
||||
status = mraa::SUCCESS;
|
||||
reset();
|
||||
if (!isConfigured())
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("config failure");
|
||||
}
|
||||
|
||||
@ -92,8 +92,3 @@ MAX44009::getVisibleLux() {
|
||||
return pow((double)2,(double)exponent) * mantissa * 0.045;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MAX44009::isConfigured() {
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
@ -130,10 +130,6 @@ class MAX44009 : public ILightSensor {
|
||||
*/
|
||||
double getVisibleLux();
|
||||
|
||||
/**
|
||||
* Returns whether the sensor is configured.
|
||||
*/
|
||||
bool isConfigured();
|
||||
const char* getModuleName() { return "max44009"; }
|
||||
|
||||
private:
|
||||
|
@ -80,7 +80,7 @@ SI1132::SI1132 (int bus) {
|
||||
|
||||
// Reset chip to defaults
|
||||
status = reset();
|
||||
if (!isConfigured())
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("config failure");
|
||||
}
|
||||
|
||||
@ -154,10 +154,6 @@ double SI1132::getVisibleLux() {
|
||||
return static_cast<double>(rawValue);
|
||||
}
|
||||
|
||||
bool SI1132::isConfigured() {
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
mraa::Result SI1132::clearResponseRegister()
|
||||
{
|
||||
|
@ -79,10 +79,6 @@ class SI1132 : public ILightSensor {
|
||||
*/
|
||||
double getVisibleLux();
|
||||
|
||||
/**
|
||||
* Returns whether the sensor is configured.
|
||||
*/
|
||||
bool isConfigured();
|
||||
const char* getModuleName() { return "si1132"; }
|
||||
|
||||
private:
|
||||
|
@ -158,10 +158,6 @@ uint16_t SI7005::getMeasurement(uint8_t configValue) {
|
||||
return rawData;
|
||||
}
|
||||
|
||||
bool
|
||||
SI7005::isConfigured() {
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
||||
bool
|
||||
SI7005::isAvailable( )
|
||||
|
@ -93,10 +93,6 @@ class SI7005 : public ITemperatureSensor, public IHumiditySensor {
|
||||
* Get relative humidity measurement.
|
||||
*/
|
||||
int getHumidityRelative ();
|
||||
/**
|
||||
* Returns whether the sensor is configured.
|
||||
*/
|
||||
bool isConfigured();
|
||||
|
||||
/**
|
||||
* Returns sensor module name
|
||||
|
@ -54,7 +54,7 @@ T6713::T6713 (int bus)
|
||||
i2c = new mraa::I2c(bus);
|
||||
status = i2c->address(T6713_ADDR);
|
||||
uint16_t firmwareRevision = getFirmwareRevision();
|
||||
if (!isConfigured())
|
||||
if (firmwareRevision != mraa::SUCCESS)
|
||||
UPM_THROW("config failure");
|
||||
}
|
||||
|
||||
@ -63,11 +63,6 @@ T6713::~T6713()
|
||||
delete i2c;
|
||||
}
|
||||
|
||||
bool T6713::isConfigured()
|
||||
{
|
||||
return status == mraa::SUCCESS;
|
||||
}
|
||||
|
||||
const char* T6713::getModuleName()
|
||||
{
|
||||
return "t6713";
|
||||
|
@ -119,11 +119,6 @@ class T6713 : public ICO2Sensor {
|
||||
*/
|
||||
~T6713 ();
|
||||
|
||||
/**
|
||||
* Returns whether the sensor is configured.
|
||||
*/
|
||||
bool isConfigured();
|
||||
|
||||
/**
|
||||
* Returns sensor module name
|
||||
*/
|
||||
|
@ -37,15 +37,6 @@ namespace upm
|
||||
class IModuleStatus
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Determines if sensor module is configured correctly
|
||||
* e.g. if it uses i2c communication can it configure registers
|
||||
* for correct operation.
|
||||
*
|
||||
* @return true if correctly configured, false it not
|
||||
*/
|
||||
virtual bool isConfigured() = 0;
|
||||
|
||||
/**
|
||||
* Returns name of module. This is the string in library name after libupm_
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user