upm  1.0.2
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ims.hpp
1 /*
2  * Author: Noel Eck <noel.eck@intel.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include "mraa/i2c.h"
28 #include "ims.h"
29 
30 namespace upm {
59 class IMS {
60  public:
70  IMS(int16_t i2c_bus, int16_t i2c_address = IMS_ADDRESS_DEFAULT);
71 
75  virtual ~IMS() {};
76 
83  void write(IMS_WR_COMMAND cmd, uint8_t wr_data);
84 
91  uint16_t read(IMS_RD_COMMAND cmd);
92 
98  uint16_t get_version();
99 
105  uint16_t get_moisture();
106 
117  uint16_t get_light();
118 
124  float get_temperature();
125 
130  void reset();
131 
137  void reset_i2c_address(uint8_t address_new);
138 
143  void sleep();
144  private:
145  /* device context struct */
146  ims_context* _dev;
147 };
148 }
API for the Catnip Electronics I2C moisture sensor.
Definition: ims.hpp:59
void sleep()
Definition: ims.cxx:105
void reset_i2c_address(uint8_t address_new)
Definition: ims.cxx:75
uint16_t read(IMS_RD_COMMAND cmd)
Definition: ims.cxx:89
uint16_t get_moisture()
Definition: ims.cxx:48
uint16_t get_version()
Definition: ims.cxx:39
void write(IMS_WR_COMMAND cmd, uint8_t wr_data)
Definition: ims.cxx:98
uint16_t get_light()
Definition: ims.cxx:57
void reset()
Definition: ims.cxx:82
C API for the Catnip Electronics I2C moisture sensor. This sensor must run at 100 kHz...
float get_temperature()
Definition: ims.cxx:66
IMS(int16_t i2c_bus, int16_t i2c_address=IMS_ADDRESS_DEFAULT)
Definition: ims.cxx:31
virtual ~IMS()
Definition: ims.hpp:75
Definition: ims.h:79