Fork of beep lib. Enables play of continous tones and changing of frequency on the fly
Fork of beep by
Diff: beep.c
- Revision:
- 0:18e4a9c978ec
- Child:
- 2:a34405c20cf5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/beep.c Tue Feb 01 18:44:45 2011 +0000 @@ -0,0 +1,26 @@ +#include "beep.h" +#include "mbed.h" + +using namespace mbed; +// constructor +Beep::Beep(PinName pin) : _pwm(pin) { + _pwm.write(0.0); // after creating it have to be off +} + +// switch off +void Beep::nobeep() { + _pwm.write(0.0); +} + + +// beep +void Beep::beep(float freq, float time) { + + _pwm.period(1.0/freq); + _pwm.write(0.5); // 50% duty cycle - beep on + toff.attach(this,&Beep::nobeep, time); // time to off +} + + + +