Javascript wrappers for HTS221 Sensor library
Dependencies: HTS221
Diff: HTS221_JS.cpp
- Revision:
- 5:bbe15d3cac27
- Parent:
- 4:6043b9511072
- Child:
- 6:b2c4b0678856
--- a/HTS221_JS.cpp Wed Oct 25 13:58:13 2017 +0200 +++ b/HTS221_JS.cpp Tue Oct 31 16:18:15 2017 +0100 @@ -83,18 +83,88 @@ /* Class Implementation ------------------------------------------------------*/ /** Constructor - * @brief Initializing the component. - * @param devI2c object of an helper class which handles the DevI2C peripheral + * @brief Initializing the component. + * @param devI2c object of an helper class which handles the DevI2C peripheral */ HTS221_JS::HTS221_JS(DevI2C &devI2c){ + init(devI2c); +} + +/** init + * @brief Initializing the component. + * @param devI2c object of an helper class which handles the DevI2C peripheral + */ +void HTS221_JS::init(DevI2C &devI2c){ hum_temp = new HTS221Sensor(&devI2c); hum_temp->init(NULL); hum_temp->enable(); } +/** Constructor + * @brief Initializing the component. + * @param devI2c object of an helper class which handles the DevI2C peripheral + * @param address + * @param drdy pin + */ +HTS221_JS::HTS221_JS(DevI2C &devI2c, uint8_t address, PinName drdy_pin){ + init(devI2c, address, drdy_pin); +} + +/** init + * @brief Initializing the component. + * @param devI2c object of an helper class which handles the DevI2C peripheral + * @param address + * @param drdy pin + */ +void HTS221_JS::init(DevI2C &devI2c, uint8_t address, PinName drdy_pin){ + hum_temp = new HTS221Sensor(&devI2c, address, drdy_pin); + hum_temp->init(NULL); + hum_temp->enable(); +} + +/** Constructor + * @brief Initializing the component. + * @param spi object of an helper class which handles the SPI peripheral + */ +HTS221_JS::HTS221_JS(SPI &spi){ + init(spi); +} + +/** init + * @brief Initializing the component. + * @param spi object of an helper class which handles the SPI peripheral + */ +void HTS221_JS::init(SPI &spi){ + hum_temp = new HTS221Sensor(&spi); + hum_temp->init(NULL); + hum_temp->enable(); +} + +/** Constructor + * @brief Initializing the component. + * @param spi object of an helper class which handles the SPI peripheral + * @param cs pin + * @param drdy pin + */ +HTS221_JS::HTS221_JS(SPI &spi, PinName cs_pin, PinName drdy_pin){ + init(spi, cs_pin, drdy_pin); +} + +/** init + * @brief Initializing the component. + * @param spi object of an helper class which handles the SPI peripheral + * @param cs pin + * @param drdy pin + */ +void HTS221_JS::init(SPI &spi, PinName cs_pin, PinName drdy_pin){ + hum_temp = new HTS221Sensor(&spi, cs_pin, drdy_pin); + hum_temp->init(NULL); + hum_temp->enable(); +} + /** Destructor - * @brief Recycling the component. - * Deletes the Sensor Object + * @brief Recycle the component. + * Deletes the Sensor Object */ HTS221_JS::~HTS221_JS(){ if(hum_temp != NULL){ @@ -103,8 +173,8 @@ } /** - * @brief Read ID address of HTS221 - * @retval The ID of the Sensor + * @brief Read ID address of HTS221 + * @retval The ID of the Sensor */ uint8_t HTS221_JS::readID(){ uint8_t result; @@ -113,8 +183,8 @@ } /** - * @brief Get the temperature reading from HTS221 - * @retval Temperature value + * @brief Get the temperature reading from HTS221 + * @retval Temperature value */ float HTS221_JS::get_temperature(){ float value; @@ -123,8 +193,8 @@ } /** - * @brief Get the temperature reading from HTS221 - * @retval Temperature value in string + * @brief Get the temperature reading from HTS221 + * @retval Temperature value in string */ char *HTS221_JS::get_temperature_string(char *buffer){ float value; @@ -134,8 +204,8 @@ } /** - * @brief Get the humidity reading from HTS221 - * @retval Humidity value + * @brief Get the humidity reading from HTS221 + * @retval Humidity value */ float HTS221_JS::get_humidity(){ float value; @@ -144,8 +214,8 @@ } /** - * @brief Get the humidity reading from HTS221 - * @retval Humidity value in string + * @brief Get the humidity reading from HTS221 + * @retval Humidity value in string */ char *HTS221_JS::get_humidity_string(char *buffer){ float value;