|
Arduboy2 Library
6.0.0
|
Play simple square wave tones using speaker pin 2. More...
#include <Arduboy2Beep.h>
Static Public Member Functions | |
| static void | begin () |
| Set up the hardware for playing tones using speaker pin 2. More... | |
| static void | tone (uint16_t count) |
| Play a tone on speaker pin 2 continually, until replaced by a new tone or stopped. More... | |
| static void | tone (uint16_t count, uint8_t dur) |
| Play a tone on speaker pin 2 for a given duration. More... | |
| static void | timer () |
| Handle the duration that a tone on speaker pin 2 plays for. More... | |
| static void | noTone () |
| Stop a tone that is playing on speaker pin 2. More... | |
| static constexpr uint16_t | freq (const float hz) |
| Convert a frequency to the required count for speaker pin 2. More... | |
Static Public Attributes | |
| static uint8_t | duration = 0 |
The counter used by the timer() function to time the duration of a tone played on speaker pin 2. More... | |
Play simple square wave tones using speaker pin 2.
This class contains the same functions as class BeepPin1 except they use speaker pin 2 instead of speaker pin 1.
Using BeepPin1 is more desirable, as it uses a 16 bit Timer, which can produce a greater frequency range and resolution than the 10 bit Timer used by BeepPin2. However, if the sketch also includes other sound generating code that uses speaker pin 1, BeepPin2 can be used to avoid conflict.
Tone frequencies on speaker pin 2 can range from 61.04Hz to 15625Hz using allowed counts from 3 to 1023.
The formulas for frequency/count conversion are:
count=(62500/frequency)-1 frequency=62500/(count+1)
See the documentation for BeepPin1 for more details.
Definition at line 282 of file Arduboy2Beep.h.
|
static |
Set up the hardware for playing tones using speaker pin 2.
For details see BeepPin1::begin().
Definition at line 52 of file Arduboy2Beep.cpp.
|
inlinestaticconstexpr |
Convert a frequency to the required count for speaker pin 2.
| hz | The frequency, in hertz (cycles per second), to be converted to a count. |
For details see BeepPin1::freq().
Definition at line 355 of file Arduboy2Beep.h.
|
static |
Stop a tone that is playing on speaker pin 2.
For details see BeepPin1::noTone().
Definition at line 81 of file Arduboy2Beep.cpp.
|
static |
Handle the duration that a tone on speaker pin 2 plays for.
For details see BeepPin1::timer().
Definition at line 74 of file Arduboy2Beep.cpp.
|
static |
Play a tone on speaker pin 2 continually, until replaced by a new tone or stopped.
| count | The count to be loaded into the timer/counter to play the desired frequency. |
For details see BeepPin1::tone(uint16_t).
Definition at line 61 of file Arduboy2Beep.cpp.
|
static |
Play a tone on speaker pin 2 for a given duration.
| count | The count to be loaded into the timer/counter to play the desired frequency. |
| dur | The duration of the tone, used by timer(). |
For details see BeepPin1::tone(uint16_t, uint8_t).
Definition at line 66 of file Arduboy2Beep.cpp.
|
static |
The counter used by the timer() function to time the duration of a tone played on speaker pin 2.
For details see BeepPin1::duration.
Definition at line 293 of file Arduboy2Beep.h.