FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
An optimized surrogate to TonePlay
structure.
More...
#include <fastarduino/devices/tone_player.h>
Public Member Functions | |
QTonePlay ()=default | |
Default constructor, used only to declare an uninitialized QTonePlay variable. More... | |
constexpr | QTonePlay (Tone tone, Duration duration) |
Construct an optimized tone play for the provided tone and duration. More... | |
constexpr | QTonePlay (Tone tone, uint8_t value=0) |
Construct a "special" optimized tone play with the provided value. More... | |
Friends | |
class | AbstractTonePlayer< NTIMER, OUTPUT, QTonePlay< NTIMER, OUTPUT > > |
An optimized surrogate to TonePlay
structure.
Contrarily to TonePlay
, it does not store Tone
(i.e. frequency) but Timer prescaler and counter for the desired frequency. The advantage is that when you construct a QTonePlay
from constant tones, each tone will be converted to timer prescaler and counter at compile-time, hence the generated code is smaller and more efficient; this can be useful when your MCU is limited in data size.
NTIMER | the AVR timer to use for the underlying Timer |
OUTPUT | the board::PWMPin connected to the buzzer; this must be the pin OCnA, where n is the AVR Timer number |
Definition at line 268 of file tone_player.h.
|
default |
Default constructor, used only to declare an uninitialized QTonePlay
variable.
You should always ensure you replace such a variable with one constructed with the next constructor.
|
inlineconstexpr |
Construct an optimized tone play for the provided tone and duration.
tone | the Tone for this QTonePlay ; it will be automatically converted (at compile-time if t is a constant) to the proper timer prescaler and counter. |
duration | the duration of this note. |
Definition at line 293 of file tone_player.h.
|
inlineconstexpr |
Construct a "special" optimized tone play with the provided value.
tone | the special tone (as defined in SpecialTone namespace) |
value | additional value which meaning depends on actual tone: number of repeats for SpecialTone::REPEAT_END , number of ties or slurs between successive notes for SpecialTone::TIE . |
Definition at line 304 of file tone_player.h.
|
friend |
Definition at line 385 of file tone_player.h.
Duration devices::audio::QTonePlay< NTIMER, OUTPUT >::duration_ |
Definition at line 368 of file tone_player.h.
uint8_t devices::audio::QTonePlay< NTIMER, OUTPUT >::repeats_ |
Definition at line 369 of file tone_player.h.
uint8_t devices::audio::QTonePlay< NTIMER, OUTPUT >::ties_ |
Definition at line 370 of file tone_player.h.