10 #include <satcat5/pkt_buffer.h>
14 #ifndef SATCAT5_RTTTL_BUFFER
15 #define SATCAT5_RTTTL_BUFFER 256
40 ,
m_scale((1ull << 48) / refclk_hz)
54 bool play(
const char* src);
74 constexpr
char RTTTL_BEETHOVEN[] =
75 "5thSymph:d=16,o=5,b=100:"\
76 "g,g,g,4d#,4p,f,f,f,4d,4p,g,g,g,d#,g#,g#,g#,g,d#6,d#6,d#6,4c6,8p";
79 constexpr
char RTTTL_HAUNTED[] =
80 "HauntHouse: d=4,o=5,b=108: 2a4, 2e, 2d#, 2b4, 2a4, 2c, 2d, 2a#4, 2e.";
83 constexpr
char RTTTL_NOKIA[] =
84 "Nokia:d=4,o=5,b=225:8e6,8d6,f#,g#,8c#6,8b,d,e,8b,8a,c#,e,2a";
87 constexpr
char RTTTL_RICK[] =
88 "Rick:d=8,o=4,b=225:g,a,c5,a,4e5,p,4e5,p,4.d5,4.p,g,a,c5,a,"\
89 "4d5,p,4d5,p,4c5,b,4.a,g,a,c5,a,2c5,4d5,4b,4a,4.g,2d5,2.c5";
92 constexpr
char RTTTL_STARTUP[] =
93 "Circles:d=16,o=6,b=180:a,a5,c,e,8a";
110 void log_event(s8 priority,
unsigned nbytes,
const char* msg)
override;
Event-handler interface for newly received data.
The PacketBuffer class is a wrapper for a circular buffer, with optional logic to support retention o...
void clear()
Reset buffer contents.
Abstract API for reading byte-streams and packets.
Ring Tone Text Transfer Language (RTTTL) interpreter.
u32 m_octave
Default octave.
u32 m_whole_note
Duration of whole note.
bool play(const char *src)
Decode and play the specified song (string input).
satcat5::io::PacketBuffer m_queue
Playback queue.
u32 m_duration
Default note duration.
satcat5::io::Writeable *const m_spkr
Output device.
const u64 m_scale
Frequency conversion.
void flush()
If playback is in progress, halt immediately.
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
u8 m_raw[SATCAT5_RTTTL_BUFFER]
Raw working buffer.
constexpr RtttlDecoder(satcat5::io::Writeable *spkr, u64 refclk_hz)
Link this decoder to a playback device.
Abstract API for writing byte-streams and packets.
Defines the interface for accepting Log messages.
Respond to log messages by playing a few musical notes.
ToBeep(satcat5::io::RtttlDecoder *codec)
Constructor binds this object to an RTTTL decoder.
void log_event(s8 priority, unsigned nbytes, const char *msg) override
Callback for each formatted Log message.
void set_cooldown(unsigned msec)
Set minimum time between beeps.
void timer_event() override
End-of-cooldown callback does nothing.
Timer objects are polled after a fixed delay or at a regular interval.
Diagnostic logging to UART and/or Ethernet ports.
Core event-processing loop for SatCat5 software.