11/*
22 * Copyright (c) 2016, Sensirion AG <[email protected] > 3- * Copyright (c) 2015, Johannes Winkelmann <[email protected] > 3+ * Copyright (c) 2015-2016 , Johannes Winkelmann <[email protected] > 44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,9 @@ class SHTSensor
4141{
4242public:
4343 /* *
44- * Enum of the supported Sensirion SHT Sensors.
45- * Using the special AutoDetect sensor causes all i2c sensors to be
44+ * Enum of the supported Digital Sensirion SHT Sensors.
45+ * For analog sensors, see SHT3xAnalogSensor.
46+ * Using the special AUTO_DETECT sensor causes all i2c sensors to be
4647 * probed. The first matching sensor will then be used.
4748 */
4849 enum SHTSensorType {
@@ -55,9 +56,7 @@ class SHTSensor
5556 SHT3X_ALT,
5657 SHTC1,
5758 SHTW1,
58- SHTW2,
59- // Analog sensors:
60- SHT3X_ANALOG
59+ SHTW2
6160 };
6261
6362 /* *
@@ -88,20 +87,10 @@ class SHTSensor
8887 * Instantiate a new SHTSensor
8988 * By default, the i2c bus is queried for known SHT Sensors. To address
9089 * a specific sensor, set the `sensorType'.
91- *
92- * Some sensor drivers require a specific parameter set and cannot be
93- * auto-detected. Those must be instantiated separately and be passed to
94- * `sensor'. In any other case sensor must be NULL.
95- *
96- * `ownSensor' describes whether the SHTSensor is responsible for freeing the
97- * memory pointed to by `sensor'. This should never need to be set explicitly.
9890 */
99- SHTSensor (SHTSensorType sensorType = AUTO_DETECT,
100- SHTSensorDriver *sensor = NULL ,
101- bool ownSensor = false )
91+ SHTSensor (SHTSensorType sensorType = AUTO_DETECT)
10292 : mSensorType (sensorType),
103- mSensor (sensor),
104- mOwnSensor(ownSensor),
93+ mSensor (NULL ),
10594 mTemperature(SHTSensor::TEMPERATURE_INVALID),
10695 mHumidity(SHTSensor::HUMIDITY_INVALID)
10796 {
@@ -112,11 +101,11 @@ class SHTSensor
112101 }
113102
114103 /* *
115- * Initialize a new Temperature and Humidity sensor driver
116- * To read out the sensor use readSample(), then use getTemperature() and
104+ * Initialize the sensor driver
105+ * To read out the sensor use readSample(), followed by getTemperature() and
117106 * getHumidity() to retrieve the values from the sample
118107 */
119- bool init (SHTSensorDriver *driver = NULL );
108+ bool init ();
120109
121110 /* *
122111 * Read new values from the sensor
@@ -162,7 +151,6 @@ class SHTSensor
162151
163152 SHTSensorType mSensorType ;
164153 SHTSensorDriver *mSensor ;
165- bool mOwnSensor ;
166154 float mTemperature ;
167155 float mHumidity ;
168156};
@@ -171,7 +159,7 @@ class SHTSensor
171159const uint8_t SHT3x_I2C_ADDRESS_44 = 0x44 ;
172160const uint8_t SHT3x_I2C_ADDRESS_45 = 0x45 ;
173161
174- /* * Abstract class for an SHT Sensor driver */
162+ /* * Abstract class for a digital SHT Sensor driver */
175163class SHTSensorDriver
176164{
177165public:
@@ -271,7 +259,7 @@ class SHTI2cSensor : public SHTSensorDriver {
271259 uint8_t dataLength);
272260};
273261
274- class SHT3xAnalogSensor : public SHTSensorDriver
262+ class SHT3xAnalogSensor
275263{
276264public:
277265
@@ -281,19 +269,11 @@ class SHT3xAnalogSensor : public SHTSensorDriver
281269 * An optional `readResolutionBits' can be set since the Arduino/Genuino Zero
282270 * support 12bit precision analog readings. By default, 10 bit precision is
283271 * used.
284- * The analog instance can then (a) be used directly or (b) be passed to the
285- * SHTDriver instance for transparent usage accross SHT drivers:
286272 *
287- * Example (a) :
273+ * Example usage :
288274 * SHT3xAnalogSensor sht3xAnalog(HUMIDITY_PIN, TEMPERATURE_PIN);
289275 * float humidity = sht.readHumidity();
290- *
291- * Example (b):
292- * SHT3xAnalogSensor shtDriver(HUMIDITY_PIN, TEMPERATURE_PIN);
293- * SHTDriver sht(SHTDriver::SHT3xAnalog);
294- * sht.init(&shtDriver)
295- * sht.readSample();
296- * float temperature = sht.getTemperature();
276+ * float temperature = sht.readTemperature();
297277 */
298278 SHT3xAnalogSensor (uint8_t humidityPin, uint8_t temperaturePin,
299279 uint8_t readResolutionBits = 10 )
@@ -306,8 +286,6 @@ class SHT3xAnalogSensor : public SHTSensorDriver
306286 {
307287 }
308288
309- virtual bool readSample ();
310-
311289 float readHumidity ();
312290 float readTemperature ();
313291
0 commit comments