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
Button.cpp@1:47973f27d645, 2015-08-14 (annotated)
- Committer:
- mfurlanetto
- Date:
- Fri Aug 14 13:32:24 2015 +0000
- Revision:
- 1:47973f27d645
- Parent:
- 0:f48fccfff709
- Child:
- 2:86de87ec731a
funziona, ma non mi piace il codice.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfurlanetto | 0:f48fccfff709 | 1 | #include "mbed.h" |
mfurlanetto | 0:f48fccfff709 | 2 | #include "Speaker.h" |
mfurlanetto | 0:f48fccfff709 | 3 | |
mfurlanetto | 0:f48fccfff709 | 4 | class Button { |
mfurlanetto | 0:f48fccfff709 | 5 | public: |
mfurlanetto | 1:47973f27d645 | 6 | Button(PinName pin, int note, bool* buffer, DigitalOut* myled) : _interrupt(pin) { |
mfurlanetto | 0:f48fccfff709 | 7 | _code=note; |
mfurlanetto | 0:f48fccfff709 | 8 | led=myled; |
mfurlanetto | 1:47973f27d645 | 9 | noteRegister=buffer; |
mfurlanetto | 1:47973f27d645 | 10 | _interrupt.rise(this, &Button::release); |
mfurlanetto | 1:47973f27d645 | 11 | _interrupt.fall(this, &Button::press); |
mfurlanetto | 1:47973f27d645 | 12 | isPressed=false; |
mfurlanetto | 0:f48fccfff709 | 13 | } |
mfurlanetto | 0:f48fccfff709 | 14 | |
mfurlanetto | 0:f48fccfff709 | 15 | void press() { |
mfurlanetto | 1:47973f27d645 | 16 | *noteRegister=true; |
mfurlanetto | 1:47973f27d645 | 17 | *led=0; |
mfurlanetto | 0:f48fccfff709 | 18 | } |
mfurlanetto | 0:f48fccfff709 | 19 | |
mfurlanetto | 1:47973f27d645 | 20 | void release() { |
mfurlanetto | 1:47973f27d645 | 21 | *noteRegister=false; |
mfurlanetto | 1:47973f27d645 | 22 | *led=1; |
mfurlanetto | 0:f48fccfff709 | 23 | } |
mfurlanetto | 0:f48fccfff709 | 24 | |
mfurlanetto | 0:f48fccfff709 | 25 | private: |
mfurlanetto | 0:f48fccfff709 | 26 | InterruptIn _interrupt; |
mfurlanetto | 0:f48fccfff709 | 27 | int _code; |
mfurlanetto | 1:47973f27d645 | 28 | bool* noteRegister; |
mfurlanetto | 0:f48fccfff709 | 29 | DigitalOut* led; |
mfurlanetto | 1:47973f27d645 | 30 | bool isPressed; |
mfurlanetto | 0:f48fccfff709 | 31 | }; |