mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
Merge 3572a176c2d81ea60c37395f5b5fa57acbb7b3f7 into 9a959b578cb69a5f0766f415da640bcbd3ebabb1
This commit is contained in:
commit
e12edf8773
28
examples/c++/iLight-sample.cxx
Normal file
28
examples/c++/iLight-sample.cxx
Normal file
@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "apds9002.hpp"
|
||||
#include "bh1750.hpp"
|
||||
#include "max44009.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
vector<unique_ptr<iLight>> lightSensors;
|
||||
|
||||
// Populate list of light sensors
|
||||
lightSensors.push_back(unique_ptr<iLight>(new APDS9002(0)));
|
||||
lightSensors.push_back(unique_ptr<iLight>(new BH1750()));
|
||||
lightSensors.push_back(unique_ptr<iLight>(new MAX44009(1)));
|
||||
|
||||
// Measure luminance level from all 3 individual sensors
|
||||
for (auto& sensor : lightSensors) {
|
||||
sensor->getLuminance();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
26
examples/c++/iTemperature-sample.cxx
Normal file
26
examples/c++/iTemperature-sample.cxx
Normal file
@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "lm35.hpp"
|
||||
#include "abp.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
vector<iTemperature*> tempSensors {new LM35(0), new ABP(0, ABP_DEFAULT_ADDRESS)};
|
||||
|
||||
for (auto sensor : tempSensors) {
|
||||
cout << sensor->getTemperature() << endl;
|
||||
}
|
||||
|
||||
for (iTemperature* sensor : tempSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
|
||||
tempSensors.clear();
|
||||
|
||||
return 0;
|
||||
}
|
@ -62,7 +62,7 @@ getLightSensor()
|
||||
int
|
||||
main()
|
||||
{
|
||||
upm::ILightSensor* lightSensor = getLightSensor();
|
||||
/*upm::ILightSensor* lightSensor = getLightSensor();
|
||||
if (lightSensor == NULL) {
|
||||
std::cout << "Light sensor not detected" << std::endl;
|
||||
return 1;
|
||||
@ -77,7 +77,7 @@ main()
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
delete lightSensor;
|
||||
delete lightSensor;*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,12 @@ main()
|
||||
|
||||
// Instantiate a LM35 on analog pin A0, with a default analog
|
||||
// reference voltage of 5.0
|
||||
upm::LM35 sensor(0);
|
||||
upm::iTemperature* sensor = new upm::LM35(0);
|
||||
|
||||
// Every half second, sample the sensor and output the temperature
|
||||
|
||||
while (shouldRun) {
|
||||
cout << "Temperature: " << sensor.getTemperature() << " C" << endl;
|
||||
cout << "Temperature: " << sensor->getTemperature() << " C" << endl;
|
||||
|
||||
upm_delay_us(500000);
|
||||
}
|
||||
@ -61,6 +61,7 @@ main()
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
38
include/interfaces/iCollision.hpp
Normal file
38
include/interfaces/iCollision.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Collision Sensors
|
||||
*/
|
||||
class iCollision
|
||||
{
|
||||
public:
|
||||
virtual ~iCollision() {}
|
||||
virtual bool isColliding() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iDistance.hpp
Normal file
38
include/interfaces/iDistance.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Distance Measuring Sensors
|
||||
*/
|
||||
class iDistance
|
||||
{
|
||||
public:
|
||||
virtual ~iDistance() {}
|
||||
virtual int getDistance() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iDistanceInterrupter.hpp
Normal file
38
include/interfaces/iDistanceInterrupter.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Distance Interrupter Sensors
|
||||
*/
|
||||
class iDistanceInterrupter
|
||||
{
|
||||
public:
|
||||
virtual ~iDistanceInterrupter() {}
|
||||
virtual bool objectDetected() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iHallEffect.hpp
Normal file
38
include/interfaces/iHallEffect.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Hall Effect Sensors
|
||||
*/
|
||||
class iHallEffect
|
||||
{
|
||||
public:
|
||||
virtual ~iHallEffect() {}
|
||||
virtual bool magnetDetected() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iHumidity.hpp
Normal file
38
include/interfaces/iHumidity.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Humidity Measuring Sensors
|
||||
*/
|
||||
class iHumidity
|
||||
{
|
||||
public:
|
||||
virtual ~iHumidity() {}
|
||||
virtual float getHumidity() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iLight.hpp
Normal file
38
include/interfaces/iLight.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Luminance Measuring Sensors
|
||||
*/
|
||||
class iLight
|
||||
{
|
||||
public:
|
||||
virtual ~iLight() {}
|
||||
virtual float getLuminance() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iMoisture.hpp
Normal file
38
include/interfaces/iMoisture.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Moisture Measuring Sensors
|
||||
*/
|
||||
class iMoisture
|
||||
{
|
||||
public:
|
||||
virtual ~iMoisture() {}
|
||||
virtual int getMoisture() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iMotion.hpp
Normal file
38
include/interfaces/iMotion.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Motion Sensors
|
||||
*/
|
||||
class iMotion
|
||||
{
|
||||
public:
|
||||
virtual ~iMotion() {}
|
||||
virtual bool motionDetected() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iPressure.hpp
Normal file
38
include/interfaces/iPressure.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Pressure Measuring Sensors
|
||||
*/
|
||||
class iPressure
|
||||
{
|
||||
public:
|
||||
virtual ~iPressure() {}
|
||||
virtual float getPressure() = 0;
|
||||
};
|
||||
}
|
38
include/interfaces/iTemperature.hpp
Normal file
38
include/interfaces/iTemperature.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for Temperature Measuring Sensors
|
||||
*/
|
||||
class iTemperature
|
||||
{
|
||||
public:
|
||||
virtual ~iTemperature() {}
|
||||
virtual float getTemperature() = 0;
|
||||
};
|
||||
}
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/gpio.h>
|
||||
#include <interfaces/iHallEffect.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -58,7 +59,7 @@ namespace upm {
|
||||
* An example demonstrating the use of an interrupt handler to count pulses
|
||||
* @snippet a110x-intr.cxx Interesting
|
||||
*/
|
||||
class A110X {
|
||||
class A110X : virtual public iHallEffect {
|
||||
public:
|
||||
/**
|
||||
* A110x digital sensor constructor
|
||||
@ -75,7 +76,7 @@ namespace upm {
|
||||
*
|
||||
* @return True if magnetic field detected
|
||||
*/
|
||||
bool magnetDetected();
|
||||
virtual bool magnetDetected();
|
||||
|
||||
/**
|
||||
* Installs an interrupt service routine (ISR) to be called when
|
||||
|
@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "abp.h"
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -59,7 +60,7 @@ namespace upm {
|
||||
* @snippet abp.cxx Interesting
|
||||
*/
|
||||
|
||||
class ABP {
|
||||
class ABP : virtual public iTemperature {
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -90,7 +91,7 @@ namespace upm {
|
||||
*
|
||||
* @return float compensated temperature value
|
||||
*/
|
||||
float getTemperature();
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* This functio has to be called before calling either of the get
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.h>
|
||||
#include <math.h>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define AM2315_NAME "am2315"
|
||||
#define AM2315_I2C_ADDRESS 0x5c
|
||||
@ -77,7 +79,7 @@ namespace upm {
|
||||
* @image html am2315.jpeg
|
||||
* @snippet am2315.cxx Interesting
|
||||
*/
|
||||
class AM2315 {
|
||||
class AM2315 : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an AM2315 object
|
||||
@ -98,15 +100,17 @@ class AM2315 {
|
||||
* Data is updated every 2 seconds - accesses occurring more often than
|
||||
* that return cached data
|
||||
*/
|
||||
float getHumidity(void);
|
||||
virtual float getHumidity(void);
|
||||
|
||||
/**
|
||||
* Gets the humidity cell temperature [degC]
|
||||
*
|
||||
* Data is updated every 2 seconds - accesses occurring more often than
|
||||
* that return cached data
|
||||
*
|
||||
* @return float compensated temperature value
|
||||
*/
|
||||
float getTemperature(void);
|
||||
virtual float getTemperature(void);
|
||||
|
||||
/**
|
||||
* Gets the humidity cell temperature [degF]
|
||||
|
@ -32,7 +32,7 @@ using namespace upm;
|
||||
|
||||
APDS9002::APDS9002(int pin)
|
||||
{
|
||||
if ( !(m_aio = mraa_aio_init(pin)) )
|
||||
if ( !(m_aio = mraa_aio_init(pin)) )
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_aio_init() failed, invalid pin?");
|
||||
@ -49,3 +49,8 @@ int APDS9002::value()
|
||||
{
|
||||
return mraa_aio_read(m_aio);
|
||||
}
|
||||
|
||||
float APDS9002::getLuminance()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.h>
|
||||
#include <interfaces/iLight.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -52,7 +53,7 @@ namespace upm {
|
||||
* @snippet apds9002.cxx Interesting
|
||||
*/
|
||||
|
||||
class APDS9002 {
|
||||
class APDS9002 : virtual public iLight {
|
||||
public:
|
||||
/**
|
||||
* APDS-9002 luminance sensor constructor
|
||||
@ -71,6 +72,13 @@ namespace upm {
|
||||
*/
|
||||
int value();
|
||||
|
||||
/**
|
||||
* Gets the luminance value from the sensor
|
||||
*
|
||||
* @return The measured light intensity value in Lux
|
||||
*/
|
||||
virtual float getLuminance();
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
};
|
||||
|
@ -59,6 +59,11 @@ float BH1750::getLux()
|
||||
return lux;
|
||||
}
|
||||
|
||||
float BH1750::getLuminance()
|
||||
{
|
||||
return getLux();
|
||||
}
|
||||
|
||||
void BH1750::powerUp()
|
||||
{
|
||||
if (bh1750_power_up(m_bh1750) != UPM_SUCCESS)
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <interfaces/iLight.hpp>
|
||||
|
||||
#include "bh1750.h"
|
||||
|
||||
@ -57,13 +58,13 @@ namespace upm {
|
||||
* @snippet bh1750.cxx Interesting
|
||||
*/
|
||||
|
||||
class BH1750 {
|
||||
class BH1750 : virtual public iLight {
|
||||
public:
|
||||
|
||||
/**
|
||||
* BH1750 object constructor (Analog mode)
|
||||
*
|
||||
* @param bus The I2C bus to use
|
||||
* @param bus The I2C bus to use
|
||||
* @param addr The I2C address of the device
|
||||
* @param mode The mode to start operation under. One of the
|
||||
* BH1750_OPMODES_T values. The default is the highest precision,
|
||||
@ -92,6 +93,13 @@ namespace upm {
|
||||
*/
|
||||
float getLux();
|
||||
|
||||
/**
|
||||
* Gets the luminance value from the sensor
|
||||
*
|
||||
* @return The measured light intensity value in Lux
|
||||
*/
|
||||
virtual float getLuminance();
|
||||
|
||||
/**
|
||||
* Power up the device.
|
||||
*/
|
||||
|
@ -48,3 +48,8 @@ bool BISS0001::value()
|
||||
{
|
||||
return biss0001_motion_detected(m_biss0001);
|
||||
}
|
||||
|
||||
bool BISS0001::motionDetected()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <interfaces/iMotion.hpp>
|
||||
#include <biss0001.h>
|
||||
|
||||
namespace upm {
|
||||
@ -57,7 +58,7 @@ namespace upm {
|
||||
* @snippet biss0001.cxx Interesting
|
||||
*/
|
||||
|
||||
class BISS0001 {
|
||||
class BISS0001 : virtual public iMotion {
|
||||
public:
|
||||
/**
|
||||
* BISS0001 motion sensor constructor
|
||||
@ -81,11 +82,11 @@ namespace upm {
|
||||
/**
|
||||
* Gets the motion value from the sensor. This is a more
|
||||
* informative method name, but we want to keep compatibility
|
||||
* with the original for now.
|
||||
* with the original for now. Implements iMotion interface.
|
||||
*
|
||||
* @return true if motion was detected, false otherwise.
|
||||
*/
|
||||
bool motionDetected() { return value(); };
|
||||
virtual bool motionDetected();
|
||||
|
||||
private:
|
||||
/* Disable implicit copy and assignment operators */
|
||||
|
@ -26,7 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "interfaces/iHumiditySensor.hpp"
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
|
||||
#include "bmp280.hpp"
|
||||
|
||||
@ -57,7 +57,7 @@ namespace upm {
|
||||
* @snippet bmp280-bme280.cxx Interesting
|
||||
*/
|
||||
|
||||
class BME280 : public BMP280, public IHumiditySensor {
|
||||
class BME280 : public BMP280, virtual public iHumidity {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ namespace upm {
|
||||
*
|
||||
* @return The relative humidity in percent.
|
||||
*/
|
||||
float getHumidity();
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Set the humidity sensor oversampling parameter. See the data
|
||||
|
@ -110,6 +110,11 @@ float BMP280::getTemperature(bool fahrenheit)
|
||||
return temperature;
|
||||
}
|
||||
|
||||
float BMP280::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
float BMP280::getPressure()
|
||||
{
|
||||
return bmp280_get_pressure(m_bmp280);
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include <string>
|
||||
#include "bmp280.h"
|
||||
|
||||
#include "interfaces/iPressureSensor.hpp"
|
||||
#include "interfaces/iTemperatureSensor.hpp"
|
||||
#include <interfaces/iPressure.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -67,7 +67,7 @@ namespace upm {
|
||||
* @snippet bmp280.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMP280 : public ITemperatureSensor, public IPressureSensor {
|
||||
class BMP280 : virtual public iPressure, virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -127,7 +127,17 @@ namespace upm {
|
||||
* Celicus. Celsius is the default.
|
||||
* @return The temperature in degrees Celsius or Fahrenheit.
|
||||
*/
|
||||
float getTemperature(bool fahrenheit=false);
|
||||
float getTemperature(bool fahrenheit);
|
||||
|
||||
/**
|
||||
* Return the current measured temperature. Note, this is not
|
||||
* ambient temperature - this is the temperature used to fine tune
|
||||
* the pressure measurement. update() must have been called prior
|
||||
* to calling this method.
|
||||
*
|
||||
* @return The temperature in degrees Celsius.
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Return the current measured pressure in Pascals (Pa). update()
|
||||
@ -135,7 +145,7 @@ namespace upm {
|
||||
*
|
||||
* @return The pressure in Pascals (Pa).
|
||||
*/
|
||||
float getPressure();
|
||||
virtual float getPressure();
|
||||
|
||||
/**
|
||||
* Set the pressure at sea level in hecto-Pascals (hPA). This
|
||||
|
@ -2,37 +2,14 @@
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%import "../interfaces/javaupm_iTemperatureSensor.i"
|
||||
%import "../interfaces/javaupm_iHumiditySensor.i"
|
||||
%import "../interfaces/javaupm_iPressureSensor.i"
|
||||
|
||||
%include "arrays_java.i";
|
||||
%include "../java_buffer.i"
|
||||
|
||||
%typemap(javaimports) SWIGTYPE %{
|
||||
import upm_interfaces.*;
|
||||
%}
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_bmp280)
|
||||
#endif
|
||||
/* END Java syntax */
|
||||
|
||||
/* BEGIN Javascript syntax ------------------------------------------------- */
|
||||
#ifdef SWIGJAVASCRIPT
|
||||
%include "iModuleStatus.hpp"
|
||||
%include "iTemperatureSensor.hpp"
|
||||
%include "iPressureSensor.hpp"
|
||||
%include "iHumiditySensor.hpp"
|
||||
#endif
|
||||
/* END Javascript syntax */
|
||||
|
||||
/* BEGIN Python syntax ----------------------------------------------------- */
|
||||
#ifdef SWIGPYTHON
|
||||
%include "iModuleStatus.hpp"
|
||||
%include "iTemperatureSensor.hpp"
|
||||
%include "iPressureSensor.hpp"
|
||||
%include "iHumiditySensor.hpp"
|
||||
#endif
|
||||
/* END Python syntax */
|
||||
|
||||
/* BEGIN Common SWIG syntax ------------------------------------------------- */
|
||||
|
@ -99,7 +99,7 @@ void BMPX8X::writeReg(uint8_t reg, uint8_t val)
|
||||
+ ": bmpx8x_write_reg() failed");
|
||||
}
|
||||
|
||||
int BMPX8X::getPressure()
|
||||
float BMPX8X::getPressure()
|
||||
{
|
||||
return bmpx8x_get_pressure(m_bmpx8x);
|
||||
}
|
||||
|
@ -32,8 +32,7 @@
|
||||
|
||||
#include "bmpx8x.h"
|
||||
|
||||
#include "interfaces/iPressureSensor.hpp"
|
||||
#include "interfaces/iTemperatureSensor.hpp"
|
||||
#include <interfaces/iPressure.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -68,7 +67,7 @@ namespace upm {
|
||||
* @snippet bmpx8x.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMPX8X : public IPressureSensor, public ITemperatureSensor {
|
||||
class BMPX8X : virtual public iPressure {
|
||||
public:
|
||||
/**
|
||||
* Instantiates a BMPX8X object
|
||||
@ -132,7 +131,7 @@ namespace upm {
|
||||
*
|
||||
* @returns The pressure in Pascals.
|
||||
*/
|
||||
int getPressure();
|
||||
virtual float getPressure();
|
||||
|
||||
/**
|
||||
* Returns the calculated temperature in Celsius. update()
|
||||
|
@ -2,19 +2,12 @@
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%import "../interfaces/javaupm_iPressureSensor.i"
|
||||
%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%}
|
||||
%import "../interfaces/javaupm_iTemperatureSensor.i"
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_bmpx8x)
|
||||
#endif
|
||||
/* END Java syntax */
|
||||
|
||||
/* BEGIN Python syntax ----------------------------------------------------- */
|
||||
#ifdef SWIGPYTHON
|
||||
%include "iModuleStatus.hpp"
|
||||
%include "iTemperatureSensor.hpp"
|
||||
%include "iPressureSensor.hpp"
|
||||
#endif
|
||||
/* END Python syntax */
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mraa/gpio.h>
|
||||
#include <interfaces/iCollision.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -42,15 +43,15 @@ namespace upm {
|
||||
* @con gpio
|
||||
*
|
||||
* @brief API for the Collision Sensor
|
||||
*
|
||||
*
|
||||
* The Collision Sensor can detect whether any
|
||||
* collision movement or vibration happens.
|
||||
* It outputs a low pulse signal when vibration is detected.
|
||||
* It outputs a low pulse signal when vibration is detected.
|
||||
*
|
||||
* @image html collision.jpg
|
||||
* @snippet collision.cxx Interesting
|
||||
*/
|
||||
class Collision {
|
||||
class Collision : virtual public iCollision {
|
||||
public:
|
||||
/**
|
||||
* Collision sensor constructor
|
||||
@ -63,11 +64,11 @@ namespace upm {
|
||||
*/
|
||||
~Collision();
|
||||
/**
|
||||
* @return bool Defines whether something is colliding with sensor
|
||||
* @return boolean value defining whether something is colliding with sensor
|
||||
*/
|
||||
bool isColliding();
|
||||
virtual bool isColliding();
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
}
|
||||
|
@ -57,6 +57,11 @@ int GroveLight::value()
|
||||
return (int) round(a);
|
||||
}
|
||||
|
||||
float GroveLight::getLuminance()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
float GroveLight::raw_value()
|
||||
{
|
||||
return (float) mraa_aio_read(m_aio);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.hpp>
|
||||
#include <interfaces/iLight.hpp>
|
||||
#include "grovebase.hpp"
|
||||
|
||||
namespace upm {
|
||||
@ -54,7 +55,7 @@ namespace upm {
|
||||
* @image html grovelight.jpg
|
||||
* @snippet grove-grovelight.cxx Interesting
|
||||
*/
|
||||
class GroveLight: public Grove {
|
||||
class GroveLight: public Grove, virtual public iLight {
|
||||
public:
|
||||
/**
|
||||
* Grove analog light sensor constructor
|
||||
@ -78,6 +79,13 @@ class GroveLight: public Grove {
|
||||
* @return Normalized light reading in lux
|
||||
*/
|
||||
int value();
|
||||
|
||||
/**
|
||||
* Gets an approximate light value, in lux, from the sensor
|
||||
*
|
||||
* @return Normalized light reading in lux
|
||||
*/
|
||||
virtual float getLuminance();
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
};
|
||||
|
@ -62,6 +62,11 @@ int GroveTemp::value ()
|
||||
return (int) round(t);
|
||||
}
|
||||
|
||||
float GroveTemp::getTemperature ()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
float GroveTemp::raw_value()
|
||||
{
|
||||
return (float) mraa_aio_read(m_aio);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <string>
|
||||
#include <mraa/aio.hpp>
|
||||
#include "grovebase.hpp"
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -54,7 +55,7 @@ namespace upm {
|
||||
* @image html grovetemp.jpg
|
||||
* @snippet grove-grovetemp.cxx Interesting
|
||||
*/
|
||||
class GroveTemp: public Grove {
|
||||
class GroveTemp: public Grove, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* Grove analog temperature sensor constructor
|
||||
@ -84,6 +85,8 @@ class GroveTemp: public Grove {
|
||||
* @return Normalized temperature in Celsius
|
||||
*/
|
||||
int value();
|
||||
|
||||
virtual float getTemperature();
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
float m_scale;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mraa/gpio.h>
|
||||
#include <interfaces/iCollision.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -43,15 +44,15 @@ namespace upm {
|
||||
* @con gpio
|
||||
*
|
||||
* @brief API for the Grove Collision Sensor
|
||||
*
|
||||
*
|
||||
* The Grove Collision Sensor can detect whether any
|
||||
* collision movement or vibration happens.
|
||||
* It outputs a low pulse signal when vibration is detected.
|
||||
* It outputs a low pulse signal when vibration is detected.
|
||||
*
|
||||
* @image html grovecollision.jpg
|
||||
* @snippet grovecollision.cxx Interesting
|
||||
*/
|
||||
class GroveCollision {
|
||||
class GroveCollision : virtual public iCollision {
|
||||
public:
|
||||
/**
|
||||
* Grove collision sensor constructor
|
||||
@ -64,11 +65,11 @@ namespace upm {
|
||||
*/
|
||||
~GroveCollision();
|
||||
/**
|
||||
* @return bool Defines whether something is colliding with sensor
|
||||
* @return boolean value defining whether something is colliding with sensor
|
||||
*/
|
||||
bool isColliding();
|
||||
virtual bool isColliding();
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
}
|
||||
|
@ -46,3 +46,8 @@ int GroveMoisture::value()
|
||||
{
|
||||
return mraa_aio_read(m_aio);
|
||||
}
|
||||
|
||||
int GroveMoisture::getMoisture()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.h>
|
||||
#include <interfaces/iMoisture.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -56,7 +57,7 @@ namespace upm {
|
||||
* @image html grovemoisture.jpg
|
||||
* @snippet grovemoisture.cxx Interesting
|
||||
*/
|
||||
class GroveMoisture {
|
||||
class GroveMoisture : virtual public iMoisture {
|
||||
public:
|
||||
/**
|
||||
* Grove analog moisture sensor constructor
|
||||
@ -75,6 +76,13 @@ namespace upm {
|
||||
*/
|
||||
int value();
|
||||
|
||||
/**
|
||||
* Gets the moisture value from the sensor
|
||||
*
|
||||
* @return Moisture reading
|
||||
*/
|
||||
virtual int getMoisture();
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
};
|
||||
|
@ -49,3 +49,9 @@ HCSR04::getDistance(HCSR04_U unit)
|
||||
{
|
||||
return hcsr04_get_distance(m_hcsr04, unit);
|
||||
}
|
||||
|
||||
int
|
||||
HCSR04::getDistance()
|
||||
{
|
||||
return getDistance(HCSR04_CM);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "hcsr04.h"
|
||||
#include <interfaces/iDistance.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -49,7 +50,7 @@ namespace upm {
|
||||
* @image html groveultrasonic.jpg
|
||||
* @snippet hcsr04.cxx Interesting
|
||||
*/
|
||||
class HCSR04 {
|
||||
class HCSR04 : virtual public iDistance {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an HCSR04 object
|
||||
@ -70,6 +71,12 @@ class HCSR04 {
|
||||
*/
|
||||
double getDistance (HCSR04_U unit);
|
||||
|
||||
/**
|
||||
* Gets the distance from the sensor
|
||||
*
|
||||
* @return distance measured in cm.
|
||||
*/
|
||||
virtual int getDistance();
|
||||
private:
|
||||
hcsr04_context m_hcsr04;
|
||||
HCSR04(const HCSR04& src) { /* do not create copied constructor */ }
|
||||
|
@ -125,6 +125,12 @@ HDC1000::getTemperature(int bSampleData)
|
||||
return (float)(m_temperature * 0.01);
|
||||
}
|
||||
|
||||
float
|
||||
HDC1000::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
float
|
||||
HDC1000::getHumidity(int bSampleData)
|
||||
{
|
||||
@ -133,3 +139,9 @@ HDC1000::getHumidity(int bSampleData)
|
||||
}
|
||||
return (float)(m_humidity * 0.01);
|
||||
}
|
||||
|
||||
float
|
||||
HDC1000::getHumidity()
|
||||
{
|
||||
return getHumidity(false);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <math.h>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define HDC1000_NAME "hdc1000"
|
||||
#define HDC1000_i2C_ADDRESS 0x43
|
||||
@ -87,7 +89,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet hdc1000.cxx Interesting
|
||||
*/
|
||||
class HDC1000 {
|
||||
class HDC1000 : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an HDC1000 object
|
||||
@ -123,7 +125,14 @@ class HDC1000 {
|
||||
* @param bSampleData Flag to read sensor
|
||||
* @return The humidity sensor temp in degC
|
||||
*/
|
||||
float getHumidity(int bSampleData = false);
|
||||
float getHumidity(int bSampleData);
|
||||
|
||||
/**
|
||||
* Get the current measured humidity [RH]
|
||||
*
|
||||
* @return The humidity sensor temp in degC
|
||||
*/
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Get the humidity cell temperature [degC]
|
||||
@ -131,7 +140,14 @@ class HDC1000 {
|
||||
* @param bSampleData Flag to read sensor
|
||||
* @return The humidity sensor temp in degC
|
||||
*/
|
||||
float getTemperature(int bSampleData = false);
|
||||
float getTemperature(int bSampleData);
|
||||
|
||||
/**
|
||||
* Get the humidity cell temperature [degC]
|
||||
*
|
||||
* @return The humidity sensor temp in degC
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -190,7 +190,8 @@ float HP20X::getPressure()
|
||||
// now read the pressure
|
||||
writeCmd(CMD_READ_P);
|
||||
|
||||
return ((float)readData() / 100.0);
|
||||
// Return result in Pa, not milibars.
|
||||
return (float)readData();
|
||||
}
|
||||
|
||||
float HP20X::getAltitude()
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <string>
|
||||
#include <mraa/common.hpp>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <interfaces/iPressure.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define HP20X_I2C_BUS 0
|
||||
#define HP20X_DEFAULT_I2C_ADDR 0x76
|
||||
@ -61,7 +63,7 @@ namespace upm {
|
||||
* @image html hp20x.jpg
|
||||
* @snippet hp20x.cxx Interesting
|
||||
*/
|
||||
class HP20X {
|
||||
class HP20X : virtual public iPressure, virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -270,14 +272,14 @@ namespace upm {
|
||||
*
|
||||
* @return Temperature
|
||||
*/
|
||||
float getTemperature();
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Returns the pressure in millibars
|
||||
*
|
||||
* @return Pressure
|
||||
*/
|
||||
float getPressure();
|
||||
virtual float getPressure();
|
||||
|
||||
/**
|
||||
* Returns the computed altitude in meters
|
||||
|
@ -99,6 +99,12 @@ HTU21D::getTemperature(int bSampleData)
|
||||
return (float)m_temperature / 1000;
|
||||
}
|
||||
|
||||
float
|
||||
HTU21D::getTemperature()
|
||||
{
|
||||
return getTemperature(0);
|
||||
}
|
||||
|
||||
float
|
||||
HTU21D::getHumidity(int bSampleData)
|
||||
{
|
||||
@ -108,6 +114,12 @@ HTU21D::getHumidity(int bSampleData)
|
||||
return (float)m_humidity / 1000;
|
||||
}
|
||||
|
||||
float
|
||||
HTU21D::getHumidity()
|
||||
{
|
||||
return getHumidity(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the compensation equation from the datasheet to correct the
|
||||
* current reading
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <math.h>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define HTU21D_NAME "htu21d"
|
||||
#define HTU21D_I2C_ADDRESS 0x40
|
||||
@ -79,7 +81,7 @@ namespace upm {
|
||||
* @image html htu21d.jpeg
|
||||
* @snippet htu21d.cxx Interesting
|
||||
*/
|
||||
class HTU21D {
|
||||
class HTU21D : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an HTU21D object
|
||||
@ -102,7 +104,14 @@ class HTU21D {
|
||||
* @param bSampleData Flag to sample sensor (default false)
|
||||
* @return Relative humidity in %RH
|
||||
*/
|
||||
float getHumidity(int bSampleData = false);
|
||||
float getHumidity(int bSampleData);
|
||||
|
||||
/**
|
||||
* Gets the current measured humidity [%RH]
|
||||
*
|
||||
* @return Relative humidity in %RH
|
||||
*/
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Gets the humidity cell temperature [degC]
|
||||
@ -110,7 +119,14 @@ class HTU21D {
|
||||
* @param bSampleData Flag to sample sensor (default false)
|
||||
* @return Temperature in degC
|
||||
*/
|
||||
float getTemperature(int bSampleData = false);
|
||||
float getTemperature(int bSampleData);
|
||||
|
||||
/**
|
||||
* Gets the humidity cell temperature [degC]
|
||||
*
|
||||
* @return Temperature in degC
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Using the current humidity and temperature, the function
|
||||
|
@ -263,6 +263,11 @@ float HWXPXX::getTemperature(bool fahrenheit)
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
float HWXPXX::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
float HWXPXX::getHumidity()
|
||||
{
|
||||
return m_humidity;
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <string>
|
||||
|
||||
#include <modbus/modbus.h>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -64,7 +66,7 @@ namespace upm {
|
||||
* @snippet hwxpxx.cxx Interesting
|
||||
*/
|
||||
|
||||
class HWXPXX {
|
||||
class HWXPXX : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
// MODBUS input registers
|
||||
typedef enum {
|
||||
@ -128,7 +130,17 @@ namespace upm {
|
||||
* The default is false (degrees Celsius).
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
float getTemperature(bool fahrenheit=false);
|
||||
float getTemperature(bool fahrenheit);
|
||||
|
||||
/**
|
||||
* Get the current temperature. update() must have been called
|
||||
* prior to calling this method. If this option was not
|
||||
* installed, this method will always return 0C/0F, depending on
|
||||
* the scale the device is operating in natively.
|
||||
*
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Get the current relative humidity. update() must have been called
|
||||
@ -136,7 +148,7 @@ namespace upm {
|
||||
*
|
||||
* @return The last humidity reading
|
||||
*/
|
||||
float getHumidity();
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Get the current slider switch position. update() must have
|
||||
|
@ -55,6 +55,11 @@ uint16_t IMS::get_moisture()
|
||||
return retval;
|
||||
}
|
||||
|
||||
int IMS::getMoisture()
|
||||
{
|
||||
return get_moisture();
|
||||
}
|
||||
|
||||
uint16_t IMS::get_light()
|
||||
{
|
||||
uint16_t retval;
|
||||
@ -73,6 +78,11 @@ float IMS::get_temperature()
|
||||
return static_cast<float>(retval)/10.0;
|
||||
}
|
||||
|
||||
float IMS::getTemperature()
|
||||
{
|
||||
return get_temperature();
|
||||
}
|
||||
|
||||
void IMS::reset_i2c_address(uint8_t address_new)
|
||||
{
|
||||
if (ims_reset_i2c_address(_dev, address_new) != UPM_SUCCESS)
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <interfaces/iMoisture.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
#include "ims.h"
|
||||
|
||||
namespace upm {
|
||||
@ -55,7 +57,7 @@ namespace upm {
|
||||
* @snippet ims.cxx Interesting
|
||||
*/
|
||||
|
||||
class IMS {
|
||||
class IMS : virtual public iMoisture, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* I2C Moisture Sensor constructor
|
||||
@ -103,6 +105,13 @@ class IMS {
|
||||
*/
|
||||
uint16_t get_moisture();
|
||||
|
||||
/**
|
||||
* Get moisture reading from sensor
|
||||
* @return Unitless, relative capacitance value (moisture)
|
||||
* @throws std::runtime_error if I2C read command fails
|
||||
*/
|
||||
virtual int getMoisture();
|
||||
|
||||
/**
|
||||
* Get light reading from LED on device. The technical data for the I2C
|
||||
* moisture sensor specifies a 3 second wait. Loop for 3 seconds
|
||||
@ -122,6 +131,13 @@ class IMS {
|
||||
*/
|
||||
float get_temperature();
|
||||
|
||||
/**
|
||||
* Get temperature reading from device
|
||||
* @return rd_data Temperature in degrees Celsius
|
||||
* @throws std::runtime_error if I2C read command fails
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Reset sensor
|
||||
* @throws std::runtime_error if I2C write command fails
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <interfaces/iDistance.hpp>
|
||||
|
||||
#define ADDR 0x62 // device address
|
||||
|
||||
@ -87,7 +88,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet lidarlitev3.cxx Interesting
|
||||
*/
|
||||
class LIDARLITEV3 {
|
||||
class LIDARLITEV3 : virtual public iDistance {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an LIDARLITEV3 object
|
||||
@ -109,7 +110,7 @@ class LIDARLITEV3 {
|
||||
* Returns distance measurement on success
|
||||
* Retruns -1 on failure.
|
||||
*/
|
||||
int getDistance ();
|
||||
virtual int getDistance ();
|
||||
|
||||
/**
|
||||
* Read
|
||||
|
@ -57,6 +57,17 @@ int Light::value()
|
||||
return (int)roundf(value);
|
||||
}
|
||||
|
||||
float Light::getLuminance()
|
||||
{
|
||||
float value;
|
||||
|
||||
if (light_get_lux(m_light, &value))
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": light_get_normalized() failed.");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
float Light::raw_value()
|
||||
{
|
||||
// This is a hack. Deprecated. Should be removed ASAP.
|
||||
|
@ -28,6 +28,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <interfaces/iLight.hpp>
|
||||
|
||||
#include "light.h"
|
||||
|
||||
@ -58,7 +59,7 @@ namespace upm {
|
||||
* @image html light.jpg
|
||||
* @snippet light.cxx Interesting
|
||||
*/
|
||||
class Light {
|
||||
class Light : virtual public iLight {
|
||||
public:
|
||||
/**
|
||||
* Analog light sensor constructor
|
||||
@ -91,6 +92,14 @@ namespace upm {
|
||||
*/
|
||||
int value();
|
||||
|
||||
/**
|
||||
* Gets an approximate light value in lux from the sensor
|
||||
*
|
||||
* @return Approximate light reading in lux
|
||||
* @throws std::runtime_error on error
|
||||
*/
|
||||
virtual float getLuminance();
|
||||
|
||||
/**
|
||||
* Set ADC reference voltage
|
||||
*
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "lm35.h"
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -58,7 +59,7 @@ namespace upm {
|
||||
* @snippet lm35.cxx Interesting
|
||||
*/
|
||||
|
||||
class LM35 {
|
||||
class LM35 : virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -79,7 +80,7 @@ namespace upm {
|
||||
*
|
||||
* @return The Temperature in degrees Celsius
|
||||
*/
|
||||
float getTemperature();
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Set sensor scale. This scale is applied to the return values
|
||||
|
@ -49,7 +49,7 @@ MAX31723::MAX31723 (int bus, int csn) : m_spi(bus), m_csnPinCtx(csn) {
|
||||
writeRegister (R_STS_WRITE_CMD, B_CONT_READING);
|
||||
}
|
||||
|
||||
short
|
||||
float
|
||||
MAX31723::getTemperature () {
|
||||
uint8_t msb = 0;
|
||||
short temperature = 0;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <mraa/gpio.hpp>
|
||||
|
||||
#include <mraa/spi.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
@ -60,7 +61,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet max31723.cxx Interesting
|
||||
*/
|
||||
class MAX31723 {
|
||||
class MAX31723 : virtual public iTemperature {
|
||||
public:
|
||||
static const uint8_t R_STS_READ_CMD = 0x00;
|
||||
static const uint8_t R_STS_WRITE_CMD = 0x80;
|
||||
@ -85,9 +86,11 @@ class MAX31723 {
|
||||
**/
|
||||
|
||||
/**
|
||||
* Gets the on-board temperature.
|
||||
* Returns the temperature in degrees Celsius
|
||||
*
|
||||
* @return The Temperature in degrees Celsius
|
||||
*/
|
||||
short getTemperature ();
|
||||
virtual float getTemperature ();
|
||||
|
||||
/**
|
||||
* Returns the name of the component
|
||||
|
@ -41,7 +41,7 @@ MAX44009::MAX44009 (int bus, int devAddr) {
|
||||
status = mraa::SUCCESS;
|
||||
reset();
|
||||
if (status != mraa::SUCCESS)
|
||||
UPM_THROW("config failure");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": config failure");
|
||||
}
|
||||
|
||||
MAX44009::~MAX44009() {
|
||||
@ -70,7 +70,7 @@ MAX44009::getVisibleRaw() {
|
||||
int length = i2c->readBytesReg(MAX44009_LUX_START_ADDR, data, MAX44009_LUX_LENGTH);
|
||||
|
||||
if(length != MAX44009_LUX_LENGTH)
|
||||
UPM_THROW("Read error");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": Read error");
|
||||
|
||||
return *value;
|
||||
}
|
||||
@ -86,8 +86,12 @@ MAX44009::getVisibleLux() {
|
||||
|
||||
// Check for overrange condition
|
||||
if(exponent == MAX44009_OVERRANGE_CONDITION)
|
||||
UPM_THROW("Overrange error");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": Overrange error");
|
||||
|
||||
return pow((double)2,(double)exponent) * mantissa * 0.045;
|
||||
}
|
||||
|
||||
float
|
||||
MAX44009::getLuminance() {
|
||||
return getVisibleLux();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
|
||||
#include "interfaces/iLightSensor.hpp"
|
||||
#include <interfaces/iLight.hpp>
|
||||
|
||||
/* ADDRESS AND NOT_FOUND VALUE */
|
||||
#define MAX44009_ADDRESS ( 0x4A )
|
||||
@ -106,7 +106,7 @@ namespace upm {
|
||||
* @snippet max44009.cxx Interesting
|
||||
*
|
||||
*/
|
||||
class MAX44009 : public ILightSensor {
|
||||
class MAX44009 : virtual public iLight {
|
||||
public:
|
||||
/**
|
||||
* Instanciates a MAX44009 object
|
||||
@ -131,6 +131,13 @@ class MAX44009 : 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 "max44009"; }
|
||||
|
||||
private:
|
||||
|
@ -2,11 +2,6 @@
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%include "arrays_java.i";
|
||||
%include "../java_buffer.i"
|
||||
%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%}
|
||||
%import "../interfaces/javaupm_iLightSensor.i"
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_max44009)
|
||||
#endif
|
||||
/* END Java syntax */
|
||||
|
@ -62,3 +62,9 @@ int MAXSONAREZ::inches()
|
||||
|
||||
return int(volts / m_vI);
|
||||
}
|
||||
|
||||
int MAXSONAREZ::getDistance()
|
||||
{
|
||||
// TODO: call static conversion first.
|
||||
return inches();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <mraa/aio.h>
|
||||
#include <interfaces/iDistance.hpp>
|
||||
|
||||
// EZ series is volts/512
|
||||
#define MAXSONAREZ_RES 512
|
||||
@ -67,7 +68,7 @@ namespace upm {
|
||||
* @snippet maxsonarez.cxx Interesting
|
||||
*/
|
||||
|
||||
class MAXSONAREZ {
|
||||
class MAXSONAREZ : virtual public iDistance {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -90,6 +91,13 @@ namespace upm {
|
||||
*/
|
||||
int inches();
|
||||
|
||||
/**
|
||||
* Gets the distance to the object in inches
|
||||
*
|
||||
* @return Distance to the object in inches
|
||||
*/
|
||||
virtual int getDistance();
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
float m_aref;
|
||||
|
@ -47,3 +47,8 @@ int MB704X::getRange()
|
||||
{
|
||||
return mb704x_get_range(m_mb704x);
|
||||
}
|
||||
|
||||
int MB704X::getDistance()
|
||||
{
|
||||
return getRange();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <interfaces/iDistance.hpp>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -58,7 +59,7 @@ namespace upm {
|
||||
* @snippet mb704x.cxx Interesting
|
||||
*/
|
||||
|
||||
class MB704X {
|
||||
class MB704X : virtual public iDistance {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -84,7 +85,12 @@ namespace upm {
|
||||
*/
|
||||
int getRange();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the distance to the object in cm
|
||||
*
|
||||
* @return Distance to the object in cm
|
||||
*/
|
||||
virtual int getDistance();
|
||||
protected:
|
||||
// mb704x device context
|
||||
mb704x_context m_mb704x;
|
||||
|
@ -67,6 +67,11 @@ MCP9808::getTemp(){
|
||||
return getTempValue(result);
|
||||
}
|
||||
|
||||
float
|
||||
MCP9808::getTemperature() {
|
||||
return getTemp();
|
||||
}
|
||||
|
||||
void
|
||||
MCP9808::shutDown(bool sleep){
|
||||
if(sleep) this->updateConfigRegister(MCP9808_CONFIG_SHUTDOWN);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define MCP9808_REG_CONFIG 0x01
|
||||
#define MCP9808_REG_AMBIENT_TEMP 0x05
|
||||
@ -75,7 +76,7 @@ namespace upm {
|
||||
* @image html mcp9808.jpg
|
||||
* @snippet mcp9808.cxx Interesting
|
||||
*/
|
||||
class MCP9808 {
|
||||
class MCP9808 : virtual public iTemperature {
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -177,6 +178,13 @@ namespace upm {
|
||||
*/
|
||||
float getTemp(void);
|
||||
|
||||
/**
|
||||
* Returns the temperature in degrees Celsius
|
||||
*
|
||||
* @return The Temperature in degrees Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Will cause the devices to either sleep or wakeup.
|
||||
*
|
||||
|
@ -70,6 +70,11 @@ MLX90614::readAmbientTempC(void) {
|
||||
return readTemperature(MLX90614_TA);
|
||||
}
|
||||
|
||||
float
|
||||
MLX90614::getTemperature() {
|
||||
return readAmbientTempC();
|
||||
}
|
||||
|
||||
/*
|
||||
* **************
|
||||
* private area
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define DEVICE_ADDR 0x5A // device address
|
||||
|
||||
@ -73,7 +74,7 @@ namespace upm {
|
||||
* @image html mlx90614.jpg
|
||||
* @snippet mlx90614.cxx Interesting
|
||||
*/
|
||||
class MLX90614 {
|
||||
class MLX90614 : virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -109,6 +110,13 @@ class MLX90614 {
|
||||
*/
|
||||
float readAmbientTempC(void);
|
||||
|
||||
/**
|
||||
* Returns the temperature in degrees Celsius
|
||||
*
|
||||
* @return The Temperature in degrees Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Returns the name of the component
|
||||
*/
|
||||
|
@ -46,3 +46,8 @@ int Moisture::value()
|
||||
{
|
||||
return mraa_aio_read(m_aio);
|
||||
}
|
||||
|
||||
int Moisture::getMoisture()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.h>
|
||||
#include <interfaces/iMoisture.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -55,7 +56,7 @@ namespace upm {
|
||||
* @image html moisture.jpg
|
||||
* @snippet moisture.cxx Interesting
|
||||
*/
|
||||
class Moisture {
|
||||
class Moisture : virtual public iMoisture {
|
||||
public:
|
||||
/**
|
||||
* Analog moisture sensor constructor
|
||||
@ -74,6 +75,13 @@ namespace upm {
|
||||
*/
|
||||
int value();
|
||||
|
||||
/**
|
||||
* Gets the moisture value from the sensor
|
||||
*
|
||||
* @return Moisture reading
|
||||
*/
|
||||
virtual int getMoisture();
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
};
|
||||
|
@ -207,6 +207,11 @@ MPL3115A2::getPressure(int bSampleData) {
|
||||
return (float)m_iPressure / 100;
|
||||
}
|
||||
|
||||
float
|
||||
MPL3115A2::getPressure() {
|
||||
return getPressure(true);
|
||||
}
|
||||
|
||||
float
|
||||
MPL3115A2::getTemperature(int bSampleData) {
|
||||
int ret;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <math.h>
|
||||
#include <interfaces/iPressure.hpp>
|
||||
|
||||
#define MPL3115A2_NAME "mpl3115a2"
|
||||
|
||||
@ -79,7 +80,7 @@ namespace upm {
|
||||
* @image html mpl3115a2.jpg
|
||||
* @snippet mpl3115a2.cxx Interesting
|
||||
*/
|
||||
class MPL3115A2 {
|
||||
class MPL3115A2 : virtual public iPressure {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an MPL3115A2 object
|
||||
@ -141,7 +142,14 @@ class MPL3115A2 {
|
||||
*
|
||||
* @param bSampleData Sets non-zero to a sample reading
|
||||
*/
|
||||
float getPressure(int bSampleData = true);
|
||||
float getPressure(int bSampleData);
|
||||
|
||||
/**
|
||||
* Reads the current pressure value from MPL3115A2 [Pa]
|
||||
*
|
||||
* @return Pressure value in Pa
|
||||
*/
|
||||
virtual float getPressure();
|
||||
|
||||
/**
|
||||
* Reads the current temperature value from MPL3115A2 [degC]
|
||||
|
@ -58,13 +58,13 @@ MS5611::MS5611(int i2cBus, int address)
|
||||
i2c->address(address);
|
||||
prom = new uint16_t[MS5611_PROM_SIZE];
|
||||
if (i2c->writeByte(MS5611_CMD_RESET != mraa::SUCCESS))
|
||||
UPM_THROW("Reset failed.");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": Reset failed.");
|
||||
delayms(5);
|
||||
for (int i = 0; i < MS5611_PROM_SIZE; ++i) {
|
||||
uint8_t buf[2];
|
||||
int bytesRead = i2c->readBytesReg(MS5611_CMD_READ_PROM + 2*i, buf, 2);
|
||||
if (bytesRead != 2)
|
||||
UPM_THROW("PROM address failed.");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": PROM address failed.");
|
||||
prom[i] = buf[0] << 8;
|
||||
prom[i] |= buf[1];
|
||||
// printf("Read PROM entry %d = %04x\n", i, prom[i]);
|
||||
@ -72,7 +72,7 @@ MS5611::MS5611(int i2cBus, int address)
|
||||
|
||||
// printf("CRC = %X\n", promCrc4());
|
||||
if (promCrc4() != (prom[7] & 0x000F))
|
||||
UPM_THROW("PROM checksum error.");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": PROM checksum error.");
|
||||
setOverSampling(ULTRA_HIGH_RES);
|
||||
}
|
||||
|
||||
@ -153,11 +153,11 @@ uint32_t MS5611::readADC(int adcReg)
|
||||
uint32_t value;
|
||||
uint8_t buf[3];
|
||||
if (i2c->writeByte(adcReg + osr) != mraa::SUCCESS)
|
||||
UPM_THROW("Convert D2 failed");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": Convert D2 failed");
|
||||
delayms(100);
|
||||
int bytesRead = i2c->readBytesReg(MS5611_CMD_ADC_READ, buf, 3);
|
||||
if (bytesRead != 3)
|
||||
UPM_THROW("ADC read failed");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": ADC read failed");
|
||||
// printf("%02X%02X%02X\n", buf[0], buf[1], buf[2]);
|
||||
value = ((uint32_t)buf[0] << 16) | ((uint32_t)buf[1] << 8) | buf[2];
|
||||
return value;
|
||||
@ -181,6 +181,11 @@ int MS5611::getTemperatureCelsius()
|
||||
return (temp + 50) / 100;
|
||||
}
|
||||
|
||||
float MS5611::getTemperature()
|
||||
{
|
||||
return getTemperatureCelsius();
|
||||
}
|
||||
|
||||
|
||||
int MS5611::getPressurePa()
|
||||
{
|
||||
@ -208,3 +213,7 @@ int MS5611::getPressurePa()
|
||||
return pressure;
|
||||
}
|
||||
|
||||
float MS5611::getPressure()
|
||||
{
|
||||
return getPressurePa();
|
||||
}
|
||||
|
@ -22,8 +22,8 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "interfaces/iPressureSensor.hpp"
|
||||
#include "interfaces/iTemperatureSensor.hpp"
|
||||
#include <interfaces/iPressure.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
#include "mraa/i2c.hpp"
|
||||
|
||||
namespace upm
|
||||
@ -58,7 +58,7 @@ namespace upm
|
||||
* @snippet ms5611.cxx Interesting
|
||||
*/
|
||||
|
||||
class MS5611 : public IPressureSensor, public ITemperatureSensor
|
||||
class MS5611 : virtual public iPressure, virtual public iTemperature
|
||||
{
|
||||
public:
|
||||
enum OsrMode
|
||||
@ -71,8 +71,22 @@ public:
|
||||
virtual const char* getModuleName() { return "ms5611"; }
|
||||
void setOverSampling(OsrMode osrMode);
|
||||
int getTemperatureCelsius();
|
||||
|
||||
/**
|
||||
* Returns the temperature in degrees Celsius
|
||||
*
|
||||
* @return The Temperature in degrees Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
int getPressurePa();
|
||||
|
||||
/**
|
||||
* Return the current measured pressure in Pascals (Pa).
|
||||
*
|
||||
* @return The pressure in Pascals (Pa).
|
||||
*/
|
||||
virtual float getPressure();
|
||||
|
||||
private:
|
||||
/* Disable implicit copy and assignment operators */
|
||||
MS5611(const MS5611&) = delete;
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%import "../interfaces/javaupm_iTemperatureSensor.i"
|
||||
%import "../interfaces/javaupm_iPressureSensor.i"
|
||||
%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%}
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_ms5611)
|
||||
#endif
|
||||
/* END Java syntax */
|
||||
|
@ -77,7 +77,7 @@ float MS5803::getTemperature()
|
||||
|
||||
float MS5803::getPressure()
|
||||
{
|
||||
return ms5803_get_pressure(m_ms5803);
|
||||
return (ms5803_get_pressure(m_ms5803) * 100);
|
||||
}
|
||||
|
||||
void MS5803::loadCoefficients()
|
||||
|
@ -24,6 +24,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <interfaces/iPressure.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#include "ms5803.h"
|
||||
|
||||
@ -64,7 +66,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet ms5803.cxx Interesting
|
||||
*/
|
||||
class MS5803 {
|
||||
class MS5803 : virtual public iPressure, virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -130,7 +132,7 @@ namespace upm {
|
||||
*
|
||||
* @return Temperature in degrees C
|
||||
*/
|
||||
float getTemperature();
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Return the latest measured pressure. update() must have
|
||||
@ -139,7 +141,7 @@ namespace upm {
|
||||
*
|
||||
* @return Pressure in mbar
|
||||
*/
|
||||
float getPressure();
|
||||
virtual float getPressure();
|
||||
|
||||
protected:
|
||||
ms5803_context m_ms5803;
|
||||
|
@ -55,6 +55,11 @@ float OTP538U::ambientTemperature()
|
||||
return temp;
|
||||
}
|
||||
|
||||
float OTP538U::getTemperature()
|
||||
{
|
||||
return ambientTemperature();
|
||||
}
|
||||
|
||||
float OTP538U::objectTemperature()
|
||||
{
|
||||
float temp = 0;
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <otp538u.h>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -73,7 +74,7 @@ namespace upm {
|
||||
* @image html otp538u.jpg
|
||||
* @snippet otp538u.cxx Interesting
|
||||
*/
|
||||
class OTP538U {
|
||||
class OTP538U : virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* OTP538U constructor
|
||||
@ -96,6 +97,13 @@ namespace upm {
|
||||
*/
|
||||
float ambientTemperature();
|
||||
|
||||
/**
|
||||
* Gets the ambient temperature in Celsius
|
||||
*
|
||||
* @return Ambient temperature
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Gets the object temperature in Celsius
|
||||
*
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/gpio.h>
|
||||
#include <interfaces/iDistanceInterrupter.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -53,7 +54,7 @@ namespace upm {
|
||||
* @image html rfr359f.jpg
|
||||
* @snippet rfr359f.cxx Interesting
|
||||
*/
|
||||
class RFR359F {
|
||||
class RFR359F : virtual public iDistanceInterrupter {
|
||||
public:
|
||||
/**
|
||||
* RFR359F constructor
|
||||
@ -72,7 +73,7 @@ namespace upm {
|
||||
*
|
||||
* @return True if the sensor has detected an object
|
||||
*/
|
||||
bool objectDetected();
|
||||
virtual bool objectDetected();
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
|
@ -99,6 +99,11 @@ float RHUSB::getTemperature(bool fahrenheit)
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
float RHUSB::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
float RHUSB::getHumidity()
|
||||
{
|
||||
return m_humidity;
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/uart.hpp>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -53,7 +55,7 @@ namespace upm {
|
||||
* @snippet rhusb.cxx Interesting
|
||||
*/
|
||||
|
||||
class RHUSB {
|
||||
class RHUSB : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* RHUSB constructor
|
||||
@ -83,7 +85,15 @@ namespace upm {
|
||||
* The default is false (degrees Celsius).
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
float getTemperature(bool fahrenheit=false);
|
||||
float getTemperature(bool fahrenheit);
|
||||
|
||||
/**
|
||||
* Get the current temperature. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return The last temperature reading in Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Get the current relative humidity. update() must have been called
|
||||
@ -91,7 +101,7 @@ namespace upm {
|
||||
*
|
||||
* @return The last humidity reading
|
||||
*/
|
||||
float getHumidity();
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Get the firmware identification string.
|
||||
|
@ -166,9 +166,10 @@ float RSC::getTemperature()
|
||||
return rsc_get_temperature(m_rsc);
|
||||
}
|
||||
|
||||
#define INH20_TO_PA 248.84
|
||||
float RSC::getPressure()
|
||||
{
|
||||
return rsc_get_pressure(m_rsc);
|
||||
return rsc_get_pressure(m_rsc) * INH20_TO_PA;
|
||||
}
|
||||
|
||||
void RSC::setMode(RSC_MODE mode)
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "rsc.h"
|
||||
#include <string>
|
||||
#include <interfaces/iPressure.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -74,7 +76,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet rsc.cxx Interesting
|
||||
*/
|
||||
class RSC {
|
||||
class RSC : virtual public iPressure, virtual public iTemperature {
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -194,14 +196,14 @@ namespace upm {
|
||||
*
|
||||
* @return float compensated temperature value
|
||||
*/
|
||||
float getTemperature();
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Function to get the compensated pressure value
|
||||
*
|
||||
* @return float compensated pressure value
|
||||
*/
|
||||
float getPressure();
|
||||
virtual float getPressure();
|
||||
|
||||
/**
|
||||
* Function to set the mode for the RSC sensor:
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#include "sht1x.h"
|
||||
|
||||
@ -58,7 +60,7 @@ namespace upm {
|
||||
* @snippet sht1x.cxx Interesting
|
||||
*/
|
||||
|
||||
class SHT1X {
|
||||
class SHT1X : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -91,7 +93,7 @@ namespace upm {
|
||||
*
|
||||
* @return The temperature in Celsius
|
||||
*/
|
||||
float getTemperature();
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Query the relative humidity. update() must have been called
|
||||
@ -99,7 +101,7 @@ namespace upm {
|
||||
*
|
||||
* @return The relative humidity.
|
||||
*/
|
||||
float getHumidity();
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Read the status register.
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -82,7 +82,7 @@ SI7005::SI7005 (int bus, int pin) {
|
||||
m_i2c = new mraa::I2c(m_bus);
|
||||
status = m_i2c->address(m_controlAddr);
|
||||
if (!isAvailable())
|
||||
UPM_THROW("config failure");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": config failure");
|
||||
}
|
||||
|
||||
SI7005::~SI7005() {
|
||||
@ -102,6 +102,11 @@ SI7005::getTemperatureCelsius () {
|
||||
return static_cast<int>(last_temperature + 0.5);
|
||||
}
|
||||
|
||||
float
|
||||
SI7005::getTemperature() {
|
||||
return getTemperatureCelsius();
|
||||
}
|
||||
|
||||
uint16_t
|
||||
SI7005::getHumidityRaw () {
|
||||
return getMeasurement( SI7005_CONFIG_HUMIDITY );
|
||||
@ -117,6 +122,10 @@ SI7005::getHumidityRelative () {
|
||||
return static_cast<int>(linearHumidity + 0.5);
|
||||
}
|
||||
|
||||
float
|
||||
SI7005::getHumidity () {
|
||||
return getHumidityRelative();
|
||||
}
|
||||
|
||||
uint16_t SI7005::getMeasurement(uint8_t configValue) {
|
||||
|
||||
@ -149,7 +158,7 @@ uint16_t SI7005::getMeasurement(uint8_t configValue) {
|
||||
|
||||
// Check we got the data we need
|
||||
if(length != SI7005_REG_DATA_LENGTH)
|
||||
UPM_THROW("read error");
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": read error");
|
||||
|
||||
// Merge MSB and LSB
|
||||
rawData = ((uint16_t)( data[SI7005_REG_DATA_LOW] & 0xFFFF )) + ( (uint16_t)(( data[SI7005_REG_DATA_HIGH] & 0xFFFF ) << 8 ));
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
#include <mraa/i2c.hpp>
|
||||
|
||||
#include "interfaces/iTemperatureSensor.hpp"
|
||||
#include "interfaces/iHumiditySensor.hpp"
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
|
||||
/* ADDRESS AND NOT_FOUND VALUE */
|
||||
#define SI7005_ADDRESS ( 0x40 )
|
||||
@ -59,7 +59,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet si7005.cxx Interesting
|
||||
*/
|
||||
class SI7005 : public ITemperatureSensor, public IHumiditySensor {
|
||||
class SI7005 : virtual public iTemperature, virtual public iHumidity {
|
||||
public:
|
||||
/**
|
||||
* Instantiates a SI7005 object
|
||||
@ -84,6 +84,13 @@ class SI7005 : public ITemperatureSensor, public IHumiditySensor {
|
||||
*/
|
||||
int getTemperatureCelsius ();
|
||||
|
||||
/**
|
||||
* Get the current temperature.
|
||||
*
|
||||
* @return The last temperature reading in Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Get relative humidity measurement.
|
||||
*/
|
||||
@ -94,6 +101,13 @@ class SI7005 : public ITemperatureSensor, public IHumiditySensor {
|
||||
*/
|
||||
int getHumidityRelative ();
|
||||
|
||||
/**
|
||||
* Get the current relative humidity.
|
||||
*
|
||||
* @return The last humidity reading
|
||||
*/
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Returns sensor module name
|
||||
*/
|
||||
|
@ -2,13 +2,6 @@
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%include "arrays_java.i";
|
||||
%include "../java_buffer.i"
|
||||
%typemap(javaimports) SWIGTYPE %{import upm_interfaces.*;%}
|
||||
|
||||
%import "../interfaces/javaupm_iTemperatureSensor.i"
|
||||
%import "../interfaces/javaupm_iHumiditySensor.i"
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_si7005)
|
||||
#endif
|
||||
/* END Java syntax */
|
||||
|
@ -259,6 +259,11 @@ float T3311::getTemperature(bool fahrenheit)
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
float T3311::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
float T3311::getHumidity()
|
||||
{
|
||||
return m_humidity;
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <string>
|
||||
|
||||
#include <modbus/modbus.h>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -60,7 +62,7 @@ namespace upm {
|
||||
* @snippet t3311.cxx Interesting
|
||||
*/
|
||||
|
||||
class T3311 {
|
||||
class T3311 : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
|
||||
// MODBUS input registers
|
||||
@ -148,7 +150,15 @@ namespace upm {
|
||||
* The default is false (degrees Celsius).
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
float getTemperature(bool fahrenheit=false);
|
||||
float getTemperature(bool fahrenheit);
|
||||
|
||||
/**
|
||||
* Get the current temperature. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return The last temperature reading in Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Get the current relative humidity. update() must have been called
|
||||
@ -156,7 +166,7 @@ namespace upm {
|
||||
*
|
||||
* @return The last humidity reading
|
||||
*/
|
||||
float getHumidity();
|
||||
virtual float getHumidity();
|
||||
|
||||
/**
|
||||
* Get the current computed value. update() must have been
|
||||
|
@ -112,6 +112,11 @@ float TEAMS::getTemperature(bool fahrenheit)
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
float TEAMS::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
int TEAMS::average(int samples)
|
||||
{
|
||||
if (samples <= 0)
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <mraa/aio.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
// Unlikey to be changable
|
||||
#define TEAMS_DEFAULT_AREF 5.0
|
||||
@ -66,7 +67,7 @@ namespace upm {
|
||||
* @snippet teams.cxx Interesting
|
||||
*/
|
||||
|
||||
class TEAMS {
|
||||
class TEAMS : virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -104,7 +105,15 @@ namespace upm {
|
||||
* The default is false (degrees Celsius).
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
float getTemperature(bool fahrenheit=false);
|
||||
float getTemperature(bool fahrenheit);
|
||||
|
||||
/**
|
||||
* Get the current temperature. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* When using a direct 4-20ma interface (rResistor supplied in the
|
||||
|
@ -62,6 +62,11 @@ int Temperature::value ()
|
||||
return (int) round(t);
|
||||
}
|
||||
|
||||
float Temperature::getTemperature ()
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
float Temperature::raw_value()
|
||||
{
|
||||
return (float) mraa_aio_read(m_aio);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/aio.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
@ -58,7 +59,7 @@ namespace upm {
|
||||
* @image html temp.jpg
|
||||
* @snippet temperature.cxx Interesting
|
||||
*/
|
||||
class Temperature {
|
||||
class Temperature : virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* Analog temperature sensor constructor
|
||||
@ -96,6 +97,13 @@ class Temperature {
|
||||
* @return Normalized temperature in Celsius
|
||||
*/
|
||||
int value();
|
||||
|
||||
/**
|
||||
* Gets the temperature in Celsius from the sensor
|
||||
*
|
||||
* @return Normalized temperature in Celsius
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
float m_scale;
|
||||
|
@ -141,6 +141,11 @@ float TEX00::getTemperature(bool fahrenheit)
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
float TEX00::getTemperature()
|
||||
{
|
||||
return getTemperature(false);
|
||||
}
|
||||
|
||||
int TEX00::average(int samples)
|
||||
{
|
||||
if (samples <= 0)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <mraa/aio.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define TEX00_DEFAULT_AREF 5.0
|
||||
|
||||
@ -74,7 +75,7 @@ namespace upm {
|
||||
* @snippet tex00.cxx Interesting
|
||||
*/
|
||||
|
||||
class TEX00 {
|
||||
class TEX00 : virtual public iTemperature {
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
@ -126,7 +127,15 @@ namespace upm {
|
||||
* The default is false (degrees Celsius).
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
float getTemperature(bool fahrenheit=false);
|
||||
float getTemperature(bool fahrenheit);
|
||||
|
||||
/**
|
||||
* Get the current temperature. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return The last temperature reading in Celsius or Fahrenheit
|
||||
*/
|
||||
virtual float getTemperature();
|
||||
|
||||
/**
|
||||
* Return the smallest temperature that can be measured by the
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <interfaces/iHumidity.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define TH02_ADDR 0x40 // device address
|
||||
|
||||
@ -69,7 +71,7 @@ namespace upm {
|
||||
* @image html th02.jpg
|
||||
* @snippet th02.cxx Interesting
|
||||
*/
|
||||
class TH02 {
|
||||
class TH02 : virtual public iHumidity, virtual public iTemperature {
|
||||
public:
|
||||
/**
|
||||
* Instantiates a TH02 object
|
||||
@ -82,14 +84,18 @@ class TH02 {
|
||||
~TH02 ();
|
||||
|
||||
/**
|
||||
* Gets the temperature value from the sensor.
|
||||
* Get the current temperature.
|
||||
*
|
||||
* @return The last temperature reading in Celsius
|
||||
*/
|
||||
float getTemperature ();
|
||||
virtual float getTemperature ();
|
||||
|
||||
/**
|
||||
* Gets the humidity value from the sensor.
|
||||
* Get the current relative humidity.
|
||||
*
|
||||
* @return The last humidity reading
|
||||
*/
|
||||
float getHumidity ();
|
||||
virtual float getHumidity ();
|
||||
|
||||
/**
|
||||
* Gets the sensor status.
|
||||
|
@ -189,6 +189,12 @@ TSL2561::getLux()
|
||||
return lux;
|
||||
}
|
||||
|
||||
float
|
||||
TSL2561::getLuminance()
|
||||
{
|
||||
return getLux();
|
||||
}
|
||||
|
||||
|
||||
mraa::Result
|
||||
TSL2561::i2cWriteReg (uint8_t reg, uint8_t value)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <math.h>
|
||||
#include <interfaces/iLight.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -108,14 +109,14 @@ namespace upm {
|
||||
* @kit eak
|
||||
*
|
||||
* @brief API for the TSL2561 Digital Light Sensor
|
||||
*
|
||||
*
|
||||
* TSL2560 and TSL2561 are light-to-digital converters that transform
|
||||
* light intensity to a digital signal output capable of a direct I2C (TSL2561) interface
|
||||
*
|
||||
* @image html tsl2561.jpg
|
||||
* @snippet tsl2561.cxx Interesting
|
||||
*/
|
||||
class TSL2561{
|
||||
class TSL2561 : virtual public iLight {
|
||||
public:
|
||||
/**
|
||||
* Instantiates a TSL2561 object
|
||||
@ -139,6 +140,13 @@ class TSL2561{
|
||||
*/
|
||||
int getLux();
|
||||
|
||||
/**
|
||||
* Gets the calculated lux reading from TSL2561
|
||||
*
|
||||
* @return Calculated lux value from the sensor
|
||||
*/
|
||||
virtual float getLuminance();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Writes to a TSL2561 register
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user