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
Diff: Button.cpp
- Revision:
- 1:47973f27d645
- Parent:
- 0:f48fccfff709
- Child:
- 2:86de87ec731a
--- a/Button.cpp Fri Aug 14 10:35:11 2015 +0000 +++ b/Button.cpp Fri Aug 14 13:32:24 2015 +0000 @@ -3,26 +3,29 @@ class Button { public: - Button(PinName pin, int note, Speaker* s, DigitalOut* myled) : _interrupt(pin) { + Button(PinName pin, int note, bool* buffer, DigitalOut* myled) : _interrupt(pin) { _code=note; led=myled; - speaker=s; - _interrupt.rise(this, &Button::press); - _interrupt.fall(this, &Button::release); + noteRegister=buffer; + _interrupt.rise(this, &Button::release); + _interrupt.fall(this, &Button::press); + isPressed=false; } void press() { - speaker->PlayNote(_code, 0.3, 0.2); - *led=1; + *noteRegister=true; + *led=0; } - void release() { - *led=0; + void release() { + *noteRegister=false; + *led=1; } private: InterruptIn _interrupt; int _code; - Speaker* speaker; + bool* noteRegister; DigitalOut* led; + bool isPressed; }; \ No newline at end of file