upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
teams.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 <mraa/aio.hpp>
30 
31 // Unlikey to be changable
32 #define TEAMS_DEFAULT_AREF 5.0
33 
34 namespace upm {
69  class TEAMS {
70  public:
71 
84  TEAMS(int tPin, float rResistor=0.0, float aref=TEAMS_DEFAULT_AREF);
85 
89  ~TEAMS();
90 
96  void update();
97 
107  float getTemperature(bool fahrenheit=false);
108 
118  bool isConnected()
119  {
120  return m_connected;
121  };
122 
134  {
135  return m_rawMilliamps;
136  };
137 
147  void setOffsetMilliamps(float offset)
148  {
149  m_offset = offset;
150  };
151 
152  protected:
153  mraa::Aio m_aioTemp;
154 
155  private:
156  float m_aref;
157  float m_rResistor;
158  int m_aResTemp;
159 
160  // for a 4-20 ma loop
161  bool m_connected;
162  float m_rawMilliamps;
163 
164  // in Celsius
165  float m_temperature;
166 
167  // in case an offset should be applied to the cumputed current
168  float m_offset;
169 
170  int average(int samples);
171  };
172 }
173 
174 
~TEAMS()
Definition: teams.cxx:68
void update()
Definition: teams.cxx:72
void setOffsetMilliamps(float offset)
Definition: teams.hpp:147
float getTemperature(bool fahrenheit=false)
Definition: teams.cxx:107
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
API for the Veris TEAMS Temperature Transmitter.
Definition: teams.hpp:69
bool isConnected()
Definition: teams.hpp:118
float getRawMilliamps()
Definition: teams.hpp:133
TEAMS(int tPin, float rResistor=0.0, float aref=TEAMS_DEFAULT_AREF)
Definition: teams.cxx:44