Class virtual button for lcd and ts

buttons.h

Committer:
jlpadiolleau
Date:
2017-12-02
Revision:
0:055a9eb7d5eb

File content as of revision 0:055a9eb7d5eb:

#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