Javascript wrappers for LPS22HB Sensor library
Dependencies: LPS22HB
Diff: LPS22HB_JS.cpp
- Revision:
- 5:e92dbbec30d7
- Parent:
- 4:c2cf5deba40f
- Child:
- 6:a480866ede7e
--- a/LPS22HB_JS.cpp Wed Oct 25 13:58:34 2017 +0200 +++ b/LPS22HB_JS.cpp Tue Oct 31 16:20:09 2017 +0100 @@ -82,19 +82,93 @@ /* 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 helper class which handles the DevI2C peripheral */ LPS22HB_JS::LPS22HB_JS(DevI2C &devI2c){ + init(devI2c); +} + +/** init + * @brief Initializing the component. + * @param DevI2c object of helper class which handles the DevI2C peripheral + */ +void LPS22HB_JS::init(DevI2C &devI2c){ press_temp = new LPS22HBSensor(&devI2c); press_temp->init(NULL); press_temp->enable(); } +/** Constructor + * @brief Initializing the component. + * @param DevI2c object of helper class which handles the DevI2C peripheral + * @param Address + * @param INT pin + */ +LPS22HB_JS::LPS22HB_JS(DevI2C &devI2c, uint8_t address, PinName int_pin){ + init(devI2c, address, int_pin); +} + +/** init + * @brief Initializing the component. + * @param DevI2c object of helper class which handles the DevI2C peripheral + * @param Address + * @param INT pin + */ +void LPS22HB_JS::init(DevI2C &devI2c, uint8_t address, PinName int_pin){ + press_temp = new LPS22HBSensor(&devI2c, address, int_pin); + press_temp->init(NULL); + press_temp->enable(); +} + +/** Constructor + * @brief Initializing the component. + * @param SPI object of helper class which handles the SPI peripheral + * @param CS pin + */ +LPS22HB_JS::LPS22HB_JS(SPI &spi, PinName cs_pin){ + init(spi, cs_pin); +} + +/** init + * @brief Initializing the component. + * @param SPI object of helper class which handles the SPI peripheral + * @param CS pin + */ +void LPS22HB_JS::init(SPI &spi, PinName cs_pin){ + press_temp = new LPS22HBSensor(&spi, cs_pin); + press_temp->init(NULL); + press_temp->enable(); +} + +/** Constructor + * @brief Initializing the component. + * @param SPI object of helper class which handles the SPI peripheral + * @param CS pin + * @param INT pin + * @param SPI type + */ +LPS22HB_JS::LPS22HB_JS(SPI &spi, PinName cs_pin, PinName int_pin, int spi_type){ + init(spi, cs_pin, int_pin, spi_type); +} + +/** init + * @brief Initializing the component. + * @param SPI object of helper class which handles the SPI peripheral + * @param CS pin + * @param INT pin + * @param SPI type + */ +void LPS22HB_JS::init(SPI &spi, PinName cs_pin, PinName int_pin, int spi_type){ + press_temp = new LPS22HBSensor(&spi, cs_pin, int_pin, spi_type == 3? LPS22HBSensor::SPI3W: LPS22HBSensor::SPI4W); + press_temp->init(NULL); + press_temp->enable(); +} + /** Destructor - * @brief Recycling the component. - * Deletes the Sensor Object + * @brief Recycling the component. Deletes the Sensor Object */ LPS22HB_JS::~LPS22HB_JS(){ if(press_temp != NULL){ @@ -102,9 +176,9 @@ } } -/** - * @brief Read ID address of LPS22HB - * @retval The ID of the Sensor +/** readID + * @brief Read ID address of LPS22HB + * @retval The ID of the Sensor */ uint8_t LPS22HB_JS::readID(){ uint8_t result; @@ -112,19 +186,19 @@ return result; } -/** - * @brief Get the temperature reading from LPS22HB - * @retval Temperature value +/** get_temperature + * @brief Gets the temperature reading from LPS22HB + * @retval Temperature value */ float LPS22HB_JS::get_temperature(){ float value; press_temp->get_temperature(&value); - return value; + return value; } -/** - * @brief Get the temperature reading from LPS22HB - * @retval Temperature value in string form +/** get_temperature_string + * @brief Gets the temperature reading from LPS22HB + * @retval Temperature value in string form */ char *LPS22HB_JS::get_temperature_string(char *buffer){ float value; @@ -133,24 +207,23 @@ return buffer; } -/** - * @brief Get the pressure reading from LPS22HB - * @retval pressure value +/** get_pressure + * @brief Gets the pressure reading from LPS22HB + * @retval Pressure value */ float LPS22HB_JS::get_pressure(){ float value; press_temp->get_pressure(&value); - return value; + return value; } - -/** - * @brief Get the pressure reading from LPS22HB - * @retval pressure value in string form +/** get_pressure_string + * @brief Gets the pressure reading from LPS22HB + * @retval pressure value in string form */ char *LPS22HB_JS::get_pressure_string(char *buffer){ float value; press_temp->get_pressure(&value); print_double(buffer, value); return buffer; -} +} \ No newline at end of file