upm  1.0.0
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sht1x.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 "sht1x.h"
33 
34 namespace upm {
60  class SHT1X {
61  public:
62 
69  SHT1X(unsigned int clk_pin, unsigned int data_pin);
70 
74  ~SHT1X();
75 
79  void reset();
80 
85  void update();
86 
93  float getTemperature();
94 
101  float getHumidity();
102 
108  uint8_t readStatus();
109 
116  upm_result_t writeStatus(uint8_t status);
117 
127  void setVolts(SHT1X_VOLTS_T volts);
128 
129  protected:
130  // device context
131  sht1x_context m_sht1x;
132 
141  upm_result_t sendCommand(SHT1X_CMD_T cmd);
142 
150  upm_result_t waitForResponse();
151 
159  void startXmit();
160 
169  uint8_t read8Bits();
170 
179  upm_result_t write8Bits(uint8_t byte);
180 
181  private:
182  };
183 }
upm_result_t waitForResponse()
Definition: sht1x.cxx:94
upm_result_t writeStatus(uint8_t status)
Definition: sht1x.cxx:79
~SHT1X()
Definition: sht1x.cxx:41
void reset()
Definition: sht1x.cxx:46
void update()
Definition: sht1x.cxx:51
C API for SHT1X Temperature and Humidity Sensors.
float getTemperature()
Definition: sht1x.cxx:58
upm_result_t write8Bits(uint8_t byte)
Definition: sht1x.cxx:113
float getHumidity()
Definition: sht1x.cxx:63
uint8_t read8Bits()
Definition: sht1x.cxx:104
void startXmit()
Definition: sht1x.cxx:99
upm_result_t sendCommand(SHT1X_CMD_T cmd)
Definition: sht1x.cxx:89
SHT1X Temperature and Humidity Sensor.
Definition: sht1x.hpp:60
void setVolts(SHT1X_VOLTS_T volts)
Definition: sht1x.cxx:84
SHT1X(unsigned int clk_pin, unsigned int data_pin)
Definition: sht1x.cxx:33
Definition: sht1x.h:46
uint8_t readStatus()
Definition: sht1x.cxx:68