Flying Silicon Sensor
Sounds Namespace Reference

Functions

void setBuzzer (int pin)
 
static void sound (int freq, int ms)
 
static void silence (void)
 
void beep (int freq, int ms)
 
void playMelody (const int melody[])
 
void playCharging (void)
 
void playBattery (float batPct)
 
void playConnect (void)
 
void playDisconnect (void)
 
void playSwitchOff (void)
 

Variables

static int buzzerPin = 0
 Buzzer pin to be used.
 
static const int WholeNote = (60000 * 4) / 90
 Duration of a whole note.
 

Function Documentation

◆ beep()

void Sounds::beep ( int  freq,
int  ms 
)

Let the buzzer and be sure to switch it properly off afterwards.

Parameters
freqTone frequency Hz
msTone duration ms

Definition at line 88 of file sounds.cpp.

References buzzerPin, silence(), and sound().

Referenced by playBattery(), playCharging(), playConnect(), playDisconnect(), playMelody(), and playSwitchOff().

◆ playBattery()

void Sounds::playBattery ( float  batPct)

Sound indicating the battery status

Parameters
batPctremaining capacity percent

Definition at line 146 of file sounds.cpp.

References beep(), NOTE_A1, and NOTE_A2.

Referenced by enable().

◆ playCharging()

void Sounds::playCharging ( void  )

Sound for battery level when USB is connected

Definition at line 135 of file sounds.cpp.

References beep(), NOTE_A1, and NOTE_A2.

Referenced by enable().

◆ playConnect()

void Sounds::playConnect ( void  )

Sound when BLE central is connected

Definition at line 197 of file sounds.cpp.

References beep(), and NOTE_G3.

Referenced by appLoop().

◆ playDisconnect()

void Sounds::playDisconnect ( void  )

Sound when BLE central is disconnected

Definition at line 207 of file sounds.cpp.

References beep(), and NOTE_A2.

Referenced by appLoop().

◆ playMelody()

void Sounds::playMelody ( const int  melody[])

Play a melody on the buzzer

The argument must contain a sequence of int pairs (freq, ms), terminated with MELODY_END

Parameters
melodyMelody definition array

Definition at line 105 of file sounds.cpp.

References beep(), BUZZER_MIN_HZ, and WholeNote.

Referenced by enable().

◆ playSwitchOff()

void Sounds::playSwitchOff ( void  )

Sound when device goes inactive

Definition at line 219 of file sounds.cpp.

References beep(), and NOTE_A1.

Referenced by appLoop(), disable(), and suspend().

◆ setBuzzer()

void Sounds::setBuzzer ( int  pin)

Enable/disable all sounds on specified buzzer

Parameters
pinThe pin where the buzzer is connected, or 0 to disable sound

Definition at line 44 of file sounds.cpp.

References buzzerPin.

Referenced by managePower().

◆ silence()

static void Sounds::silence ( void  )
static

Stop sound

Definition at line 74 of file sounds.cpp.

References buzzerPin.

Referenced by beep().

◆ sound()

static void Sounds::sound ( int  freq,
int  ms 
)
static

Activate buzzer tone and return immediately Caution: Can leave the buzzer transistor open and drain the battery very fast.

Parameters
freqTone frequency Hz
msTone duration ms

Definition at line 55 of file sounds.cpp.

References BUZZER_MAX_HZ, BUZZER_MIN_HZ, BUZZER_MIN_MS, and buzzerPin.

Referenced by beep().

Variable Documentation

◆ buzzerPin

int Sounds::buzzerPin = 0
static

Buzzer pin to be used.

Definition at line 34 of file sounds.cpp.

Referenced by beep(), setBuzzer(), silence(), and sound().

◆ WholeNote

const int Sounds::WholeNote = (60000 * 4) / 90
static

Duration of a whole note.

Definition at line 37 of file sounds.cpp.

Referenced by playMelody().