upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
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 {
61  class SHT1X {
62  public:
63 
70  SHT1X(unsigned int clk_pin, unsigned int data_pin);
71 
75  ~SHT1X();
76 
80  void reset();
81 
86  void update();
87 
94  float getTemperature();
95 
102  float getHumidity();
103 
109  uint8_t readStatus();
110 
117  upm_result_t writeStatus(uint8_t status);
118 
128  void setVolts(SHT1X_VOLTS_T volts);
129 
130  protected:
131  // device context
132  sht1x_context m_sht1x;
133 
142  upm_result_t sendCommand(SHT1X_CMD_T cmd);
143 
151  upm_result_t waitForResponse();
152 
160  void startXmit();
161 
170  uint8_t read8Bits();
171 
180  upm_result_t write8Bits(uint8_t byte);
181 
182  private:
183  /* Disable implicit copy and assignment operators */
184  SHT1X(const SHT1X&) = delete;
185  SHT1X &operator=(const SHT1X&) = delete;
186  };
187 }
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
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
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:61
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:48
uint8_t readStatus()
Definition: sht1x.cxx:68