doxyclang
This commit is contained in:
parent
c2bddcf43c
commit
8d48fd2708
2 changed files with 43 additions and 32 deletions
|
|
@ -30,13 +30,13 @@
|
||||||
#include "Adafruit_SHTC3.h"
|
#include "Adafruit_SHTC3.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief SHTC3 constructor using i2c
|
* @brief SHTC3 constructor
|
||||||
* @param *theWire
|
|
||||||
* optional wire
|
|
||||||
*/
|
*/
|
||||||
Adafruit_SHTC3::Adafruit_SHTC3(void) {
|
Adafruit_SHTC3::Adafruit_SHTC3(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief SHTC3 destructor
|
||||||
|
*/
|
||||||
Adafruit_SHTC3::~Adafruit_SHTC3(void) {
|
Adafruit_SHTC3::~Adafruit_SHTC3(void) {
|
||||||
if (temp_sensor) {
|
if (temp_sensor) {
|
||||||
delete temp_sensor;
|
delete temp_sensor;
|
||||||
|
|
@ -49,7 +49,7 @@ Adafruit_SHTC3::~Adafruit_SHTC3(void) {
|
||||||
/**
|
/**
|
||||||
* Initialises the I2C bus, and assigns the I2C address to us.
|
* Initialises the I2C bus, and assigns the I2C address to us.
|
||||||
*
|
*
|
||||||
* @param i2caddr The I2C address to use for the sensor.
|
* @param theWire The I2C bus to use, defaults to &Wire
|
||||||
*
|
*
|
||||||
* @return True if initialisation was successful, otherwise False.
|
* @return True if initialisation was successful, otherwise False.
|
||||||
*/
|
*/
|
||||||
|
|
@ -63,7 +63,7 @@ bool Adafruit_SHTC3::begin(TwoWire *theWire) {
|
||||||
if (!i2c_dev->begin()) {
|
if (!i2c_dev->begin()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
sleep(false);
|
sleep(false);
|
||||||
|
|
||||||
|
|
@ -76,6 +76,11 @@ bool Adafruit_SHTC3::begin(TwoWire *theWire) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Brings the SHTC3 in or out of sleep mode
|
||||||
|
*
|
||||||
|
* @param sleepmode If true, go into sleep mode. Else, wakeup
|
||||||
|
*/
|
||||||
void Adafruit_SHTC3::sleep(bool sleepmode) {
|
void Adafruit_SHTC3::sleep(bool sleepmode) {
|
||||||
if (sleepmode) {
|
if (sleepmode) {
|
||||||
writeCommand(SHTC3_SLEEP);
|
writeCommand(SHTC3_SLEEP);
|
||||||
|
|
@ -85,10 +90,13 @@ void Adafruit_SHTC3::sleep(bool sleepmode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_SHTC3::lowPowerMode(bool readmode) {
|
/**
|
||||||
_lpMode = readmode;
|
* @brief Tells the SHTC3 to read future data in low power (fast) or normal
|
||||||
}
|
* (precise)
|
||||||
|
*
|
||||||
|
* @param readmode If true, use low power mode for reads
|
||||||
|
*/
|
||||||
|
void Adafruit_SHTC3::lowPowerMode(bool readmode) { _lpMode = readmode; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID register contents.
|
* Gets the ID register contents.
|
||||||
|
|
@ -140,7 +148,7 @@ bool Adafruit_SHTC3::getEvent(sensors_event_t *humidity,
|
||||||
delay(13);
|
delay(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (! i2c_dev->read(readbuffer, sizeof(readbuffer))) {
|
while (!i2c_dev->read(readbuffer, sizeof(readbuffer))) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,8 +197,6 @@ void Adafruit_SHTC3::fillHumidityEvent(sensors_event_t *humidity,
|
||||||
humidity->relative_humidity = _humidity;
|
humidity->relative_humidity = _humidity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the Adafruit_Sensor object for the SHTC3's humidity sensor
|
* @brief Gets the Adafruit_Sensor object for the SHTC3's humidity sensor
|
||||||
*
|
*
|
||||||
|
|
@ -288,7 +294,8 @@ bool Adafruit_SHTC3::writeCommand(uint16_t command) {
|
||||||
*
|
*
|
||||||
* @param cmd The 16-bit command ID to send.
|
* @param cmd The 16-bit command ID to send.
|
||||||
*/
|
*/
|
||||||
bool Adafruit_SHTC3::readCommand(uint16_t command, uint8_t *buffer, uint8_t num_bytes) {
|
bool Adafruit_SHTC3::readCommand(uint16_t command, uint8_t *buffer,
|
||||||
|
uint8_t num_bytes) {
|
||||||
uint8_t cmd[2];
|
uint8_t cmd[2];
|
||||||
|
|
||||||
cmd[0] = command >> 8;
|
cmd[0] = command >> 8;
|
||||||
|
|
@ -297,7 +304,6 @@ bool Adafruit_SHTC3::writeCommand(uint16_t command) {
|
||||||
return i2c_dev->write_then_read(cmd, 2, buffer, num_bytes);
|
return i2c_dev->write_then_read(cmd, 2, buffer, num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a CRC8 calculation on the supplied values.
|
* Performs a CRC8 calculation on the supplied values.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -25,20 +25,27 @@
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
|
|
||||||
#define SHTC3_DEFAULT_ADDR 0x70 /**< SHTC3 I2C Address */
|
#define SHTC3_DEFAULT_ADDR 0x70 /**< SHTC3 I2C Address */
|
||||||
#define SHTC3_NORMAL_MEAS_TFIRST_STRETCH 0x7CA2 /**< Normal measurement, temp first with Clock Stretch Enabled */
|
#define SHTC3_NORMAL_MEAS_TFIRST_STRETCH \
|
||||||
#define SHTC3_LOWPOW_MEAS_TFIRST_STRETCH 0x6458 /**< Low power measurement, temp first with Clock Stretch Enabled */
|
0x7CA2 /**< Normal measurement, temp first with Clock Stretch Enabled */
|
||||||
#define SHTC3_NORMAL_MEAS_HFIRST_STRETCH 0x5C24 /**< Normal measurement, hum first with Clock Stretch Enabled */
|
#define SHTC3_LOWPOW_MEAS_TFIRST_STRETCH \
|
||||||
#define SHTC3_LOWPOW_MEAS_HFIRST_STRETCH 0x44DE /**< Low power measurement, hum first with Clock Stretch Enabled */
|
0x6458 /**< Low power measurement, temp first with Clock Stretch Enabled */
|
||||||
|
#define SHTC3_NORMAL_MEAS_HFIRST_STRETCH \
|
||||||
|
0x5C24 /**< Normal measurement, hum first with Clock Stretch Enabled */
|
||||||
|
#define SHTC3_LOWPOW_MEAS_HFIRST_STRETCH \
|
||||||
|
0x44DE /**< Low power measurement, hum first with Clock Stretch Enabled */
|
||||||
|
|
||||||
#define SHTC3_NORMAL_MEAS_TFIRST 0x7866 /**< Normal measurement, temp first with Clock Stretch disabled */
|
#define SHTC3_NORMAL_MEAS_TFIRST \
|
||||||
#define SHTC3_LOWPOW_MEAS_TFIRST 0x609C /**< Low power measurement, temp first with Clock Stretch disabled */
|
0x7866 /**< Normal measurement, temp first with Clock Stretch disabled */
|
||||||
#define SHTC3_NORMAL_MEAS_HFIRST 0x58E0 /**< Normal measurement, hum first with Clock Stretch disabled */
|
#define SHTC3_LOWPOW_MEAS_TFIRST \
|
||||||
#define SHTC3_LOWPOW_MEAS_HFIRST 0x401A /**< Low power measurement, hum first with Clock Stretch disabled */
|
0x609C /**< Low power measurement, temp first with Clock Stretch disabled */
|
||||||
|
#define SHTC3_NORMAL_MEAS_HFIRST \
|
||||||
|
0x58E0 /**< Normal measurement, hum first with Clock Stretch disabled */
|
||||||
|
#define SHTC3_LOWPOW_MEAS_HFIRST \
|
||||||
|
0x401A /**< Low power measurement, hum first with Clock Stretch disabled */
|
||||||
|
|
||||||
|
#define SHTC3_READID 0xEFC8 /**< Read Out of ID Register */
|
||||||
#define SHTC3_READID 0xEFC8 /**< Read Out of ID Register */
|
#define SHTC3_SOFTRESET 0x805D /**< Soft Reset */
|
||||||
#define SHTC3_SOFTRESET 0x805D /**< Soft Reset */
|
#define SHTC3_SLEEP 0xB098 /**< Enter sleep mode */
|
||||||
#define SHTC3_SLEEP 0xB098 /**< Enter sleep mode */
|
|
||||||
#define SHTC3_WAKEUP 0x3517 /**< Wakeup mode */
|
#define SHTC3_WAKEUP 0x3517 /**< Wakeup mode */
|
||||||
|
|
||||||
static uint8_t crc8(const uint8_t *data, int len);
|
static uint8_t crc8(const uint8_t *data, int len);
|
||||||
|
|
@ -82,8 +89,6 @@ private:
|
||||||
Adafruit_SHTC3 *_theSHTC3 = NULL;
|
Adafruit_SHTC3 *_theSHTC3 = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Driver for the Adafruit SHTC3 Temperature and Humidity breakout board.
|
* Driver for the Adafruit SHTC3 Temperature and Humidity breakout board.
|
||||||
*/
|
*/
|
||||||
|
|
@ -109,12 +114,12 @@ protected:
|
||||||
uint16_t _sensorid_humidity; ///< ID number for humidity
|
uint16_t _sensorid_humidity; ///< ID number for humidity
|
||||||
uint16_t _sensorid_temp; ///< ID number for temperature
|
uint16_t _sensorid_temp; ///< ID number for temperature
|
||||||
|
|
||||||
Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface
|
Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface
|
||||||
Adafruit_SHTC3_Temp *temp_sensor = NULL; ///< Temp sensor data object
|
Adafruit_SHTC3_Temp *temp_sensor = NULL; ///< Temp sensor data object
|
||||||
Adafruit_SHTC3_Humidity *humidity_sensor =
|
Adafruit_SHTC3_Humidity *humidity_sensor =
|
||||||
NULL; ///< Humidity sensor data object
|
NULL; ///< Humidity sensor data object
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _lpMode = false;
|
bool _lpMode = false;
|
||||||
bool writeCommand(uint16_t cmd);
|
bool writeCommand(uint16_t cmd);
|
||||||
bool readCommand(uint16_t command, uint8_t *buffer, uint8_t num_bytes);
|
bool readCommand(uint16_t command, uint8_t *buffer, uint8_t num_bytes);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue