Buttons changing color when tapped.

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Committer:
fzajdel
Date:
Sun May 19 11:59:32 2019 +0000
Revision:
2:bd49dd9c7bd6
Parent:
0:6d5a5f60d228
Touch screen with buttons

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fzajdel 0:6d5a5f60d228 1 #ifndef button_h
fzajdel 0:6d5a5f60d228 2 #define button_h
fzajdel 0:6d5a5f60d228 3
fzajdel 0:6d5a5f60d228 4 #include "mbed.h"
fzajdel 0:6d5a5f60d228 5 #include "rectangle.h"
fzajdel 0:6d5a5f60d228 6 #include "LCD_DISCO_F429ZI.h"
fzajdel 0:6d5a5f60d228 7 #include "config.h"
fzajdel 0:6d5a5f60d228 8 #include "widget.h"
fzajdel 0:6d5a5f60d228 9 #include "widgetcallback.h"
fzajdel 0:6d5a5f60d228 10 #include <string>
fzajdel 0:6d5a5f60d228 11
fzajdel 0:6d5a5f60d228 12 class Button : public Widget{
fzajdel 0:6d5a5f60d228 13 public:
fzajdel 0:6d5a5f60d228 14 Button(){}
fzajdel 0:6d5a5f60d228 15 Button(uint8_t x, uint8_t y, uint8_t width, uint8_t height, string Text = RECTANGLE_DEFAULT_TEXT);
fzajdel 0:6d5a5f60d228 16 Button(uint8_t x, uint8_t y, uint8_t width, uint8_t height, WidgetCallback* CbOnPress, WidgetCallback* CbOnRelease, string Text = RECTANGLE_DEFAULT_TEXT);
fzajdel 0:6d5a5f60d228 17 virtual ~Button(){};
fzajdel 0:6d5a5f60d228 18 virtual void Check(uint16_t X, uint16_t Y);
fzajdel 2:bd49dd9c7bd6 19 virtual bool isPressed(uint16_t X, uint16_t Y);
fzajdel 0:6d5a5f60d228 20 virtual Figure *GetFigure(); // Temporary Solution
fzajdel 0:6d5a5f60d228 21
fzajdel 0:6d5a5f60d228 22 private:
fzajdel 0:6d5a5f60d228 23 enum {PRESSED, RELEASED};
fzajdel 0:6d5a5f60d228 24 uint8_t State;
fzajdel 0:6d5a5f60d228 25 Rectangle* MyRectangle;
fzajdel 0:6d5a5f60d228 26 WidgetCallback* CbOnPress;
fzajdel 0:6d5a5f60d228 27 WidgetCallback* CbOnRelease;
fzajdel 0:6d5a5f60d228 28
fzajdel 0:6d5a5f60d228 29 void OnPress();
fzajdel 0:6d5a5f60d228 30 void OnRelease();
fzajdel 0:6d5a5f60d228 31 bool CheckRectRange(uint16_t x, uint16_t y);
fzajdel 0:6d5a5f60d228 32 };
fzajdel 0:6d5a5f60d228 33
fzajdel 0:6d5a5f60d228 34
fzajdel 0:6d5a5f60d228 35
fzajdel 0:6d5a5f60d228 36
fzajdel 0:6d5a5f60d228 37 #endif