diff --git a/README.md b/README.md index 9b9fcb7..7fa43a7 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,163 @@ -SparkFun Qwiic Buzzer Arduino Library [![Build Status](https://travis-ci.org/sparkfun/SparkFun_Qwiic_Buzzer_Arduino_Library.svg?branch=master)](https://travis-ci.org/sparkfun/SparkFun_Qwiic_Buzzer_Arduino_Library) -======================================== -[![SparkFun Qwiic Buzzer](https://cdn.sparkfun.com/r/600-600/assets/parts/2/4/8/3/2/BOB-24474-Qwiic-Buzzer-Feature.jpg)](https://www.sparkfun.com/products/24474) +![SparkFun Qwiic Buzzer](docs/images/gh-banner-2025-arduino-buzzer.png "SparkFun Qwiic Buzzer") -[*SparkFun Qwiic Buzzer (BOB-24474)*](https://www.sparkfun.com/products/24474) +# SparkFun Qwiic Buzzer - +This library provides an interface that enables the following functionality when a SparkFun Qwiic Buzzer breakout board: -Repository Contents -------------------- +* Turn the buzzer on and off +* Adjust the buzzers frequency and duration +* Control the the volume of the buzzer +* Play sound effects on the buzzer +* Change the I2C address to enable the use of multiple buzzers on one device -* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE. -* **/src** - Source files for the library (.cpp, .h). -* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE. -* **library.properties** - General library properties for the Arduino package manager. -Documentation --------------- +## General Use +The following outlines the general use of the library in an Arduino Sketch. -* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library. -* **[Product Repository](https://github.com/sparkfun/SparkFun_Qwiic_Buzzer)** - Main repository (including hardware files) for the SparkFun Qwiic Buzzer Breakout Board. -* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Buzzer)** - Basic hookup guide for the Qwiic Buzzer. +### Declaration -Products that use this Library ---------------------------------- +At the start of your sketch, the library header file is included using the following statement: -* [*BOB-24474*](https://www.sparkfun.com/products/24474) - Initial release +~~~cpp +#include +~~~ -Version History ---------------- +Before the arduino ```setup()``` function, create a Buzzer object in your file with the following declaration: -* v1.0.0 - Initial Public release. +~~~c +QwiicBuzzer buzzer; // its a buzzer +~~~ -License Information -------------------- -This product is _**open source**_! +### Initialization -Please review the LICENSE.md file for license information. +In the Arduino ```setup()``` function, initialize the buzzer by calling the begin method. This method is called after the Arduino `Wire` (I2C) library is initialized. -If you have any questions or concerns on licensing, please contact technical support on our [SparkFun forums](https://forum.sparkfun.com/viewforum.php?f=152). +~~~cpp +//check if buzzer will connect over I2C +if (buzzer.begin() == false) { +Serial.println("Device did not connect! Freezing."); +while (1); +} +~~~ + +The begin method returns true if the buzzer is connected and available, and false if it is not. If a value of *false* is returned in the above example, the sketch execution is halted. + +### Usage + +#### On/Off + +Turn the buzzer on and off as shown in the following loop example: + +~~~cpp +void loop() { + buzzer.on(); + + delay(1000); + + buzzer.off(); + + delay(1000); +} +~~~ + +#### Frequency Control + +The buzzer frequency is controlled using the ```configureBuzzer()``` method. + +~~~cpp +void loop() { + // Configure with desired settings + // Resonant frequency is 2.73KHz + buzzer.configureBuzzer(SFE_QWIIC_BUZZER_RESONANT_FREQUENCY); + buzzer.on(); + delay(100); + + buzzer.off(); + delay(1000); + + buzzer.configureBuzzer(1000); // set frequency to 1KHz + buzzer.on(); + delay(100); + + buzzer.off(); + delay(1000); +} +~~~ + +#### Buzz Duration + +The buzz duration is set by adding a timing value after the frequency to the ```configureBuzzer()``` method. + +~~~cpp + buzzer.configureBuzzer(2730, 100); // frequency: 2.73KHz, duration: 100ms +~~~ + +#### Volume + +The buzz volume is an additional optional parameter to the ```configureBuzzer()``` method. + +~~~cpp +buzzer.configureBuzzer(2730, 100, SFE_QWIIC_BUZZER_VOLUME_MIN); // frequency: 2.73KHz, duration: 100ms, volume: MIN +... +buzzer.configureBuzzer(2730, 100, SFE_QWIIC_BUZZER_VOLUME_MAX); // frequency: 2.73KHz, duration: 100ms, volume: MAX +~~~ + +#### Sound Effects + +The buzzer has a collection of sound effects included in this library. These are started by using the ```playSoundEffect()``` method, providing the number of the sound effect to play. + +Playing sound effect 1: + +~~~cpp + err = buzzer.playSoundEffect(1, BUZZER_VOLUME); +~~~ +## Examples + +The following examples are provided with the library + +- [Buzz](examples/Example_01_Buzz/Example_01_Buzz.ino) - This example shows how to turn the buzzer on and off. +- [Buzz Frequency](examples/Example_02_Buzz_Frequency/Example_02_Buzz_Frequency.ino) - This example shows how to adjust the frequency of the buzzer. +- [Buzz Duration](examples/Example_03_Buzz_Duration/Example_03_Buzz_Duration.ino) - This example shows how to control the buzzer using frequency and duration. +- [Buzz Volume](examples/Example_04_Buzz_Volume/Example_04_Buzz_Volume.ino) - This example shows how to control the buzzer to sound at different volumes. +- [Change I2C Address](examples/Example_05_ChangeI2CAddress/Example_05_ChangeI2CAddress.ino) - A configurator for changing the I2C address on the Qwiic Buzzer that walks the user through finding the address of their buzzer, and then changing it! +- [Save Settings](examples/Example_06_SaveSettings/Example_06_SaveSettings.ino) - This example shows how to save settings to the buzzer. +- [Melody](examples/Example_07_Melody/Example_07_Melody.ino) - TThis example shows how to buzz a melody on the Qwiic Buzzer. +- [Sound Effects](examples/Example_08_Sound_Effects/Example_08_Sound_Effects.ino) - This example demos the sound effects included in this library. +- [Firmware Version](examples/Example_09_FirmwareVersion/Example_09_FirmwareVersion.ino) - This example shows how to read the firmware version from the Qwiic Buzzer +- [Buzz Multiple](examples/Example_10_Buzz_Multiple/Example_10_Buzz_Multiple.ino) - This example shows how to control multiple buzzers. + +## Documentation + +The full API and use documentation for this library is provided [here](https://docs.sparkfun.com/SparkFun_Qwiic_Buzzer_Arduino_Library/). For a quick reference, the main methods available in the library are listed [here](https://docs.sparkfun.com/SparkFun_Qwiic_Buzzer_Arduino_Library/class_qwiic_buzzer.html). + +Curious about the hardware this board works with - visit the SparkFun Qwiic Buzzer [hardware repository](https://github.com/sparkfun/SparkFun_Qwiic_Buzzer). + +The ***Hookup Guide*** for the SparkFun Qwiic Buzzer is available [here](https://docs.sparkfun.com/SparkFun_Qwiic_Buzzer). + +## License Information + +This product is ***open source***! + +This product is licensed using the [MIT Open Source License](https://opensource.org/license/mit). -Distributed as-is; no warranty is given. diff --git a/docs/doxygen/doxygen-config b/docs/doxygen/doxygen-config index 13e10e9..f4c5274 100644 --- a/docs/doxygen/doxygen-config +++ b/docs/doxygen/doxygen-config @@ -171,7 +171,7 @@ ALWAYS_DETAILED_SEC = YES # operators of the base classes will not be shown. # The default value is: NO. -INLINE_INHERITED_MEMB = NO +INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the diff --git a/docs/images/gh-banner-2025-arduino-buzzer.png b/docs/images/gh-banner-2025-arduino-buzzer.png new file mode 100644 index 0000000..8e13f71 Binary files /dev/null and b/docs/images/gh-banner-2025-arduino-buzzer.png differ diff --git a/library.properties b/library.properties index a0c2ab2..4a67963 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun Qwiic Buzzer Library -version=1.0.1 +version=1.1.0 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Communicates with and configures the SparkFun Qwiic Buzzer @@ -7,4 +7,4 @@ paragraph=This library allows the user to control the buzzer frequency/duration, category=Outputs url=https://github.com/sparkfun/SparkFun_Qwiic_Buzzer_Arduino_Library architectures=* -depends=SparkFun Toolkit (<1.0.0) +depends=SparkFun Toolkit (>=1.0.0) diff --git a/src/SparkFun_Qwiic_Buzzer_Arduino_Library.h b/src/SparkFun_Qwiic_Buzzer_Arduino_Library.h index 2276e86..5c16ffd 100644 --- a/src/SparkFun_Qwiic_Buzzer_Arduino_Library.h +++ b/src/SparkFun_Qwiic_Buzzer_Arduino_Library.h @@ -1,34 +1,26 @@ -/****************************************************************************** - SparkFun_Qwiic_Buzzer_Arduino_Library.h - SparkFun Qwiic Buzzer Library header file - - by Pete Lewis @SparkFun Electronics - January 2024 - - Based on original source code written by - Fischer Moseley @ SparkFun Electronics - Original Creation Date: July 24, 2019 - - This file implements the QwiicBuzzer class, prototyped in SparkFun_Qwiic_Buzzer_Arduino_Library.h - - Development environment specifics: - IDE: Arduino 2.2.1 - Hardware Platform: Arduino Uno/SparkFun Redboard - Qwiic Buzzer Version: v10 - - SPDX-License-Identifier: MIT - - Copyright (c) 2024 SparkFun Electronics - - Distributed as-is; no warranty is given. -******************************************************************************/ +/** + * @file SparkFun_Qwiic_Buzzer_Arduino_Library.h + * @brief SparkFun Qwiic Buzzer Library header file + * @author Pete Lewis \@SparkFun Electronics + * @date January 2024 + * + * @note Based on original source code written by Fischer Moseley \@ SparkFun Electronics + * Original Creation Date: July 24, 2019 + * + * @details This file implements the QwiicBuzzer class, prototyped in SparkFun_Qwiic_Buzzer_Arduino_Library.h + * + * @copyright Copyright (c) 2024 SparkFun Electronics. This project is released under the MIT License. + * @license SPDX-License-Identifier: MIT + * + */ #pragma once -#include "sfeQwiicBuzzer.h" +// clang-format off #include - -class QwiicBuzzer : public sfeQwiicBuzzer +#include "sfTk/sfDevBuzzer.h" +// clang-format on +class QwiicBuzzer : public sfDevBuzzer { public: /// @brief Begins the Qwiic Buzzer @@ -41,16 +33,16 @@ class QwiicBuzzer : public sfeQwiicBuzzer _theI2CBus.init(wirePort, address); // Begin the sensor - return sfeQwiicBuzzer::begin(&_theI2CBus) == kSTkErrOk; + return sfDevBuzzer::begin(&_theI2CBus) == ksfTkErrOk; } /// @brief Checks if the Qwiic Buzzer is connected /// @return True if the sensor is connected, false otherwise bool isConnected() { - return sfeQwiicBuzzer::isConnected() == kSTkErrOk; + return sfDevBuzzer::isConnected() == ksfTkErrOk; } private: - sfeTkArdI2C _theI2CBus; + sfTkArdI2C _theI2CBus; }; diff --git a/src/sfeQwiicBuzzer.cpp b/src/sfTk/sfDevBuzzer.cpp similarity index 64% rename from src/sfeQwiicBuzzer.cpp rename to src/sfTk/sfDevBuzzer.cpp index 7bdd329..8722485 100644 --- a/src/sfeQwiicBuzzer.cpp +++ b/src/sfTk/sfDevBuzzer.cpp @@ -1,90 +1,84 @@ -/****************************************************************************** - sfeQwiicBuzzer.h - SparkFun Qwiic Buzzer Library header file - - by Pete Lewis @SparkFun Electronics - January 2024 - - Based on original source code written by - Fischer Moseley @ SparkFun Electronics - Original Creation Date: July 24, 2019 - - Development environment specifics: - IDE: Arduino 2.2.1 - Hardware Platform: Arduino Uno/SparkFun Redboard - Qwiic Buzzer Version: v10 - - SPDX-License-Identifier: MIT - - Copyright (c) 2023 SparkFun Electronics - - Distributed as-is; no warranty is given. -******************************************************************************/ - -#include "sfeQwiicBuzzer.h" - -sfeTkError_t sfeQwiicBuzzer::begin(sfeTkII2C *theBus) +/** + * @file sfDevBuzzer.cpp + * @brief Implementation file for SparkFun Qwiic Buzzer Library + * @author Pete Lewis \@SparkFun Electronics + * @date January 2024 + * + * @note Based on original source code by Fischer Moseley @ SparkFun Electronics + * Original Creation Date: July 24, 2019 + * + * @details This file contains the implementation of the sfDevBuzzer class, which + * provides control functionality for the SparkFun Qwiic Buzzer hardware. + * + * @copyright Copyright (c) 2023-2025 SparkFun Electronics. This project is released under the MIT License. + * @license SPDX-License-Identifier: MIT + * + * Distributed as-is; no warranty is given. + */ + +#include "sfDevBuzzer.h" + +sfTkError_t sfDevBuzzer::begin(sfTkII2C *theBus) { // Nullptr check if (theBus == nullptr) - return kSTkErrFail; + return ksfTkErrFail; // Set bus pointer _theBus = theBus; - sfeTkError_t err; + sfTkError_t err; err = isConnected(); // Check whether the ping was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; uint8_t readDeviceId; err = deviceId(readDeviceId); // Check whether the read was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; // check that device ID matches if (readDeviceId != SFE_QWIIC_BUZZER_DEVICE_ID) - return kSTkErrFail; + return ksfTkErrFail; // Done! - return kSTkErrOk; + return ksfTkErrOk; } -sfeTkError_t sfeQwiicBuzzer::isConnected() +sfTkError_t sfDevBuzzer::isConnected() { // Just ping the device address return _theBus->ping(); } -sfeTkError_t sfeQwiicBuzzer::deviceId(uint8_t &deviceId) +sfTkError_t sfDevBuzzer::deviceId(uint8_t &deviceId) { - return _theBus->readRegisterByte(kSfeQwiicBuzzerRegId, deviceId); + return _theBus->readRegister(kSfeQwiicBuzzerRegId, deviceId); } -bool sfeQwiicBuzzer::firmwareVersionMajor(uint8_t &versionMajor) +bool sfDevBuzzer::firmwareVersionMajor(uint8_t &versionMajor) { - sfeTkError_t err; - err = _theBus->readRegisterByte(kSfeQwiicBuzzerRegFirmwareMajor, versionMajor); - if (err == kSTkErrOk) + sfTkError_t err; + err = _theBus->readRegister(kSfeQwiicBuzzerRegFirmwareMajor, versionMajor); + if (err == ksfTkErrOk) return true; else return false; } -bool sfeQwiicBuzzer::firmwareVersionMinor(uint8_t &versionMinor) +bool sfDevBuzzer::firmwareVersionMinor(uint8_t &versionMinor) { - sfeTkError_t err; - err = _theBus->readRegisterByte(kSfeQwiicBuzzerRegFirmwareMinor, versionMinor); - if (err == kSTkErrOk) + sfTkError_t err; + err = _theBus->readRegister(kSfeQwiicBuzzerRegFirmwareMinor, versionMinor); + if (err == ksfTkErrOk) return true; else - return false; + return false; } -sfeTkError_t sfeQwiicBuzzer::configureBuzzer(const uint16_t toneFrequency, const uint16_t duration, - const uint8_t volume) +sfTkError_t sfDevBuzzer::configureBuzzer(const uint16_t toneFrequency, const uint16_t duration, const uint8_t volume) { // All of the necessary configuration register addresses are in sequential order, // starting at "kSfeQwiicBuzzerRegToneFrequencyMsb". @@ -111,52 +105,52 @@ sfeTkError_t sfeQwiicBuzzer::configureBuzzer(const uint16_t toneFrequency, const data[3] = durationMSB; // kSfeQwiicBuzzerRegDurationMsb data[4] = durationLSB; // kSfeQwiicBuzzerRegDurationLsb - return _theBus->writeRegisterRegion(kSfeQwiicBuzzerRegToneFrequencyMsb, data, dataLength); + return _theBus->writeRegister(kSfeQwiicBuzzerRegToneFrequencyMsb, data, dataLength); } -sfeTkError_t sfeQwiicBuzzer::on() +sfTkError_t sfDevBuzzer::on() { - return _theBus->writeRegisterByte(kSfeQwiicBuzzerRegActive, 1); + return _theBus->writeRegisterUInt8(kSfeQwiicBuzzerRegActive, 1); } -sfeTkError_t sfeQwiicBuzzer::off() +sfTkError_t sfDevBuzzer::off() { - return _theBus->writeRegisterByte(kSfeQwiicBuzzerRegActive, 0); + return _theBus->writeRegisterUInt8(kSfeQwiicBuzzerRegActive, 0); } -sfeTkError_t sfeQwiicBuzzer::saveSettings() +sfTkError_t sfDevBuzzer::saveSettings() { - return _theBus->writeRegisterByte(kSfeQwiicBuzzerRegSaveSettings, 1); + return _theBus->writeRegisterUInt8(kSfeQwiicBuzzerRegSaveSettings, 1); } -sfeTkError_t sfeQwiicBuzzer::setAddress(const uint8_t &address) +sfTkError_t sfDevBuzzer::setAddress(const uint8_t &address) { if (address < 0x08 || address > 0x77) { - return kSTkErrFail; // error immediately if the address is out of legal range + return ksfTkErrFail; // error immediately if the address is out of legal range } - sfeTkError_t err = _theBus->writeRegisterByte(kSfeQwiicBuzzerRegI2cAddress, address); + sfTkError_t err = _theBus->writeRegister(kSfeQwiicBuzzerRegI2cAddress, address); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; // Update the address in the bus _theBus->setAddress(address); // Done! - return kSTkErrOk; + return ksfTkErrOk; } -uint8_t sfeQwiicBuzzer::address() +uint8_t sfDevBuzzer::address() { return _theBus->address(); } -bool sfeQwiicBuzzer::playSoundEffect(const uint8_t soundEffectNumber, const uint8_t volume) +bool sfDevBuzzer::playSoundEffect(const uint8_t soundEffectNumber, const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; switch (soundEffectNumber) { @@ -191,169 +185,169 @@ bool sfeQwiicBuzzer::playSoundEffect(const uint8_t soundEffectNumber, const uint err = soundEffect9(volume); break; default: - err = kSTkErrFail; + err = ksfTkErrFail; } - if (err == kSTkErrOk) + if (err == ksfTkErrOk) return true; else return false; } -sfeTkError_t sfeQwiicBuzzer::soundEffect0(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect0(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; for (int note = 150; note < 4000; note += 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } for (int note = 4000; note > 150; note -= 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect1(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect1(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; for (int i = 0; i <= 2; i++) { for (int note = 150; note < 4000; note += 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(2); + sftk_delay_ms(2); } for (int note = 4000; note > 150; note -= 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(2); + sftk_delay_ms(2); } } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect2(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect2(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; for (int note = 150; note < 4000; note += 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(40); + sftk_delay_ms(40); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect3(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect3(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; for (int note = 150; note < 4000; note += 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect4(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect4(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; for (int note = 4000; note > 150; note -= 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(40); + sftk_delay_ms(40); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect5(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect5(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; for (int note = 4000; note > 150; note -= 150) { err = configureBuzzer(note, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect6(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect6(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; int laughdelay = 400; int laughstep = 10; uint16_t i; @@ -362,83 +356,83 @@ sfeTkError_t sfeQwiicBuzzer::soundEffect6(const uint8_t volume) { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(laughdelay); + sftk_delay_ms(laughdelay); for (i = 1250; i < 1515; i += laughstep) // 1250, 1515 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(laughdelay); + sftk_delay_ms(laughdelay); for (i = 1111; i < 1342; i += laughstep) // 1111, 1342 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(laughdelay); + sftk_delay_ms(laughdelay); for (i = 1010; i < 1176; i += laughstep) // 1010, 1176 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect7(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect7(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; int laughdelay = 200; int laughstep = 15; uint16_t i; @@ -447,82 +441,82 @@ sfeTkError_t sfeQwiicBuzzer::soundEffect7(const uint8_t volume) { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(laughdelay); + sftk_delay_ms(laughdelay); for (i = 1250; i < 1515; i += laughstep) // 1250, 1515 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(laughdelay); + sftk_delay_ms(laughdelay); for (i = 1111; i < 1342; i += laughstep) // 1111, 1342 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(laughdelay); + sftk_delay_ms(laughdelay); for (i = 1010; i < 1176; i += laughstep) // 1010, 1176 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect8(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect8(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; int crydelay = 500; int step = 10; uint16_t i; @@ -531,62 +525,62 @@ sfeTkError_t sfeQwiicBuzzer::soundEffect8(const uint8_t volume) { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(crydelay); + sftk_delay_ms(crydelay); for (i = 1667; i > 1250; i -= step) // 1667, 1250 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(crydelay); + sftk_delay_ms(crydelay); for (i = 1429; i > 1053; i -= step) // 1429, 1053 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } -sfeTkError_t sfeQwiicBuzzer::soundEffect9(const uint8_t volume) +sfTkError_t sfDevBuzzer::soundEffect9(const uint8_t volume) { - sfeTkError_t err; + sfTkError_t err; int crydelay = 200; int step = 20; uint16_t i; @@ -595,56 +589,56 @@ sfeTkError_t sfeQwiicBuzzer::soundEffect9(const uint8_t volume) { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(crydelay); + sftk_delay_ms(crydelay); for (i = 1667; i > 1250; i -= step) // 1667, 1250 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } err = off(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(crydelay); + sftk_delay_ms(crydelay); for (i = 1429; i > 1053; i -= step) // 1429, 1053 { err = configureBuzzer(i, 0, volume); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; err = on(); // Check whether the write was successful - if (err != kSTkErrOk) + if (err != ksfTkErrOk) return err; - delay(10); + sftk_delay_ms(10); } return off(); } \ No newline at end of file diff --git a/src/sfeQwiicBuzzer.h b/src/sfTk/sfDevBuzzer.h similarity index 78% rename from src/sfeQwiicBuzzer.h rename to src/sfTk/sfDevBuzzer.h index 0deceea..b9800ba 100644 --- a/src/sfeQwiicBuzzer.h +++ b/src/sfTk/sfDevBuzzer.h @@ -1,34 +1,34 @@ -/****************************************************************************** - sfeQwiicBuzzer.h - SparkFun Qwiic Buzzer Library header file +/** + * @file sfDevBuzzer.h + * @brief Header file for SparkFun Qwiic Buzzer Library + * @author Pete Lewis \@SparkFun Electronics + * @date January 2024 + * + * @note Based on original source code by Fischer Moseley @ SparkFun Electronics + * Original Creation Date: July 24, 2019 + * + * @details This file declares the sfDevBuzzer class which provides control + * functionality for the SparkFun Qwiic Buzzer hardware. The class + * enables I2C communication, configuration of tone frequency, duration, + * volume, and includes several pre-programmed sound effects. + * + * @copyright Copyright (c) 2024-2025 SparkFun Electronics. This project is released under the MIT License. + * @license SPDX-License-Identifier: MIT + * + */ - by Pete Lewis @SparkFun Electronics - January 2024 - - Based on original source code written by - Fischer Moseley @ SparkFun Electronics - Original Creation Date: July 24, 2019 - - This file implements the QwiicBuzzer class, prototyped in SparkFun_Qwiic_Buzzer_Arduino_Library.h - - Development environment specifics: - IDE: Arduino 2.2.1 - Hardware Platform: Arduino Uno/SparkFun Redboard - Qwiic Buzzer Version: v10 - - SPDX-License-Identifier: MIT +#pragma once - Copyright (c) 2023 SparkFun Electronics +#include "sfDevBuzzerPitches.h" +#include "sfDevBuzzerRegisters.h" - Distributed as-is; no warranty is given. -******************************************************************************/ +#include -#pragma once +// include the sparkfun toolkit headers +#include -#include "sfeQwiicBuzzerPitches.h" -#include "sfeQwiicBuzzerRegisters.h" -#include -#include +// Bus interfaces +#include #define SFE_QWIIC_BUZZER_DEFAULT_ADDRESS 0x34 #define SFE_QWIIC_BUZZER_DEVICE_ID 0x5E @@ -39,27 +39,27 @@ #define SFE_QWIIC_BUZZER_VOLUME_MID 3 #define SFE_QWIIC_BUZZER_VOLUME_MAX 4 -class sfeQwiicBuzzer +class sfDevBuzzer { public: /// @brief Default constructor - sfeQwiicBuzzer() : _theBus{nullptr} + sfDevBuzzer() : _theBus{nullptr} { } /// @brief Begins the Qwiic Buzzer /// @param theBus I2C bus to use for communication /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t begin(sfeTkII2C *theBus = nullptr); + sfTkError_t begin(sfTkII2C *theBus = nullptr); /// @brief Checks if the Qwiic Buzzer is connected /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t isConnected(); + sfTkError_t isConnected(); /// @brief Reads the Device ID of the Qwiic Buzzer /// @param deviceId uint8_t variable where the read results will be stored /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t deviceId(uint8_t &deviceId); + sfTkError_t deviceId(uint8_t &deviceId); /// @brief Reads the Firmware Version Major of the Qwiic Buzzer /// @param versionMajor Variable where the read results will be stored @@ -81,25 +81,25 @@ class sfeQwiicBuzzer /// @param duration Duration in milliseconds (0 = forever) /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t configureBuzzer(const uint16_t toneFrequency = SFE_QWIIC_BUZZER_RESONANT_FREQUENCY, - const uint16_t duration = 0, const uint8_t volume = 4); + sfTkError_t configureBuzzer(const uint16_t toneFrequency = SFE_QWIIC_BUZZER_RESONANT_FREQUENCY, + const uint16_t duration = 0, const uint8_t volume = 4); /// @brief Turns on buzzer /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t on(); + sfTkError_t on(); /// @brief Turns off buzzer /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t off(); + sfTkError_t off(); /// @brief Stores settings to EEPROM /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t saveSettings(); + sfTkError_t saveSettings(); /// @brief Changes the I2C address of the Qwiic Buzzer /// @param address New address, must be in the range 0x08 to 0x77 /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t setAddress(const uint8_t &address); + sfTkError_t setAddress(const uint8_t &address); /// @brief Gets the current I2C address of the Qwiic Buzzer /// @return The current I2C address, 7-bit unshifted @@ -118,7 +118,7 @@ class sfeQwiicBuzzer /// single "up and down" cycle. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect0(const uint8_t volume); + sfTkError_t soundEffect0(const uint8_t volume); /// @brief Plays sound effect 1 (aka "3 Fast Sirens") /// Intended to sound like a siren, starting at a low frequency, and then @@ -126,7 +126,7 @@ class sfeQwiicBuzzer /// cycle of "up and down" three times rapidly. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect1(const uint8_t volume); + sfTkError_t soundEffect1(const uint8_t volume); /// @brief Plays sound effect 2 (aka "robot saying 'Yes'") /// Intended to sound like a robot saying the word "yes". @@ -135,7 +135,7 @@ class sfeQwiicBuzzer /// sound to any question you may ask your buzzing robot. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect2(const uint8_t volume); + sfTkError_t soundEffect2(const uint8_t volume); /// @brief Plays sound effect 3 (aka "robot yelling 'YES!'" - faster) /// Intended to sound like a robot saying the word "yes". @@ -145,7 +145,7 @@ class sfeQwiicBuzzer /// is done more quickly, it can add enthusiasm to the buzzing sound. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect3(const uint8_t volume); + sfTkError_t soundEffect3(const uint8_t volume); /// @brief Plays sound effect 4 (aka "robot saying 'No'") /// Intended to sound like a robot saying the word "no". @@ -154,7 +154,7 @@ class sfeQwiicBuzzer /// sound to any question you may ask your buzzing robot. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect4(const uint8_t volume); + sfTkError_t soundEffect4(const uint8_t volume); /// @brief Plays sound effect 5 (aka "robot yelling 'NO!'" - faster) /// Intended to sound like a robot saying the word "no". @@ -164,34 +164,34 @@ class sfeQwiicBuzzer /// is done more quickly, it can add enthusiasm to the buzzing sound. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect5(const uint8_t volume); + sfTkError_t soundEffect5(const uint8_t volume); /// @brief Plays sound effect 6 (aka "Laughing Robot") /// Intended to sound like your robot is laughing at you. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect6(const uint8_t volume); + sfTkError_t soundEffect6(const uint8_t volume); /// @brief Plays sound effect 7 (aka "Laughing Robot Faster") /// Intended to sound like your robot is laughing at you. As this sound /// is done more quickly, it can add enthusiasm to the buzzing sound. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect7(const uint8_t volume); + sfTkError_t soundEffect7(const uint8_t volume); /// @brief Plays sound effect 8 (aka "Crying Robot") /// Intended to sound like a robot is crying and sad. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect8(const uint8_t volume); + sfTkError_t soundEffect8(const uint8_t volume); /// @brief Plays sound effect 9 (aka "Crying Robot Faster") /// Intended to sound like a robot is crying and sad. As this sound /// is done more quickly, it can add enthusiasm to the buzzing sound. /// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest) /// @return 0 for succuss, negative for errors, positive for warnings - sfeTkError_t soundEffect9(const uint8_t volume); + sfTkError_t soundEffect9(const uint8_t volume); protected: - sfeTkII2C *_theBus; + sfTkII2C *_theBus; }; \ No newline at end of file diff --git a/src/sfTk/sfDevBuzzerPitches.h b/src/sfTk/sfDevBuzzerPitches.h new file mode 100644 index 0000000..672f6b6 --- /dev/null +++ b/src/sfTk/sfDevBuzzerPitches.h @@ -0,0 +1,204 @@ +/** + * @file sfDevBuzzerPitches.h + * @brief Header file for SparkFun Qwiic Buzzer Library containing note definitions + * @author Pete Lewis \@SparkFun Electronics + * @date January 2024 + * + * @note Based on original source code written by Tom Igoe in Jan 2010: + * https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMelody + * http://www.arduino.cc/en/Tutorial/Tone + * + * @details This file contains a list of commonly found notes on a piano, defined + * as constants for use with the SparkFun Qwiic Buzzer Library. + * + * + * @copyright Copyright (c) 2024-2025 SparkFun Electronics. This project is released under the MIT License. + * @license SPDX-License-Identifier: MIT + * + */ + +/************************************************* + Public Constants +*************************************************/ + +#define SFE_QWIIC_BUZZER_NOTE_REST 0 +#define SFE_QWIIC_BUZZER_NOTE_B0 31 +#define SFE_QWIIC_BUZZER_NOTE_C1 33 +#define SFE_QWIIC_BUZZER_NOTE_CS1 35 +#define SFE_QWIIC_BUZZER_NOTE_D1 37 +#define SFE_QWIIC_BUZZER_NOTE_DS1 39 +#define SFE_QWIIC_BUZZER_NOTE_E1 41 +#define SFE_QWIIC_BUZZER_NOTE_F1 44 +#define SFE_QWIIC_BUZZER_NOTE_FS1 46 +#define SFE_QWIIC_BUZZER_NOTE_G1 49 +#define SFE_QWIIC_BUZZER_NOTE_GS1 52 +#define SFE_QWIIC_BUZZER_NOTE_A1 55 +#define SFE_QWIIC_BUZZER_NOTE_AS1 58 +#define SFE_QWIIC_BUZZER_NOTE_B1 62 +#define SFE_QWIIC_BUZZER_NOTE_C2 65 +#define SFE_QWIIC_BUZZER_NOTE_CS2 69 +#define SFE_QWIIC_BUZZER_NOTE_D2 73 +#define SFE_QWIIC_BUZZER_NOTE_DS2 78 +#define SFE_QWIIC_BUZZER_NOTE_E2 82 +#define SFE_QWIIC_BUZZER_NOTE_F2 87 +#define SFE_QWIIC_BUZZER_NOTE_FS2 93 +#define SFE_QWIIC_BUZZER_NOTE_G2 98 +#define SFE_QWIIC_BUZZER_NOTE_GS2 104 +#define SFE_QWIIC_BUZZER_NOTE_A2 110 +#define SFE_QWIIC_BUZZER_NOTE_AS2 117 +#define SFE_QWIIC_BUZZER_NOTE_B2 123 +#define SFE_QWIIC_BUZZER_NOTE_C3 131 +#define SFE_QWIIC_BUZZER_NOTE_CS3 139 +#define SFE_QWIIC_BUZZER_NOTE_D3 147 +#define SFE_QWIIC_BUZZER_NOTE_DS3 156 +#define SFE_QWIIC_BUZZER_NOTE_E3 165 +#define SFE_QWIIC_BUZZER_NOTE_F3 175 +#define SFE_QWIIC_BUZZER_NOTE_FS3 185 +#define SFE_QWIIC_BUZZER_NOTE_G3 196 +#define SFE_QWIIC_BUZZER_NOTE_GS3 208 +#define SFE_QWIIC_BUZZER_NOTE_A3 220 +#define SFE_QWIIC_BUZZER_NOTE_AS3 233 +#define SFE_QWIIC_BUZZER_NOTE_B3 247 +#define SFE_QWIIC_BUZZER_NOTE_C4 262 +#define SFE_QWIIC_BUZZER_NOTE_CS4 277 +#define SFE_QWIIC_BUZZER_NOTE_D4 294 +#define SFE_QWIIC_BUZZER_NOTE_DS4 311 +#define SFE_QWIIC_BUZZER_NOTE_E4 330 +#define SFE_QWIIC_BUZZER_NOTE_F4 349 +#define SFE_QWIIC_BUZZER_NOTE_FS4 370 +#define SFE_QWIIC_BUZZER_NOTE_G4 392 +#define SFE_QWIIC_BUZZER_NOTE_GS4 415 +#define SFE_QWIIC_BUZZER_NOTE_A4 440 +#define SFE_QWIIC_BUZZER_NOTE_AS4 466 +#define SFE_QWIIC_BUZZER_NOTE_B4 494 +#define SFE_QWIIC_BUZZER_NOTE_C5 523 +#define SFE_QWIIC_BUZZER_NOTE_CS5 554 +#define SFE_QWIIC_BUZZER_NOTE_D5 587 +#define SFE_QWIIC_BUZZER_NOTE_DS5 622 +#define SFE_QWIIC_BUZZER_NOTE_E5 659 +#define SFE_QWIIC_BUZZER_NOTE_F5 698 +#define SFE_QWIIC_BUZZER_NOTE_FS5 740 +#define SFE_QWIIC_BUZZER_NOTE_G5 784 +#define SFE_QWIIC_BUZZER_NOTE_GS5 831 +#define SFE_QWIIC_BUZZER_NOTE_A5 880 +#define SFE_QWIIC_BUZZER_NOTE_AS5 932 +#define SFE_QWIIC_BUZZER_NOTE_B5 988 +#define SFE_QWIIC_BUZZER_NOTE_C6 1047 +#define SFE_QWIIC_BUZZER_NOTE_CS6 1109 +#define SFE_QWIIC_BUZZER_NOTE_D6 1175 +#define SFE_QWIIC_BUZZER_NOTE_DS6 1245 +#define SFE_QWIIC_BUZZER_NOTE_E6 1319 +#define SFE_QWIIC_BUZZER_NOTE_F6 1397 +#define SFE_QWIIC_BUZZER_NOTE_FS6 1480 +#define SFE_QWIIC_BUZZER_NOTE_G6 1568 +#define SFE_QWIIC_BUZZER_NOTE_GS6 1661 +#define SFE_QWIIC_BUZZER_NOTE_A6 1760 +#define SFE_QWIIC_BUZZER_NOTE_AS6 1865 +#define SFE_QWIIC_BUZZER_NOTE_B6 1976 +#define SFE_QWIIC_BUZZER_NOTE_C7 2093 +#define SFE_QWIIC_BUZZER_NOTE_CS7 2217 +#define SFE_QWIIC_BUZZER_NOTE_D7 2349 +#define SFE_QWIIC_BUZZER_NOTE_DS7 2489 +#define SFE_QWIIC_BUZZER_NOTE_E7 2637 +#define SFE_QWIIC_BUZZER_NOTE_F7 2794 +#define SFE_QWIIC_BUZZER_NOTE_FS7 2960 +#define SFE_QWIIC_BUZZER_NOTE_G7 3136 +#define SFE_QWIIC_BUZZER_NOTE_GS7 3322 +#define SFE_QWIIC_BUZZER_NOTE_A7 3520 +#define SFE_QWIIC_BUZZER_NOTE_AS7 3729 +#define SFE_QWIIC_BUZZER_NOTE_B7 3951 +#define SFE_QWIIC_BUZZER_NOTE_C8 4186 +#define SFE_QWIIC_BUZZER_NOTE_CS8 4435 +#define SFE_QWIIC_BUZZER_NOTE_D8 4699 +#define SFE_QWIIC_BUZZER_NOTE_DS8 4978 + +// Backwards compatibility with original "pitches.h" file written by Tim Igeo, 2010. +#define NOTE_B0 SFE_QWIIC_BUZZER_NOTE_B0 +#define NOTE_C1 SFE_QWIIC_BUZZER_NOTE_C1 +#define NOTE_CS1 SFE_QWIIC_BUZZER_NOTE_CS1 +#define NOTE_D1 SFE_QWIIC_BUZZER_NOTE_D1 +#define NOTE_DS1 SFE_QWIIC_BUZZER_NOTE_DS1 +#define NOTE_E1 SFE_QWIIC_BUZZER_NOTE_E1 +#define NOTE_F1 SFE_QWIIC_BUZZER_NOTE_F1 +#define NOTE_FS1 SFE_QWIIC_BUZZER_NOTE_FS1 +#define NOTE_G1 SFE_QWIIC_BUZZER_NOTE_G1 +#define NOTE_GS1 SFE_QWIIC_BUZZER_NOTE_GS1 +#define NOTE_A1 SFE_QWIIC_BUZZER_NOTE_A1 +#define NOTE_AS1 SFE_QWIIC_BUZZER_NOTE_AS1 +#define NOTE_B1 SFE_QWIIC_BUZZER_NOTE_B1 +#define NOTE_C2 SFE_QWIIC_BUZZER_NOTE_C2 +#define NOTE_CS2 SFE_QWIIC_BUZZER_NOTE_CS2 +#define NOTE_D2 SFE_QWIIC_BUZZER_NOTE_D2 +#define NOTE_DS2 SFE_QWIIC_BUZZER_NOTE_DS2 +#define NOTE_E2 SFE_QWIIC_BUZZER_NOTE_E2 +#define NOTE_F2 SFE_QWIIC_BUZZER_NOTE_F2 +#define NOTE_FS2 SFE_QWIIC_BUZZER_NOTE_FS2 +#define NOTE_G2 SFE_QWIIC_BUZZER_NOTE_G2 +#define NOTE_GS2 SFE_QWIIC_BUZZER_NOTE_GS2 +#define NOTE_A2 SFE_QWIIC_BUZZER_NOTE_A2 +#define NOTE_AS2 SFE_QWIIC_BUZZER_NOTE_AS2 +#define NOTE_B2 SFE_QWIIC_BUZZER_NOTE_B2 +#define NOTE_C3 SFE_QWIIC_BUZZER_NOTE_C3 +#define NOTE_CS3 SFE_QWIIC_BUZZER_NOTE_CS3 +#define NOTE_D3 SFE_QWIIC_BUZZER_NOTE_D3 +#define NOTE_DS3 SFE_QWIIC_BUZZER_NOTE_DS3 +#define NOTE_E3 SFE_QWIIC_BUZZER_NOTE_E3 +#define NOTE_F3 SFE_QWIIC_BUZZER_NOTE_F3 +#define NOTE_FS3 SFE_QWIIC_BUZZER_NOTE_FS3 +#define NOTE_G3 SFE_QWIIC_BUZZER_NOTE_G3 +#define NOTE_GS3 SFE_QWIIC_BUZZER_NOTE_GS3 +#define NOTE_A3 SFE_QWIIC_BUZZER_NOTE_A3 +#define NOTE_AS3 SFE_QWIIC_BUZZER_NOTE_AS3 +#define NOTE_B3 SFE_QWIIC_BUZZER_NOTE_B3 +#define NOTE_C4 SFE_QWIIC_BUZZER_NOTE_C4 +#define NOTE_CS4 SFE_QWIIC_BUZZER_NOTE_CS4 +#define NOTE_D4 SFE_QWIIC_BUZZER_NOTE_D4 +#define NOTE_DS4 SFE_QWIIC_BUZZER_NOTE_DS4 +#define NOTE_E4 SFE_QWIIC_BUZZER_NOTE_E4 +#define NOTE_F4 SFE_QWIIC_BUZZER_NOTE_F4 +#define NOTE_FS4 SFE_QWIIC_BUZZER_NOTE_FS4 +#define NOTE_G4 SFE_QWIIC_BUZZER_NOTE_G4 +#define NOTE_GS4 SFE_QWIIC_BUZZER_NOTE_GS4 +#define NOTE_A4 SFE_QWIIC_BUZZER_NOTE_A4 +#define NOTE_AS4 SFE_QWIIC_BUZZER_NOTE_AS4 +#define NOTE_B4 SFE_QWIIC_BUZZER_NOTE_B4 +#define NOTE_C5 SFE_QWIIC_BUZZER_NOTE_C5 +#define NOTE_CS5 SFE_QWIIC_BUZZER_NOTE_CS5 +#define NOTE_D5 SFE_QWIIC_BUZZER_NOTE_D5 +#define NOTE_DS5 SFE_QWIIC_BUZZER_NOTE_DS5 +#define NOTE_E5 SFE_QWIIC_BUZZER_NOTE_E5 +#define NOTE_F5 SFE_QWIIC_BUZZER_NOTE_F5 +#define NOTE_FS5 SFE_QWIIC_BUZZER_NOTE_FS5 +#define NOTE_G5 SFE_QWIIC_BUZZER_NOTE_G5 +#define NOTE_GS5 SFE_QWIIC_BUZZER_NOTE_GS5 +#define NOTE_A5 SFE_QWIIC_BUZZER_NOTE_A5 +#define NOTE_AS5 SFE_QWIIC_BUZZER_NOTE_AS5 +#define NOTE_B5 SFE_QWIIC_BUZZER_NOTE_B5 +#define NOTE_C6 SFE_QWIIC_BUZZER_NOTE_C6 +#define NOTE_CS6 SFE_QWIIC_BUZZER_NOTE_CS6 +#define NOTE_D6 SFE_QWIIC_BUZZER_NOTE_D6 +#define NOTE_DS6 SFE_QWIIC_BUZZER_NOTE_DS6 +#define NOTE_E6 SFE_QWIIC_BUZZER_NOTE_E6 +#define NOTE_F6 SFE_QWIIC_BUZZER_NOTE_F6 +#define NOTE_FS6 SFE_QWIIC_BUZZER_NOTE_FS6 +#define NOTE_G6 SFE_QWIIC_BUZZER_NOTE_G6 +#define NOTE_GS6 SFE_QWIIC_BUZZER_NOTE_GS6 +#define NOTE_A6 SFE_QWIIC_BUZZER_NOTE_A6 +#define NOTE_AS6 SFE_QWIIC_BUZZER_NOTE_AS6 +#define NOTE_B6 SFE_QWIIC_BUZZER_NOTE_B6 +#define NOTE_C7 SFE_QWIIC_BUZZER_NOTE_C7 +#define NOTE_CS7 SFE_QWIIC_BUZZER_NOTE_CS7 +#define NOTE_D7 SFE_QWIIC_BUZZER_NOTE_D7 +#define NOTE_DS7 SFE_QWIIC_BUZZER_NOTE_DS7 +#define NOTE_E7 SFE_QWIIC_BUZZER_NOTE_E7 +#define NOTE_F7 SFE_QWIIC_BUZZER_NOTE_F7 +#define NOTE_FS7 SFE_QWIIC_BUZZER_NOTE_FS7 +#define NOTE_G7 SFE_QWIIC_BUZZER_NOTE_G7 +#define NOTE_GS7 SFE_QWIIC_BUZZER_NOTE_GS7 +#define NOTE_A7 SFE_QWIIC_BUZZER_NOTE_A7 +#define NOTE_AS7 SFE_QWIIC_BUZZER_NOTE_AS7 +#define NOTE_B7 SFE_QWIIC_BUZZER_NOTE_B7 +#define NOTE_C8 SFE_QWIIC_BUZZER_NOTE_C8 +#define NOTE_CS8 SFE_QWIIC_BUZZER_NOTE_CS8 +#define NOTE_D8 SFE_QWIIC_BUZZER_NOTE_D8 +#define NOTE_DS8 SFE_QWIIC_BUZZER_NOTE_DS8 \ No newline at end of file diff --git a/src/sfTk/sfDevBuzzerRegisters.h b/src/sfTk/sfDevBuzzerRegisters.h new file mode 100644 index 0000000..418cd4d --- /dev/null +++ b/src/sfTk/sfDevBuzzerRegisters.h @@ -0,0 +1,35 @@ +/** + * @file sfDevBuzzerRegisters.h + * @brief Header file defining the virtual memory map for the Qwiic Buzzer + * @author Pete Lewis \@SparkFun Electronics + * @date January 2024 + * + * @note Based on original source code written by Fischer Moseley \@ SparkFun Electronics + * Original Creation Date: July 24, 2019 + * + * @details This file defines the virtual memory map on the Qwiic Buzzer. The enum + * provides a set of pointers for the various registers on the Qwiic Buzzer. + * + * + * @copyright Copyright (c) 2023 SparkFun Electronics. This project is released under the MIT License. + * @license SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include + +// Register Pointer Map + +const uint8_t kSfeQwiicBuzzerRegId = 0x00; +const uint8_t kSfeQwiicBuzzerRegFirmwareMinor = 0x01; +const uint8_t kSfeQwiicBuzzerRegFirmwareMajor = 0x02; +const uint8_t kSfeQwiicBuzzerRegToneFrequencyMsb = 0x03; +const uint8_t kSfeQwiicBuzzerRegToneFrequencyLsb = 0x04; +const uint8_t kSfeQwiicBuzzerRegVolume = 0x05; +const uint8_t kSfeQwiicBuzzerRegDurationMsb = 0x06; +const uint8_t kSfeQwiicBuzzerRegDurationLsb = 0x07; +const uint8_t kSfeQwiicBuzzerRegActive = 0x08; +const uint8_t kSfeQwiicBuzzerRegSaveSettings = 0x09; +const uint8_t kSfeQwiicBuzzerRegI2cAddress = 0x0A; diff --git a/src/sfeQwiicBuzzerPitches.h b/src/sfeQwiicBuzzerPitches.h deleted file mode 100644 index 0ecc23a..0000000 --- a/src/sfeQwiicBuzzerPitches.h +++ /dev/null @@ -1,205 +0,0 @@ -/****************************************************************************** - sfeQwiicBuzzerPitches.h - SparkFun Qwiic Buzzer Library header file - This file contains a list of commonly found notes on a piano. - - by Pete Lewis @SparkFun Electronics - January 2024 - - Based on original source code written by Tom Igeo in Jan 2010: - https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMelody - http://www.arduino.cc/en/Tutorial/Tone - - SPDX-License-Identifier: MIT - - Copyright (c) 2023 SparkFun Electronics - - Distributed as-is; no warranty is given. -******************************************************************************/ - -/************************************************* - Public Constants -*************************************************/ - -#define SFE_QWIIC_BUZZER_NOTE_REST 0 -#define SFE_QWIIC_BUZZER_NOTE_B0 31 -#define SFE_QWIIC_BUZZER_NOTE_C1 33 -#define SFE_QWIIC_BUZZER_NOTE_CS1 35 -#define SFE_QWIIC_BUZZER_NOTE_D1 37 -#define SFE_QWIIC_BUZZER_NOTE_DS1 39 -#define SFE_QWIIC_BUZZER_NOTE_E1 41 -#define SFE_QWIIC_BUZZER_NOTE_F1 44 -#define SFE_QWIIC_BUZZER_NOTE_FS1 46 -#define SFE_QWIIC_BUZZER_NOTE_G1 49 -#define SFE_QWIIC_BUZZER_NOTE_GS1 52 -#define SFE_QWIIC_BUZZER_NOTE_A1 55 -#define SFE_QWIIC_BUZZER_NOTE_AS1 58 -#define SFE_QWIIC_BUZZER_NOTE_B1 62 -#define SFE_QWIIC_BUZZER_NOTE_C2 65 -#define SFE_QWIIC_BUZZER_NOTE_CS2 69 -#define SFE_QWIIC_BUZZER_NOTE_D2 73 -#define SFE_QWIIC_BUZZER_NOTE_DS2 78 -#define SFE_QWIIC_BUZZER_NOTE_E2 82 -#define SFE_QWIIC_BUZZER_NOTE_F2 87 -#define SFE_QWIIC_BUZZER_NOTE_FS2 93 -#define SFE_QWIIC_BUZZER_NOTE_G2 98 -#define SFE_QWIIC_BUZZER_NOTE_GS2 104 -#define SFE_QWIIC_BUZZER_NOTE_A2 110 -#define SFE_QWIIC_BUZZER_NOTE_AS2 117 -#define SFE_QWIIC_BUZZER_NOTE_B2 123 -#define SFE_QWIIC_BUZZER_NOTE_C3 131 -#define SFE_QWIIC_BUZZER_NOTE_CS3 139 -#define SFE_QWIIC_BUZZER_NOTE_D3 147 -#define SFE_QWIIC_BUZZER_NOTE_DS3 156 -#define SFE_QWIIC_BUZZER_NOTE_E3 165 -#define SFE_QWIIC_BUZZER_NOTE_F3 175 -#define SFE_QWIIC_BUZZER_NOTE_FS3 185 -#define SFE_QWIIC_BUZZER_NOTE_G3 196 -#define SFE_QWIIC_BUZZER_NOTE_GS3 208 -#define SFE_QWIIC_BUZZER_NOTE_A3 220 -#define SFE_QWIIC_BUZZER_NOTE_AS3 233 -#define SFE_QWIIC_BUZZER_NOTE_B3 247 -#define SFE_QWIIC_BUZZER_NOTE_C4 262 -#define SFE_QWIIC_BUZZER_NOTE_CS4 277 -#define SFE_QWIIC_BUZZER_NOTE_D4 294 -#define SFE_QWIIC_BUZZER_NOTE_DS4 311 -#define SFE_QWIIC_BUZZER_NOTE_E4 330 -#define SFE_QWIIC_BUZZER_NOTE_F4 349 -#define SFE_QWIIC_BUZZER_NOTE_FS4 370 -#define SFE_QWIIC_BUZZER_NOTE_G4 392 -#define SFE_QWIIC_BUZZER_NOTE_GS4 415 -#define SFE_QWIIC_BUZZER_NOTE_A4 440 -#define SFE_QWIIC_BUZZER_NOTE_AS4 466 -#define SFE_QWIIC_BUZZER_NOTE_B4 494 -#define SFE_QWIIC_BUZZER_NOTE_C5 523 -#define SFE_QWIIC_BUZZER_NOTE_CS5 554 -#define SFE_QWIIC_BUZZER_NOTE_D5 587 -#define SFE_QWIIC_BUZZER_NOTE_DS5 622 -#define SFE_QWIIC_BUZZER_NOTE_E5 659 -#define SFE_QWIIC_BUZZER_NOTE_F5 698 -#define SFE_QWIIC_BUZZER_NOTE_FS5 740 -#define SFE_QWIIC_BUZZER_NOTE_G5 784 -#define SFE_QWIIC_BUZZER_NOTE_GS5 831 -#define SFE_QWIIC_BUZZER_NOTE_A5 880 -#define SFE_QWIIC_BUZZER_NOTE_AS5 932 -#define SFE_QWIIC_BUZZER_NOTE_B5 988 -#define SFE_QWIIC_BUZZER_NOTE_C6 1047 -#define SFE_QWIIC_BUZZER_NOTE_CS6 1109 -#define SFE_QWIIC_BUZZER_NOTE_D6 1175 -#define SFE_QWIIC_BUZZER_NOTE_DS6 1245 -#define SFE_QWIIC_BUZZER_NOTE_E6 1319 -#define SFE_QWIIC_BUZZER_NOTE_F6 1397 -#define SFE_QWIIC_BUZZER_NOTE_FS6 1480 -#define SFE_QWIIC_BUZZER_NOTE_G6 1568 -#define SFE_QWIIC_BUZZER_NOTE_GS6 1661 -#define SFE_QWIIC_BUZZER_NOTE_A6 1760 -#define SFE_QWIIC_BUZZER_NOTE_AS6 1865 -#define SFE_QWIIC_BUZZER_NOTE_B6 1976 -#define SFE_QWIIC_BUZZER_NOTE_C7 2093 -#define SFE_QWIIC_BUZZER_NOTE_CS7 2217 -#define SFE_QWIIC_BUZZER_NOTE_D7 2349 -#define SFE_QWIIC_BUZZER_NOTE_DS7 2489 -#define SFE_QWIIC_BUZZER_NOTE_E7 2637 -#define SFE_QWIIC_BUZZER_NOTE_F7 2794 -#define SFE_QWIIC_BUZZER_NOTE_FS7 2960 -#define SFE_QWIIC_BUZZER_NOTE_G7 3136 -#define SFE_QWIIC_BUZZER_NOTE_GS7 3322 -#define SFE_QWIIC_BUZZER_NOTE_A7 3520 -#define SFE_QWIIC_BUZZER_NOTE_AS7 3729 -#define SFE_QWIIC_BUZZER_NOTE_B7 3951 -#define SFE_QWIIC_BUZZER_NOTE_C8 4186 -#define SFE_QWIIC_BUZZER_NOTE_CS8 4435 -#define SFE_QWIIC_BUZZER_NOTE_D8 4699 -#define SFE_QWIIC_BUZZER_NOTE_DS8 4978 - - -// Backwards compatibility with original "pitches.h" file written by Tim Igeo, 2010. -#define NOTE_B0 SFE_QWIIC_BUZZER_NOTE_B0 -#define NOTE_C1 SFE_QWIIC_BUZZER_NOTE_C1 -#define NOTE_CS1 SFE_QWIIC_BUZZER_NOTE_CS1 -#define NOTE_D1 SFE_QWIIC_BUZZER_NOTE_D1 -#define NOTE_DS1 SFE_QWIIC_BUZZER_NOTE_DS1 -#define NOTE_E1 SFE_QWIIC_BUZZER_NOTE_E1 -#define NOTE_F1 SFE_QWIIC_BUZZER_NOTE_F1 -#define NOTE_FS1 SFE_QWIIC_BUZZER_NOTE_FS1 -#define NOTE_G1 SFE_QWIIC_BUZZER_NOTE_G1 -#define NOTE_GS1 SFE_QWIIC_BUZZER_NOTE_GS1 -#define NOTE_A1 SFE_QWIIC_BUZZER_NOTE_A1 -#define NOTE_AS1 SFE_QWIIC_BUZZER_NOTE_AS1 -#define NOTE_B1 SFE_QWIIC_BUZZER_NOTE_B1 -#define NOTE_C2 SFE_QWIIC_BUZZER_NOTE_C2 -#define NOTE_CS2 SFE_QWIIC_BUZZER_NOTE_CS2 -#define NOTE_D2 SFE_QWIIC_BUZZER_NOTE_D2 -#define NOTE_DS2 SFE_QWIIC_BUZZER_NOTE_DS2 -#define NOTE_E2 SFE_QWIIC_BUZZER_NOTE_E2 -#define NOTE_F2 SFE_QWIIC_BUZZER_NOTE_F2 -#define NOTE_FS2 SFE_QWIIC_BUZZER_NOTE_FS2 -#define NOTE_G2 SFE_QWIIC_BUZZER_NOTE_G2 -#define NOTE_GS2 SFE_QWIIC_BUZZER_NOTE_GS2 -#define NOTE_A2 SFE_QWIIC_BUZZER_NOTE_A2 -#define NOTE_AS2 SFE_QWIIC_BUZZER_NOTE_AS2 -#define NOTE_B2 SFE_QWIIC_BUZZER_NOTE_B2 -#define NOTE_C3 SFE_QWIIC_BUZZER_NOTE_C3 -#define NOTE_CS3 SFE_QWIIC_BUZZER_NOTE_CS3 -#define NOTE_D3 SFE_QWIIC_BUZZER_NOTE_D3 -#define NOTE_DS3 SFE_QWIIC_BUZZER_NOTE_DS3 -#define NOTE_E3 SFE_QWIIC_BUZZER_NOTE_E3 -#define NOTE_F3 SFE_QWIIC_BUZZER_NOTE_F3 -#define NOTE_FS3 SFE_QWIIC_BUZZER_NOTE_FS3 -#define NOTE_G3 SFE_QWIIC_BUZZER_NOTE_G3 -#define NOTE_GS3 SFE_QWIIC_BUZZER_NOTE_GS3 -#define NOTE_A3 SFE_QWIIC_BUZZER_NOTE_A3 -#define NOTE_AS3 SFE_QWIIC_BUZZER_NOTE_AS3 -#define NOTE_B3 SFE_QWIIC_BUZZER_NOTE_B3 -#define NOTE_C4 SFE_QWIIC_BUZZER_NOTE_C4 -#define NOTE_CS4 SFE_QWIIC_BUZZER_NOTE_CS4 -#define NOTE_D4 SFE_QWIIC_BUZZER_NOTE_D4 -#define NOTE_DS4 SFE_QWIIC_BUZZER_NOTE_DS4 -#define NOTE_E4 SFE_QWIIC_BUZZER_NOTE_E4 -#define NOTE_F4 SFE_QWIIC_BUZZER_NOTE_F4 -#define NOTE_FS4 SFE_QWIIC_BUZZER_NOTE_FS4 -#define NOTE_G4 SFE_QWIIC_BUZZER_NOTE_G4 -#define NOTE_GS4 SFE_QWIIC_BUZZER_NOTE_GS4 -#define NOTE_A4 SFE_QWIIC_BUZZER_NOTE_A4 -#define NOTE_AS4 SFE_QWIIC_BUZZER_NOTE_AS4 -#define NOTE_B4 SFE_QWIIC_BUZZER_NOTE_B4 -#define NOTE_C5 SFE_QWIIC_BUZZER_NOTE_C5 -#define NOTE_CS5 SFE_QWIIC_BUZZER_NOTE_CS5 -#define NOTE_D5 SFE_QWIIC_BUZZER_NOTE_D5 -#define NOTE_DS5 SFE_QWIIC_BUZZER_NOTE_DS5 -#define NOTE_E5 SFE_QWIIC_BUZZER_NOTE_E5 -#define NOTE_F5 SFE_QWIIC_BUZZER_NOTE_F5 -#define NOTE_FS5 SFE_QWIIC_BUZZER_NOTE_FS5 -#define NOTE_G5 SFE_QWIIC_BUZZER_NOTE_G5 -#define NOTE_GS5 SFE_QWIIC_BUZZER_NOTE_GS5 -#define NOTE_A5 SFE_QWIIC_BUZZER_NOTE_A5 -#define NOTE_AS5 SFE_QWIIC_BUZZER_NOTE_AS5 -#define NOTE_B5 SFE_QWIIC_BUZZER_NOTE_B5 -#define NOTE_C6 SFE_QWIIC_BUZZER_NOTE_C6 -#define NOTE_CS6 SFE_QWIIC_BUZZER_NOTE_CS6 -#define NOTE_D6 SFE_QWIIC_BUZZER_NOTE_D6 -#define NOTE_DS6 SFE_QWIIC_BUZZER_NOTE_DS6 -#define NOTE_E6 SFE_QWIIC_BUZZER_NOTE_E6 -#define NOTE_F6 SFE_QWIIC_BUZZER_NOTE_F6 -#define NOTE_FS6 SFE_QWIIC_BUZZER_NOTE_FS6 -#define NOTE_G6 SFE_QWIIC_BUZZER_NOTE_G6 -#define NOTE_GS6 SFE_QWIIC_BUZZER_NOTE_GS6 -#define NOTE_A6 SFE_QWIIC_BUZZER_NOTE_A6 -#define NOTE_AS6 SFE_QWIIC_BUZZER_NOTE_AS6 -#define NOTE_B6 SFE_QWIIC_BUZZER_NOTE_B6 -#define NOTE_C7 SFE_QWIIC_BUZZER_NOTE_C7 -#define NOTE_CS7 SFE_QWIIC_BUZZER_NOTE_CS7 -#define NOTE_D7 SFE_QWIIC_BUZZER_NOTE_D7 -#define NOTE_DS7 SFE_QWIIC_BUZZER_NOTE_DS7 -#define NOTE_E7 SFE_QWIIC_BUZZER_NOTE_E7 -#define NOTE_F7 SFE_QWIIC_BUZZER_NOTE_F7 -#define NOTE_FS7 SFE_QWIIC_BUZZER_NOTE_FS7 -#define NOTE_G7 SFE_QWIIC_BUZZER_NOTE_G7 -#define NOTE_GS7 SFE_QWIIC_BUZZER_NOTE_GS7 -#define NOTE_A7 SFE_QWIIC_BUZZER_NOTE_A7 -#define NOTE_AS7 SFE_QWIIC_BUZZER_NOTE_AS7 -#define NOTE_B7 SFE_QWIIC_BUZZER_NOTE_B7 -#define NOTE_C8 SFE_QWIIC_BUZZER_NOTE_C8 -#define NOTE_CS8 SFE_QWIIC_BUZZER_NOTE_CS8 -#define NOTE_D8 SFE_QWIIC_BUZZER_NOTE_D8 -#define NOTE_DS8 SFE_QWIIC_BUZZER_NOTE_DS8 \ No newline at end of file diff --git a/src/sfeQwiicBuzzerRegisters.h b/src/sfeQwiicBuzzerRegisters.h deleted file mode 100644 index e51b6df..0000000 --- a/src/sfeQwiicBuzzerRegisters.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - sfeQwiicBuzzerRegisters.h - - by Pete Lewis @SparkFun Electronics - January 2024 - - Based on original source code written by - Fischer Moseley @ SparkFun Electronics - Original Creation Date: July 24, 2019 - - This file defines the virtual memory map on the Qwiic Buzzer. The enum - provides a set of pointers for the various registers on the Qwiic - Buzzer. - - Development environment specifics: - IDE: Arduino 2.2.1 - Hardware Platform: Arduino Uno/SparkFun Redboard - Qwiic Buzzer Version: v10 - - SPDX-License-Identifier: MIT - - Copyright (c) 2023 SparkFun Electronics - - Distributed as-is; no warranty is given. -******************************************************************************/ - -#pragma once - -#include - -// Register Pointer Map -enum Qwiic_Buzzer_Register : uint8_t -{ - kSfeQwiicBuzzerRegId = 0x00, - kSfeQwiicBuzzerRegFirmwareMinor, - kSfeQwiicBuzzerRegFirmwareMajor, - kSfeQwiicBuzzerRegToneFrequencyMsb, - kSfeQwiicBuzzerRegToneFrequencyLsb, - kSfeQwiicBuzzerRegVolume, - kSfeQwiicBuzzerRegDurationMsb, - kSfeQwiicBuzzerRegDurationLsb, - kSfeQwiicBuzzerRegActive, - kSfeQwiicBuzzerRegSaveSettings, - kSfeQwiicBuzzerRegI2cAddress, -}; \ No newline at end of file