Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
F469_GUI/Button.hpp@2:2182df2d7810, 2017-03-31 (annotated)
- Committer:
- SquirrelGod
- Date:
- Fri Mar 31 15:36:26 2017 +0000
- Revision:
- 2:2182df2d7810
Programme ?cran capacitif
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SquirrelGod | 2:2182df2d7810 | 1 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 2 | // Button class handling multi-touch -- Header |
SquirrelGod | 2:2182df2d7810 | 3 | // Multi-touch: Enabled (default) |
SquirrelGod | 2:2182df2d7810 | 4 | // |
SquirrelGod | 2:2182df2d7810 | 5 | // 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki |
SquirrelGod | 2:2182df2d7810 | 6 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 7 | |
SquirrelGod | 2:2182df2d7810 | 8 | #ifndef F746_BUTTON_HPP |
SquirrelGod | 2:2182df2d7810 | 9 | #define F746_BUTTON_HPP |
SquirrelGod | 2:2182df2d7810 | 10 | |
SquirrelGod | 2:2182df2d7810 | 11 | #include "GuiBase.hpp" |
SquirrelGod | 2:2182df2d7810 | 12 | |
SquirrelGod | 2:2182df2d7810 | 13 | namespace Mikami |
SquirrelGod | 2:2182df2d7810 | 14 | { |
SquirrelGod | 2:2182df2d7810 | 15 | class Button : public GuiBase |
SquirrelGod | 2:2182df2d7810 | 16 | { |
SquirrelGod | 2:2182df2d7810 | 17 | public: |
SquirrelGod | 2:2182df2d7810 | 18 | // Constructor |
SquirrelGod | 2:2182df2d7810 | 19 | Button(uint16_t x, uint16_t y, |
SquirrelGod | 2:2182df2d7810 | 20 | uint16_t width, uint16_t height, |
SquirrelGod | 2:2182df2d7810 | 21 | const string str = "", sFONT &fonts = Font12, |
SquirrelGod | 2:2182df2d7810 | 22 | uint32_t textColor = GuiBase::ENUM_TEXT, |
SquirrelGod | 2:2182df2d7810 | 23 | uint32_t backColor = GuiBase::ENUM_BACK, |
SquirrelGod | 2:2182df2d7810 | 24 | uint32_t createdColor = GuiBase::ENUM_CREATED, |
SquirrelGod | 2:2182df2d7810 | 25 | uint32_t touchedColor = GuiBase::ENUM_TOUCHED, |
SquirrelGod | 2:2182df2d7810 | 26 | uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, |
SquirrelGod | 2:2182df2d7810 | 27 | uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT) |
SquirrelGod | 2:2182df2d7810 | 28 | : GuiBase(x, y, fonts, |
SquirrelGod | 2:2182df2d7810 | 29 | textColor, backColor, createdColor, |
SquirrelGod | 2:2182df2d7810 | 30 | touchedColor, inactiveColor, |
SquirrelGod | 2:2182df2d7810 | 31 | inactiveTextColor), |
SquirrelGod | 2:2182df2d7810 | 32 | W_(width), H_(height), STR_(str), active_(true) |
SquirrelGod | 2:2182df2d7810 | 33 | { Draw(); } |
SquirrelGod | 2:2182df2d7810 | 34 | |
SquirrelGod | 2:2182df2d7810 | 35 | // Draw button |
SquirrelGod | 2:2182df2d7810 | 36 | void Draw(uint32_t color, uint32_t textColor); |
SquirrelGod | 2:2182df2d7810 | 37 | void Draw(uint32_t color) { Draw(color, TEXT_COLOR_); } |
SquirrelGod | 2:2182df2d7810 | 38 | void Draw() { Draw(CREATED_COLOR_, TEXT_COLOR_); } |
SquirrelGod | 2:2182df2d7810 | 39 | |
SquirrelGod | 2:2182df2d7810 | 40 | // Erase button |
SquirrelGod | 2:2182df2d7810 | 41 | void Erase() { Draw(BACK_COLOR_, BACK_COLOR_); } |
SquirrelGod | 2:2182df2d7810 | 42 | |
SquirrelGod | 2:2182df2d7810 | 43 | // Check touch detected and redraw button |
SquirrelGod | 2:2182df2d7810 | 44 | bool Touched(); |
SquirrelGod | 2:2182df2d7810 | 45 | |
SquirrelGod | 2:2182df2d7810 | 46 | bool IsOnButton(); |
SquirrelGod | 2:2182df2d7810 | 47 | |
SquirrelGod | 2:2182df2d7810 | 48 | void Activate(); |
SquirrelGod | 2:2182df2d7810 | 49 | void Inactivate(); |
SquirrelGod | 2:2182df2d7810 | 50 | bool IsActive() { return active_; } |
SquirrelGod | 2:2182df2d7810 | 51 | |
SquirrelGod | 2:2182df2d7810 | 52 | // Set or reset multi-touch |
SquirrelGod | 2:2182df2d7810 | 53 | static void SetMultiTouch(bool tf) { multiTouch_ = tf; } |
SquirrelGod | 2:2182df2d7810 | 54 | |
SquirrelGod | 2:2182df2d7810 | 55 | private: |
SquirrelGod | 2:2182df2d7810 | 56 | const uint16_t W_, H_; |
SquirrelGod | 2:2182df2d7810 | 57 | const string STR_; |
SquirrelGod | 2:2182df2d7810 | 58 | bool active_; |
SquirrelGod | 2:2182df2d7810 | 59 | |
SquirrelGod | 2:2182df2d7810 | 60 | // disallow copy constructor and assignment operator |
SquirrelGod | 2:2182df2d7810 | 61 | Button(const Button&); |
SquirrelGod | 2:2182df2d7810 | 62 | Button& operator=(const Button&); |
SquirrelGod | 2:2182df2d7810 | 63 | }; |
SquirrelGod | 2:2182df2d7810 | 64 | } |
SquirrelGod | 2:2182df2d7810 | 65 | #endif // F746_BUTTON_HPP |