mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 09:51:14 +03:00
Added initial interfaces and some sensors implementing them
This commit is contained in:

committed by
Serban Waltter

parent
85608a9f61
commit
e7820f2831
@ -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 */
|
||||
|
Reference in New Issue
Block a user