Class virtual button for lcd and ts
Diff: buttons.h
- Revision:
- 0:055a9eb7d5eb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buttons.h Sat Dec 02 11:47:56 2017 +0000 @@ -0,0 +1,36 @@ +#ifndef __BUTTONS_H +#define __BUTTONS_H + +#ifdef TARGET_DISCO_F746NG + +#include "mbed.h" +#include "stm32746g_discovery_lcd.h" +#include "stm32746g_discovery_ts.h" + +class button +{ + public: + button(uint16_t x, uint16_t y, uint16_t w, uint16_t h,uint32_t colorOn,uint32_t colorOff); // Constructor + void draw(void); + bool read(void) {return m_state;} + bool getState(void); + operator bool(void) {return m_state;} + + private: + bool m_state; + bool m_memoState; + uint16_t m_x; // position x + uint16_t m_y; // position y + uint16_t m_w; // largeur + uint16_t m_h; // hauteur + uint32_t m_colorOn; // couleur On + uint32_t m_colorOff; // couleur Off + void readState(void); + Ticker m_touchRead; +}; + +#else +#error "This class must be used with DISCO_F746NG board only." +#endif //TARGET_DISCO_F746NG + +#endif \ No newline at end of file