SparkFun Qwiic Ultrasonic Distance Sensor  v1.1.2-5-gc1d2217
SparkFun Qwiic Ultrasonic Distance Sensor
Loading...
Searching...
No Matches
sfeQwiicUltrasonic Class Reference

#include <sfeQwiicUltrasonic.h>

Inheritance diagram for sfeQwiicUltrasonic:

Public Member Functions

 sfeQwiicUltrasonic ()
 Default constructor. More...
 
 sfeQwiicUltrasonic (const uint8_t fwVersion)
 Alternate constructor. More...
 
sfeTkError_t begin (sfeTkII2C *theBus=nullptr)
 Begins the Qwiic Ultrasonic sensor. More...
 
sfeTkError_t isConnected ()
 Checks if the Qwiic Ultrasonic sensor is connected. More...
 
sfeTkError_t triggerAndRead (uint16_t &distance)
 Triggers a new measurement and reads the previous one. More...
 
sfeTkError_t changeAddress (uint8_t &address)
 Changes the I2C address of older Qwiic Ultrasonic sensors. More...
 
uint8_t getAddress ()
 Gets the current I2C address being used by the library for the Qwiic Ultrasonic sensor. More...
 

Protected Attributes

sfeTkII2C * _theBus
 

Constructor & Destructor Documentation

◆ sfeQwiicUltrasonic() [1/2]

sfeQwiicUltrasonic::sfeQwiicUltrasonic ( )
inline

Default constructor.

◆ sfeQwiicUltrasonic() [2/2]

sfeQwiicUltrasonic::sfeQwiicUltrasonic ( const uint8_t  fwVersion)
inline

Alternate constructor.

Parameters
fwVersionFirmware version of the Qwiic Ultrasonic Sensor. If using an older version of the sensor, the list of available I2C addresses differs.

Member Function Documentation

◆ begin()

sfeTkError_t sfeQwiicUltrasonic::begin ( sfeTkII2C *  theBus = nullptr)

Begins the Qwiic Ultrasonic sensor.

Parameters
theBusI2C bus to use for communication
Returns
0 for succuss, negative for errors, positive for warnings

◆ changeAddress()

sfeTkError_t sfeQwiicUltrasonic::changeAddress ( uint8_t &  address)

Changes the I2C address of older Qwiic Ultrasonic sensors.

Parameters
addressNew address, must be in the range 0x20 to 0x2F
Returns
0 for succuss, negative for errors, positive for warnings

◆ getAddress()

uint8_t sfeQwiicUltrasonic::getAddress ( )

Gets the current I2C address being used by the library for the Qwiic Ultrasonic sensor.

Returns
The current I2C address, 7-bit unshifted

◆ isConnected()

sfeTkError_t sfeQwiicUltrasonic::isConnected ( )

Checks if the Qwiic Ultrasonic sensor is connected.

Returns
0 for succuss, negative for errors, positive for warnings

◆ triggerAndRead()

sfeTkError_t sfeQwiicUltrasonic::triggerAndRead ( uint16_t &  distance)

Triggers a new measurement and reads the previous one.

Parameters
distanceDistance in mm
Returns
0 for succuss, negative for errors, positive for warnings

Member Data Documentation

◆ _theBus

sfeTkII2C* sfeQwiicUltrasonic::_theBus
protected

The documentation for this class was generated from the following files: