#include <rtttl.h>
List of all members.
Public Member Functions |
| | Rtttl () |
| void | begin (uint8_t tonePin) |
| void | _tone (uint16_t freq) |
| void | _noTone () |
| void | play_P (const prog_char *p, uint8_t octave_offset=0) |
| void | play (const char *p, uint8_t octave_offset=0) |
| void | _play (const prog_char *p, uint8_t octave_offset, bool pgm) |
Detailed Description
Definition at line 108 of file rtttl.h.
Constructor & Destructor Documentation
Member Function Documentation
Definition at line 152 of file rtttl.h.
Referenced by _play().
{
noTone(this->_pinSpk);
}
| void Rtttl::_play |
( |
const prog_char * |
p, |
|
|
uint8_t |
octave_offset, |
|
|
bool |
pgm |
|
) |
| [inline] |
Definition at line 168 of file rtttl.h.
References _noTone(), _tone(), isdigit, read_byte(), and read_word().
Referenced by play(), and play_P().
{
byte default_dur = 4;
byte default_oct = 6;
int bpm = 63;
int num;
long wholenote;
long duration;
byte note;
byte scale;
while (read_byte(p, pgm) != ':')
p++;
p++;
if (read_byte(p, pgm) == 'd')
{
p++;
p++;
num = 0;
while (isdigit(read_byte(p, pgm)))
{
num = (num * 10) + (read_byte(p, pgm) - '0');
p++;
}
if (num > 0)
default_dur = num;
p++;
}
if (read_byte(p, pgm) == 'o')
{
p++;
p++;
num = read_byte(p, pgm) - '0';
p++;
if (num >= 3 && num <= 7)
default_oct = num;
p++;
}
if (read_byte(p, pgm) == 'b')
{
p++;
p++;
num = 0;
while (isdigit(read_byte(p, pgm)))
{
num = (num * 10) + (read_byte(p, pgm) - '0');
p++;
}
bpm = num;
p++;
}
wholenote = (60 * 1000L / bpm) * 4;
while (read_byte(p, pgm))
{
num = 0;
while (isdigit(read_byte(p, pgm)))
{
num = (num * 10) + (read_byte(p, pgm) - '0');
p++;
}
if (num)
duration = wholenote / num;
else
duration = wholenote / default_dur;
note = 0;
switch (read_byte(p, pgm))
{
case 'c':
note = 1;
break;
case 'd':
note = 3;
break;
case 'e':
note = 5;
break;
case 'f':
note = 6;
break;
case 'g':
note = 8;
break;
case 'a':
note = 10;
break;
case 'b':
note = 12;
break;
case 'p':
default:
note = 0;
}
p++;
if (read_byte(p, pgm) == '#')
{
note++;
p++;
}
if (read_byte(p, pgm) == '.')
{
duration += duration / 2;
p++;
}
if (isdigit(read_byte(p, pgm)))
{
scale = read_byte(p, pgm) - '0';
p++;
}
else
{
scale = default_oct;
}
scale += octave_offset;
if (read_byte(p, pgm) == ',')
p++;
if (note)
{
_tone(read_word(¬es[(scale - 4) * 12 + note], pgm));
delay(duration);
_noTone();
}
else
{
delay(duration);
}
}
}
Definition at line 146 of file rtttl.h.
Referenced by _play().
{
tone(this->_pinSpk, freq);
}
Definition at line 121 of file rtttl.h.
{
this->_pinSpk = tonePin;
#ifdef _Tone_h
this->m_tone.begin(tonePin);
#endif
}
| void Rtttl::play |
( |
const char * |
p, |
|
|
uint8_t |
octave_offset = 0 |
|
) |
| [inline] |
| void Rtttl::play_P |
( |
const prog_char * |
p, |
|
|
uint8_t |
octave_offset = 0 |
|
) |
| [inline] |
The documentation for this class was generated from the following file: