Skip to content

Commit f386556

Browse files
committed
freq and duration working
1 parent ef0ec2f commit f386556

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/SparkFun_Qwiic_Buzzer_Arduino_Library.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ bool QwiicBuzzer::BUZZERconfig(uint16_t toneFrequency, uint16_t duration, uint8_
119119
success &= writeSingleRegister(SFE_QWIIC_BUZZER_DURATION_MSB, durationMSB);
120120
success &= writeSingleRegister(SFE_QWIIC_BUZZER_DURATION_LSB, durationLSB);
121121

122+
if(volume > 0)
123+
{
124+
success &= setBuzzerActiveReg();
125+
}
126+
else
127+
{
128+
success &= clearBuzzerActiveReg();
129+
}
130+
122131
return success;
123132
}
124133

@@ -147,6 +156,16 @@ bool QwiicBuzzer::saveSettings()
147156
return writeSingleRegister(SFE_QWIIC_BUZZER_SAVE_SETTINGS, 0x01);
148157
}
149158

159+
bool QwiicBuzzer::setBuzzerActiveReg()
160+
{
161+
return writeSingleRegister(SFE_QWIIC_BUZZER_ACTIVE, 0x01);
162+
}
163+
164+
bool QwiicBuzzer::clearBuzzerActiveReg()
165+
{
166+
return writeSingleRegister(SFE_QWIIC_BUZZER_ACTIVE, 0x00);
167+
}
168+
150169
/*------------------------- Internal I2C Abstraction ---------------- */
151170

152171
uint8_t QwiicBuzzer::readSingleRegister(Qwiic_Button_Register reg)

src/SparkFun_Qwiic_Buzzer_Arduino_Library.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class QwiicBuzzer
8282
bool on(uint16_t toneFrequency = 2730, uint16_t duration = 0, uint8_t volume = 3);
8383
bool off();
8484
bool saveSettings(); // store settings to EEPROM
85+
bool setBuzzerActiveReg();
86+
bool clearBuzzerActiveReg();
8587

8688
//Internal I2C Abstraction
8789
uint8_t readSingleRegister(Qwiic_Button_Register reg); //Reads a single 8-bit register.

0 commit comments

Comments
 (0)