Sample API functions for playing tunes on a piezo buzzer.

Functions

void halPlayTune_P (uint8_t PGM *tune, bool bkg)
Plays a tune on the piezo buzzer.
void halStackIndicatePresence (void)
Causes something to happen on a node (such as playing a tune on the buzzer) that can be used to indicate where it physically is.

Note Definitions

Flats are used instead of sharps because # is a special character.

#define NOTE_C3 119
A note which can be used in tune structure definitions.
#define NOTE_Db3 112
A note which can be used in tune structure definitions.
#define NOTE_D3 106
A note which can be used in tune structure definitions.
#define NOTE_Eb3 100
A note which can be used in tune structure definitions.
#define NOTE_E3 94
A note which can be used in tune structure definitions.
#define NOTE_F3 89
A note which can be used in tune structure definitions.
#define NOTE_Gb3 84
A note which can be used in tune structure definitions.
#define NOTE_G3 79
A note which can be used in tune structure definitions.
#define NOTE_Ab3 74
A note which can be used in tune structure definitions.
#define NOTE_A3 70
A note which can be used in tune structure definitions.
#define NOTE_Bb3 66
A note which can be used in tune structure definitions.
#define NOTE_B3 63
A note which can be used in tune structure definitions.
#define NOTE_C4 59
A note which can be used in tune structure definitions.
#define NOTE_Db4 55
A note which can be used in tune structure definitions.
#define NOTE_D4 52
A note which can be used in tune structure definitions.
#define NOTE_Eb4 49
A note which can be used in tune structure definitions.
#define NOTE_E4 46
A note which can be used in tune structure definitions.
#define NOTE_F4 44
A note which can be used in tune structure definitions.
#define NOTE_Gb4 41
A note which can be used in tune structure definitions.
#define NOTE_G4 39
A note which can be used in tune structure definitions.
#define NOTE_Ab4 37
A note which can be used in tune structure definitions.
#define NOTE_A4 35
A note which can be used in tune structure definitions.
#define NOTE_Bb4 33
A note which can be used in tune structure definitions.
#define NOTE_B4 31
A note which can be used in tune structure definitions.
#define NOTE_C5 29
A note which can be used in tune structure definitions.
#define NOTE_Db5 27
A note which can be used in tune structure definitions.
#define NOTE_D5 26
A note which can be used in tune structure definitions.
#define NOTE_Eb5 24
A note which can be used in tune structure definitions.
#define NOTE_E5 23
A note which can be used in tune structure definitions.
#define NOTE_F5 21
A note which can be used in tune structure definitions.
#define NOTE_Gb5 20
A note which can be used in tune structure definitions.
#define NOTE_G5 19
A note which can be used in tune structure definitions.
#define NOTE_Ab5 18
A note which can be used in tune structure definitions.
#define NOTE_A5 17
A note which can be used in tune structure definitions.
#define NOTE_Bb5 16
A note which can be used in tune structure definitions.
#define NOTE_B5 15
A note which can be used in tune structure definitions.

Detailed Description

Sample API functions for playing tunes on a piezo buzzer.

See buzzer.h for source code.

Macro Definition Documentation

NOTE_A3

#define NOTE_A3   70

A note which can be used in tune structure definitions.

NOTE_A4

#define NOTE_A4   35

A note which can be used in tune structure definitions.

NOTE_A5

#define NOTE_A5   17

A note which can be used in tune structure definitions.

NOTE_Ab3

#define NOTE_Ab3   74

A note which can be used in tune structure definitions.

NOTE_Ab4

#define NOTE_Ab4   37

A note which can be used in tune structure definitions.

NOTE_Ab5

#define NOTE_Ab5   18

A note which can be used in tune structure definitions.

NOTE_B3

#define NOTE_B3   63

A note which can be used in tune structure definitions.

NOTE_B4

#define NOTE_B4   31

A note which can be used in tune structure definitions.

NOTE_B5

#define NOTE_B5   15

A note which can be used in tune structure definitions.

NOTE_Bb3

#define NOTE_Bb3   66

A note which can be used in tune structure definitions.

NOTE_Bb4

#define NOTE_Bb4   33

A note which can be used in tune structure definitions.

NOTE_Bb5

#define NOTE_Bb5   16

A note which can be used in tune structure definitions.

NOTE_C3

#define NOTE_C3   119

A note which can be used in tune structure definitions.

NOTE_C4

#define NOTE_C4   59

A note which can be used in tune structure definitions.

NOTE_C5

#define NOTE_C5   29

A note which can be used in tune structure definitions.

NOTE_D3

#define NOTE_D3   106

A note which can be used in tune structure definitions.

NOTE_D4

#define NOTE_D4   52

A note which can be used in tune structure definitions.

NOTE_D5

#define NOTE_D5   26

A note which can be used in tune structure definitions.

NOTE_Db3

#define NOTE_Db3   112

A note which can be used in tune structure definitions.

NOTE_Db4

#define NOTE_Db4   55

A note which can be used in tune structure definitions.

NOTE_Db5

#define NOTE_Db5   27

A note which can be used in tune structure definitions.

NOTE_E3

#define NOTE_E3   94

A note which can be used in tune structure definitions.

NOTE_E4

#define NOTE_E4   46

A note which can be used in tune structure definitions.

NOTE_E5

#define NOTE_E5   23

A note which can be used in tune structure definitions.

NOTE_Eb3

#define NOTE_Eb3   100

A note which can be used in tune structure definitions.

NOTE_Eb4

#define NOTE_Eb4   49

A note which can be used in tune structure definitions.

NOTE_Eb5

#define NOTE_Eb5   24

A note which can be used in tune structure definitions.

NOTE_F3

#define NOTE_F3   89

A note which can be used in tune structure definitions.

NOTE_F4

#define NOTE_F4   44

A note which can be used in tune structure definitions.

NOTE_F5

#define NOTE_F5   21

A note which can be used in tune structure definitions.

NOTE_G3

#define NOTE_G3   79

A note which can be used in tune structure definitions.

NOTE_G4

#define NOTE_G4   39

A note which can be used in tune structure definitions.

NOTE_G5

#define NOTE_G5   19

A note which can be used in tune structure definitions.

NOTE_Gb3

#define NOTE_Gb3   84

A note which can be used in tune structure definitions.

NOTE_Gb4

#define NOTE_Gb4   41

A note which can be used in tune structure definitions.

NOTE_Gb5

#define NOTE_Gb5   20

A note which can be used in tune structure definitions.

Function Documentation

halPlayTune_P()

void halPlayTune_P ( uint8_t PGM * tune,
bool bkg
)

Plays a tune on the piezo buzzer.

The tune is played in the background if ::bkg is true. Otherwise, the API blocks until the playback of the tune is complete. halPlayTune_P() is not meant to be called back-to-back.

Parameters
tune A pointer to tune to play.
bkg Determines whether the tune plays in the background. If true, tune plays in background; if false, tune plays in foreground.

A tune is implemented as follows:

uint8_t PGM hereIamTune[] = { //All tunes are stored in flash.
NOTE_B4 , 1, //Plays the note B4 for 100 milliseconds.
0, 1, //Pause for 100 milliseconds.
NOTE_B5 , 5, //Plays the note B5 for 500 milliseconds.
0, 0 //NULL terminates the tune.
};

halStackIndicatePresence()

void halStackIndicatePresence ( void )

Causes something to happen on a node (such as playing a tune on the buzzer) that can be used to indicate where it physically is.