![](/media/cache/profiles/2e72ed76b7b3b9ce2f15fce64178dfaf.jpg.50x50_q85.jpg)
Shows how to use a display and the touch controller. A very basic calculator. Note that for some displays the LANDSCAPE define must be set for the layout to be correct.
Dependencies: DmTftLibrary mbed
Diff: Button.h
- Revision:
- 0:3713b01e72fe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Button.h Tue May 20 15:36:25 2014 +0000 @@ -0,0 +1,27 @@ +#ifndef BUTTON_h +#define BUTTON_h + +#include "DmTftBase.h" + +typedef void (*cbFunc)(uint32_t); + +class Button { +public: + Button(const char* caption, uint16_t x, uint16_t y, uint16_t width, uint16_t height); + void setAction(cbFunc func, uint32_t arg) { _func = func; _funcArg = arg; } + void setCaption(const char* caption) { _caption = caption; } + void setColors(uint16_t bg, uint16_t fg, uint16_t bgPressed, uint16_t fgPressed); + bool handle(uint16_t x, uint16_t y, bool pressed); + void draw(DmTftBase* tft); + +private: + const char* _caption; + uint16_t _x0, _y0, _x1, _y1; + uint16_t _bgCol, _fgCol, _bgColPressed, _fgColPressed; + bool _enabled, _pressed; + cbFunc _func; + uint32_t _funcArg; +}; + +#endif /* BUTTON_h */ +