LevelMeter-Display  2.0
An ultrasonic Level Meter for Stormwater Cisterns
Functions | Variables
sound.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static void InitSound ()
 Initializes sound hardware and state. More...
 
void PlayNote (uint8_t note, uint8_t duration)
 Plays a single note. More...
 
void PlaySequence (uint8_t *seq)
 Plays a sequence of notes. More...
 
void PlayTone (uint16_t tone, uint8_t duration)
 Plays a single tone. More...
 
static void SndTimerCallback ()
 Must be called by system timer (10ms) More...
 
void SndToneOff (void)
 Stops playing a tone. More...
 
void SndToneOn (uint16_t tone)
 Starts playing a tone. More...
 

Variables

uint8_t * musicPtr
 Is used in the timer callback to play sequences. More...
 
uint8_t sndBigBenSeq []
 Big Ben Tone sequence. More...
 
uint8_t sndErrorSeq []
 Tone sequence for error messages. More...
 
uint8_t sndSeqPlaying
 Is !=0 while a sequence is playing. More...
 
uint8_t sndSig1 []
 Sequence for alert output 1. More...
 
uint8_t sndSig2 []
 Sequence for alert output 2. More...
 
uint8_t sndSuccessSeq []
 Tone sequence for success. More...
 
uint8_t sndToneCnt
 Down-counter for tone duration. Can be tested to 0 to wait for end of tone. More...
 

Function Documentation

◆ InitSound()

static void InitSound ( )
inlinestatic

Initializes sound hardware and state.

References musicPtr, sndSeqPlaying, and sndToneCnt.

Referenced by Init().

Here is the caller graph for this function:

◆ PlayNote()

void PlayNote ( uint8_t  note,
uint8_t  duration 
)

Plays a single note.

Parameters
noteThe note as a midi value (e.g. A4 (440Hz) = 69)
durationLength in multiple of 10ms

The note value "0" can be used to play silence. Notes from 57 to 117 can be used. Other values produce undefined tones.

References midiOffset, and PlayTone().

Referenced by PlaySequence(), and SndTimerCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PlaySequence()

void PlaySequence ( uint8_t *  seq)

Plays a sequence of notes.

Parameters
seqa pointer to the note data

The data format is one byte note and one byte duration. The data has to be terminated with 0x00 0x00

References musicPtr, and PlayNote().

Referenced by DoTflags(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PlayTone()

void PlayTone ( uint16_t  tone,
uint8_t  duration 
)

Plays a single tone.

Parameters
toneThe value of the timer period register (OCR3A)
durationLength in multiple of 10ms

The frequency of the tone is 3.6864MHz/(tone+1) A tone value 0 plays silence for the given duration

References sndToneCnt, SndToneOff(), and SndToneOn().

Referenced by PlayNote().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SndTimerCallback()

static void SndTimerCallback ( )
inlinestatic

Must be called by system timer (10ms)

References musicPtr, PlayNote(), sndToneCnt, and SndToneOff().

Referenced by ISR().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SndToneOff()

void SndToneOff ( void  )
inline

Stops playing a tone.

Referenced by PlayTone(), and SndTimerCallback().

Here is the caller graph for this function:

◆ SndToneOn()

void SndToneOn ( uint16_t  tone)
inline

Starts playing a tone.

Parameters
toneThe value of the timer period register (OCR3A)

The frequency of the tone is 3.6864MHz/(tone+1)

Referenced by PlayTone().

Here is the caller graph for this function:

Variable Documentation

◆ musicPtr

uint8_t* musicPtr

Is used in the timer callback to play sequences.

Referenced by InitSound(), PlaySequence(), and SndTimerCallback().

◆ sndBigBenSeq

uint8_t sndBigBenSeq[]

Big Ben Tone sequence.

Referenced by DoTflags().

◆ sndErrorSeq

uint8_t sndErrorSeq[]

Tone sequence for error messages.

◆ sndSeqPlaying

uint8_t sndSeqPlaying

Is !=0 while a sequence is playing.

Referenced by InitSound().

◆ sndSig1

uint8_t sndSig1[]

Sequence for alert output 1.

Referenced by DoTflags().

◆ sndSig2

uint8_t sndSig2[]

Sequence for alert output 2.

Referenced by DoTflags().

◆ sndSuccessSeq

uint8_t sndSuccessSeq[]

Tone sequence for success.

Referenced by main().

◆ sndToneCnt

uint8_t sndToneCnt

Down-counter for tone duration. Can be tested to 0 to wait for end of tone.

Referenced by InitSound(), PlayTone(), and SndTimerCallback().