|
LevelMeter-Display
2.0
An ultrasonic Level Meter for Stormwater Cisterns
|
Sound and music functions. More...

Macros | |
| #define | eigth (sixteenth*2) |
| #define | half (quarter*2) |
| #define | quarter (eigth*2) |
| #define | sixteenth 8 |
| #define | whole (half*2) |
Functions | |
| 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... | |
| void | SndToneOff () |
| Stops playing a tone. More... | |
| void | SndToneOn (uint16_t tone) |
| Starts playing a tone. More... | |
Variables | |
| static const uint8_t | midiOffset =57 |
| The first note in notes[] is midi-code 57. More... | |
| uint8_t * | musicPtr |
| Is used in the timer callback to play sequences. More... | |
| static const uint16_t notes [] | PROGMEM |
| uint8_t | sndBigBenSeq [] |
| Big Ben Tone sequence. More... | |
| uint8_t | sndErrorSeq [] ={57,20,0,0} |
| 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 [] ={80,5,0,10,92,5,0,0} |
| 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... | |
Sound and music functions.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Playing sounds and music is done using timer interrupts. So the functions are non-blocking.
| #define eigth (sixteenth*2) |
| #define half (quarter*2) |
| #define quarter (eigth*2) |
| #define sixteenth 8 |
| #define whole (half*2) |
| void PlayNote | ( | uint8_t | note, |
| uint8_t | duration | ||
| ) |
Plays a single note.
| note | The note as a midi value (e.g. A4 (440Hz) = 69) |
| duration | Length 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().


| void PlaySequence | ( | uint8_t * | seq | ) |
Plays a sequence of notes.
| seq | a 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().


| void PlayTone | ( | uint16_t | tone, |
| uint8_t | duration | ||
| ) |
Plays a single tone.
| tone | The value of the timer period register (OCR3A) |
| duration | Length 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().


|
inline |
Stops playing a tone.
Referenced by PlayTone(), and SndTimerCallback().

|
inline |
Starts playing a tone.
| tone | The value of the timer period register (OCR3A) |
The frequency of the tone is 3.6864MHz/(tone+1)
Referenced by PlayTone().

|
static |
The first note in notes[] is midi-code 57.
Referenced by PlayNote().
| uint8_t* musicPtr |
Is used in the timer callback to play sequences.
Referenced by InitSound(), PlaySequence(), and SndTimerCallback().
|
static |
| uint8_t sndBigBenSeq[] |
| uint8_t sndErrorSeq[] ={57,20,0,0} |
Tone sequence for error messages.
| uint8_t sndSeqPlaying |
Is !=0 while a sequence is playing.
Referenced by InitSound().
| uint8_t sndSig1[] |
| uint8_t sndSig2[] |
Sequence for alert output 2.
Referenced by DoTflags().
| uint8_t sndSuccessSeq[] ={80,5,0,10,92,5,0,0} |
Tone sequence for success.
Referenced by main().
| 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().
1.8.15