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
@ -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
|
||||
|
Reference in New Issue
Block a user