Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TextLCD mbed MMA8451Q TSI
ButtonMusical.cpp
- Committer:
- mfurlanetto
- Date:
- 2015-09-19
- Revision:
- 8:60231840370f
- Child:
- 10:6e18b220e10c
File content as of revision 8:60231840370f:
#include "Speaker.h"
#include "Note.cpp"
#include "Button.cpp"
class ButtonMusical: public Button{
public:
ButtonMusical(PinName pin, Note note, Speaker* speaker) : Button(pin), _note(note), sp(speaker) {
pressTimes=0;
}
void press() {
if(pressTimes==0)
{
sp->changeFrequency(_note.getFrequency());
pressTimes++;
}
}
void release() {
sp->changeFrequency(-_note.getFrequency()*pressTimes);
pressTimes=0;
}
private:
Note _note;
int pressTimes;
Speaker* sp;
};
