upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
ecezo.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 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 #pragma once
25 
26 #include <string>
27 #include <iostream>
28 
29 #include <stdlib.h>
30 #include <unistd.h>
31 
32 #include "ecezo.h"
33 
34 namespace upm {
60  class ECEZO {
61  public:
62 
77  ECEZO(unsigned int bus=0, unsigned int addrBaud=9600,
78  bool isI2C=false);
79 
83  ~ECEZO();
84 
91  void update();
92 
104  void setTemperature(float temp);
105 
112  void setKValue(float k);
113 
119  void setSleep(bool enable);
120 
128  float getEC();
129 
137  float getTDS();
138 
145  float getSalinity();
146 
154  float getSG();
155 
185  void calibrate(ECEZO_CALIBRATION_T cal, float ec);
186 
187 
188  protected:
189  // ecezo device context
190  ecezo_context m_ecezo;
191 
205  void setContinuous(bool enable);
206 
216  std::string sendCommand(std::string cmd);
217 
225  std::string read();
226 
234  void write(std::string data);
235 
236  private:
237  /* Disable implicit copy and assignment operators */
238  ECEZO(const ECEZO&) = delete;
239  ECEZO &operator=(const ECEZO&) = delete;
240  };
241 }
void setContinuous(bool enable)
Definition: ecezo.cxx:106
void setSleep(bool enable)
Definition: ecezo.cxx:72
C API for the EC-EZO EC Sensor.
void calibrate(ECEZO_CALIBRATION_T cal, float ec)
Definition: ecezo.cxx:99
std::string read()
Definition: ecezo.cxx:127
float getTDS()
Definition: ecezo.cxx:84
~ECEZO()
Definition: ecezo.cxx:46
ECEZO(unsigned int bus=0, unsigned int addrBaud=9600, bool isI2C=false)
Definition: ecezo.cxx:33
void write(std::string data)
Definition: ecezo.cxx:140
std::string sendCommand(std::string cmd)
Definition: ecezo.cxx:113
float getSalinity()
Definition: ecezo.cxx:89
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void setKValue(float k)
Definition: ecezo.cxx:65
Definition: ecezo.h:50
void update()
Definition: ecezo.cxx:51
void setTemperature(float temp)
Definition: ecezo.cxx:58
API for the EC-EZO EC Sensor.
Definition: ecezo.hpp:60
float getSG()
Definition: ecezo.cxx:94
float getEC()
Definition: ecezo.cxx:79