Class virtual button for lcd and ts
buttons.h@0:055a9eb7d5eb, 2017-12-02 (annotated)
- Committer:
- jlpadiolleau
- Date:
- Sat Dec 02 11:47:56 2017 +0000
- Revision:
- 0:055a9eb7d5eb
Correction du TP4 d'info1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jlpadiolleau | 0:055a9eb7d5eb | 1 | #ifndef __BUTTONS_H |
jlpadiolleau | 0:055a9eb7d5eb | 2 | #define __BUTTONS_H |
jlpadiolleau | 0:055a9eb7d5eb | 3 | |
jlpadiolleau | 0:055a9eb7d5eb | 4 | #ifdef TARGET_DISCO_F746NG |
jlpadiolleau | 0:055a9eb7d5eb | 5 | |
jlpadiolleau | 0:055a9eb7d5eb | 6 | #include "mbed.h" |
jlpadiolleau | 0:055a9eb7d5eb | 7 | #include "stm32746g_discovery_lcd.h" |
jlpadiolleau | 0:055a9eb7d5eb | 8 | #include "stm32746g_discovery_ts.h" |
jlpadiolleau | 0:055a9eb7d5eb | 9 | |
jlpadiolleau | 0:055a9eb7d5eb | 10 | class button |
jlpadiolleau | 0:055a9eb7d5eb | 11 | { |
jlpadiolleau | 0:055a9eb7d5eb | 12 | public: |
jlpadiolleau | 0:055a9eb7d5eb | 13 | button(uint16_t x, uint16_t y, uint16_t w, uint16_t h,uint32_t colorOn,uint32_t colorOff); // Constructor |
jlpadiolleau | 0:055a9eb7d5eb | 14 | void draw(void); |
jlpadiolleau | 0:055a9eb7d5eb | 15 | bool read(void) {return m_state;} |
jlpadiolleau | 0:055a9eb7d5eb | 16 | bool getState(void); |
jlpadiolleau | 0:055a9eb7d5eb | 17 | operator bool(void) {return m_state;} |
jlpadiolleau | 0:055a9eb7d5eb | 18 | |
jlpadiolleau | 0:055a9eb7d5eb | 19 | private: |
jlpadiolleau | 0:055a9eb7d5eb | 20 | bool m_state; |
jlpadiolleau | 0:055a9eb7d5eb | 21 | bool m_memoState; |
jlpadiolleau | 0:055a9eb7d5eb | 22 | uint16_t m_x; // position x |
jlpadiolleau | 0:055a9eb7d5eb | 23 | uint16_t m_y; // position y |
jlpadiolleau | 0:055a9eb7d5eb | 24 | uint16_t m_w; // largeur |
jlpadiolleau | 0:055a9eb7d5eb | 25 | uint16_t m_h; // hauteur |
jlpadiolleau | 0:055a9eb7d5eb | 26 | uint32_t m_colorOn; // couleur On |
jlpadiolleau | 0:055a9eb7d5eb | 27 | uint32_t m_colorOff; // couleur Off |
jlpadiolleau | 0:055a9eb7d5eb | 28 | void readState(void); |
jlpadiolleau | 0:055a9eb7d5eb | 29 | Ticker m_touchRead; |
jlpadiolleau | 0:055a9eb7d5eb | 30 | }; |
jlpadiolleau | 0:055a9eb7d5eb | 31 | |
jlpadiolleau | 0:055a9eb7d5eb | 32 | #else |
jlpadiolleau | 0:055a9eb7d5eb | 33 | #error "This class must be used with DISCO_F746NG board only." |
jlpadiolleau | 0:055a9eb7d5eb | 34 | #endif //TARGET_DISCO_F746NG |
jlpadiolleau | 0:055a9eb7d5eb | 35 | |
jlpadiolleau | 0:055a9eb7d5eb | 36 | #endif |