shenzhi xu / Mbed 2 deprecated temperature

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers beep.h Source File

beep.h

00001 #ifndef MBED_BEEP_H
00002 #define MBED_BEEP_H
00003 
00004 #include "mbed.h"
00005 
00006 
00007 /** class to make sound with a buzzer, based on a PwmOut
00008  *   The class use a timeout to switch off the sound  - it is not blocking while making noise
00009  *
00010  * Example:
00011  * @code
00012  * // Beep with 1Khz for 0.5 seconds
00013  * #include "mbed.h"
00014  * #include "beep.h"
00015  * 
00016  * Beep buzzer(p21);
00017  * 
00018  * int main() {
00019  *        ...
00020  *   buzzer.beep(1000,0.5);    
00021  *       ...
00022  * }
00023  * @endcode
00024  */
00025 
00026 
00027 
00028 namespace mbed {
00029 
00030 /* Class: Beep
00031  *  A class witch uses pwm to controle a beeper to generate sounds.
00032  */
00033 class Beep {
00034 
00035 
00036 
00037 public:
00038 
00039 
00040 /** Create a Beep object connected to the specified PwmOut pin
00041  *
00042  * @param pin PwmOut pin to connect to 
00043  */
00044     Beep (PinName pin);
00045 
00046 /** Beep with given frequency and duration.
00047  *
00048  * @param frequency - the frequency of the tone in Hz
00049  * @param time - the duration of the tone in seconds
00050  */
00051     
00052     
00053     void beep (float frequency, float time);
00054 
00055 
00056 
00057 /** stop the beep instantaneous 
00058  * usually not used 
00059  */
00060    
00061    
00062    
00063     void nobeep();
00064 
00065 
00066 
00067 
00068 private :
00069     PwmOut _pwm;
00070     Timeout toff;
00071 };
00072 
00073 
00074 
00075 }
00076 
00077 
00078 #endif