
Buttons changing color when tapped.
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Diff: button.cpp
- Revision:
- 2:bd49dd9c7bd6
- Parent:
- 0:6d5a5f60d228
--- a/button.cpp Thu Apr 04 15:27:33 2019 +0000 +++ b/button.cpp Sun May 19 11:59:32 2019 +0000 @@ -32,6 +32,8 @@ void Button::Check(uint16_t X, uint16_t Y){ + State = (CheckRectRange(X,Y) ? PRESSED : RELEASED); + switch(State){ case PRESSED: OnPress(); @@ -40,13 +42,16 @@ OnRelease(); break; } - - State = (CheckRectRange(X,Y) ? PRESSED : RELEASED); -}; +}; + +bool Button::isPressed(uint16_t X, uint16_t Y){ + return (CheckRectRange(X,Y) ? PRESSED : RELEASED); +} void Button::OnPress(){ MyRectangle->SetFillingColor(BUTTON_PUSH_COLOR); + if(NULL != CbOnPress){ CbOnPress->Execute(); } @@ -55,6 +60,7 @@ void Button::OnRelease(){ MyRectangle->SetFillingColor(BUTTON_RELEASE_COLOR); + if(NULL != CbOnRelease) { CbOnRelease->Execute(); }