SparkFun Qwiic Buzzer  v1.0.1-17-gba6cd53
Library for the SparkFun Qwiic Buzzer
Loading...
Searching...
No Matches
sfDevBuzzer Class Reference

#include <sfDevBuzzer.h>

Inheritance diagram for sfDevBuzzer:

Public Member Functions

 sfDevBuzzer ()
 Default constructor. More...
 
sfTkError_t begin (sfTkII2C *theBus=nullptr)
 Begins the Qwiic Buzzer. More...
 
sfTkError_t isConnected ()
 Checks if the Qwiic Buzzer is connected. More...
 
sfTkError_t deviceId (uint8_t &deviceId)
 Reads the Device ID of the Qwiic Buzzer. More...
 
bool firmwareVersionMajor (uint8_t &versionMajor)
 Reads the Firmware Version Major of the Qwiic Buzzer. More...
 
bool firmwareVersionMinor (uint8_t &versionMinor)
 Reads the Firmware Version Minor of the Qwiic Buzzer. More...
 
sfTkError_t configureBuzzer (const uint16_t toneFrequency=SFE_QWIIC_BUZZER_RESONANT_FREQUENCY, const uint16_t duration=0, const uint8_t volume=4)
 Configures the Qwiic Buzzer without causing the buzzer to buzz. This allows configuration in silence (before you may want to buzz). It is also useful in combination with saveSettings(), and then later causing buzzing by using the physical TRIGGER pin. To start buzzing (via Qwiic) with your desired configuration, use this function, then call on(). More...
 
sfTkError_t on ()
 Turns on buzzer. More...
 
sfTkError_t off ()
 Turns off buzzer. More...
 
sfTkError_t saveSettings ()
 Stores settings to EEPROM. More...
 
sfTkError_t setAddress (const uint8_t &address)
 Changes the I2C address of the Qwiic Buzzer. More...
 
uint8_t address ()
 Gets the current I2C address of the Qwiic Buzzer. More...
 
bool playSoundEffect (const uint8_t soundEffectNumber, const uint8_t volume)
 Plays one of the sound effects included in this library. More...
 

Protected Attributes

sfTkII2C * _theBus
 

Constructor & Destructor Documentation

◆ sfDevBuzzer()

sfDevBuzzer::sfDevBuzzer ( )
inline

Default constructor.

Member Function Documentation

◆ address()

uint8_t sfDevBuzzer::address ( )

Gets the current I2C address of the Qwiic Buzzer.

Returns
The current I2C address, 7-bit unshifted

◆ begin()

sfTkError_t sfDevBuzzer::begin ( sfTkII2C *  theBus = nullptr)

Begins the Qwiic Buzzer.

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

◆ configureBuzzer()

sfTkError_t sfDevBuzzer::configureBuzzer ( const uint16_t  toneFrequency = SFE_QWIIC_BUZZER_RESONANT_FREQUENCY,
const uint16_t  duration = 0,
const uint8_t  volume = 4 
)

Configures the Qwiic Buzzer without causing the buzzer to buzz. This allows configuration in silence (before you may want to buzz). It is also useful in combination with saveSettings(), and then later causing buzzing by using the physical TRIGGER pin. To start buzzing (via Qwiic) with your desired configuration, use this function, then call on().

Parameters
toneFrequencyFrequency in Hz of buzzer tone
durationDuration in milliseconds (0 = forever)
volumeVolume (4 settings; 0=off, 1=quiet... 4=loudest)
Returns
0 for succuss, negative for errors, positive for warnings

◆ deviceId()

sfTkError_t sfDevBuzzer::deviceId ( uint8_t &  deviceId)

Reads the Device ID of the Qwiic Buzzer.

Parameters
deviceIduint8_t variable where the read results will be stored
Returns
0 for succuss, negative for errors, positive for warnings

◆ firmwareVersionMajor()

bool sfDevBuzzer::firmwareVersionMajor ( uint8_t &  versionMajor)

Reads the Firmware Version Major of the Qwiic Buzzer.

Parameters
versionMajorVariable where the read results will be stored
Returns
1 for succuss, 0 error

◆ firmwareVersionMinor()

bool sfDevBuzzer::firmwareVersionMinor ( uint8_t &  versionMinor)

Reads the Firmware Version Minor of the Qwiic Buzzer.

Parameters
versionMinorVariable where the read results will be stored
Returns
1 for succuss, 0 error

◆ isConnected()

sfTkError_t sfDevBuzzer::isConnected ( )

Checks if the Qwiic Buzzer is connected.

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

◆ off()

sfTkError_t sfDevBuzzer::off ( )

Turns off buzzer.

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

◆ on()

sfTkError_t sfDevBuzzer::on ( )

Turns on buzzer.

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

◆ playSoundEffect()

bool sfDevBuzzer::playSoundEffect ( const uint8_t  soundEffectNumber,
const uint8_t  volume 
)

Plays one of the sound effects included in this library.

Parameters
soundEffectNumberThe sound effect you with to play
volumeVolume (4 settings; 0=off, 1=quiet... 4=loudest)
Returns
1 for succuss, 0 error

◆ saveSettings()

sfTkError_t sfDevBuzzer::saveSettings ( )

Stores settings to EEPROM.

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

◆ setAddress()

sfTkError_t sfDevBuzzer::setAddress ( const uint8_t &  address)

Changes the I2C address of the Qwiic Buzzer.

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

Member Data Documentation

◆ _theBus

sfTkII2C* sfDevBuzzer::_theBus
protected

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