Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
F469_GUI/ButtonGroup.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 | // ButtonGroup class -- Header |
SquirrelGod | 2:2182df2d7810 | 3 | // |
SquirrelGod | 2:2182df2d7810 | 4 | // 2016/07/12, Copyright (c) 2016 MIKAMI, Naoki |
SquirrelGod | 2:2182df2d7810 | 5 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 6 | |
SquirrelGod | 2:2182df2d7810 | 7 | #ifndef F746_BUTTON_GROUP_HPP |
SquirrelGod | 2:2182df2d7810 | 8 | #define F746_BUTTON_GROUP_HPP |
SquirrelGod | 2:2182df2d7810 | 9 | |
SquirrelGod | 2:2182df2d7810 | 10 | #include "Button.hpp" |
SquirrelGod | 2:2182df2d7810 | 11 | |
SquirrelGod | 2:2182df2d7810 | 12 | namespace Mikami |
SquirrelGod | 2:2182df2d7810 | 13 | { |
SquirrelGod | 2:2182df2d7810 | 14 | class ButtonGroup : public GuiBase |
SquirrelGod | 2:2182df2d7810 | 15 | { |
SquirrelGod | 2:2182df2d7810 | 16 | public: |
SquirrelGod | 2:2182df2d7810 | 17 | // Constructor |
SquirrelGod | 2:2182df2d7810 | 18 | ButtonGroup(uint16_t x0, uint16_t y0, |
SquirrelGod | 2:2182df2d7810 | 19 | uint16_t width, uint16_t height, |
SquirrelGod | 2:2182df2d7810 | 20 | uint16_t number, const string str[], |
SquirrelGod | 2:2182df2d7810 | 21 | uint16_t spaceX = 0, uint16_t spaceY = 0, |
SquirrelGod | 2:2182df2d7810 | 22 | uint16_t column = 1, |
SquirrelGod | 2:2182df2d7810 | 23 | int touched = -1, // number for button initially touched-color |
SquirrelGod | 2:2182df2d7810 | 24 | sFONT &fonts = Font12, |
SquirrelGod | 2:2182df2d7810 | 25 | uint32_t textColor = GuiBase::ENUM_TEXT, |
SquirrelGod | 2:2182df2d7810 | 26 | uint32_t backColor = GuiBase::ENUM_BACK, |
SquirrelGod | 2:2182df2d7810 | 27 | uint32_t createdColor = GuiBase::ENUM_CREATED, |
SquirrelGod | 2:2182df2d7810 | 28 | uint32_t touchedColor = GuiBase::ENUM_TOUCHED, |
SquirrelGod | 2:2182df2d7810 | 29 | uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, |
SquirrelGod | 2:2182df2d7810 | 30 | uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT); |
SquirrelGod | 2:2182df2d7810 | 31 | |
SquirrelGod | 2:2182df2d7810 | 32 | // Destructor |
SquirrelGod | 2:2182df2d7810 | 33 | virtual ~ButtonGroup(); |
SquirrelGod | 2:2182df2d7810 | 34 | |
SquirrelGod | 2:2182df2d7810 | 35 | // Draw button |
SquirrelGod | 2:2182df2d7810 | 36 | bool Draw(int num, uint32_t color, uint32_t textColor); |
SquirrelGod | 2:2182df2d7810 | 37 | bool Draw(int num) { return Draw(num, CREATED_COLOR_, TEXT_COLOR_); } |
SquirrelGod | 2:2182df2d7810 | 38 | |
SquirrelGod | 2:2182df2d7810 | 39 | // Change to touched color |
SquirrelGod | 2:2182df2d7810 | 40 | bool TouchedColor(int num); |
SquirrelGod | 2:2182df2d7810 | 41 | |
SquirrelGod | 2:2182df2d7810 | 42 | // Draw all buttons |
SquirrelGod | 2:2182df2d7810 | 43 | void DrawAll(uint32_t color, uint32_t textColor) |
SquirrelGod | 2:2182df2d7810 | 44 | { for (int n=0; n<number_; n++) Draw(n, color, textColor); } |
SquirrelGod | 2:2182df2d7810 | 45 | void DrawAll() { DrawAll(CREATED_COLOR_, TEXT_COLOR_); } |
SquirrelGod | 2:2182df2d7810 | 46 | |
SquirrelGod | 2:2182df2d7810 | 47 | // Erase button |
SquirrelGod | 2:2182df2d7810 | 48 | bool Erase(int num); |
SquirrelGod | 2:2182df2d7810 | 49 | void EraseAll() |
SquirrelGod | 2:2182df2d7810 | 50 | { for (int n=0; n<number_; n++) Erase(n); } |
SquirrelGod | 2:2182df2d7810 | 51 | |
SquirrelGod | 2:2182df2d7810 | 52 | // Check touch detected for specified button |
SquirrelGod | 2:2182df2d7810 | 53 | bool Touched(int num); |
SquirrelGod | 2:2182df2d7810 | 54 | |
SquirrelGod | 2:2182df2d7810 | 55 | // Get touched number |
SquirrelGod | 2:2182df2d7810 | 56 | bool GetTouchedNumber(int &num); |
SquirrelGod | 2:2182df2d7810 | 57 | |
SquirrelGod | 2:2182df2d7810 | 58 | // Activate and inactivate button(s) |
SquirrelGod | 2:2182df2d7810 | 59 | bool Activate(int num); |
SquirrelGod | 2:2182df2d7810 | 60 | void ActivateAll() |
SquirrelGod | 2:2182df2d7810 | 61 | { for (int n=0; n<number_; n++) Activate(n); } |
SquirrelGod | 2:2182df2d7810 | 62 | bool Inactivate(int num); |
SquirrelGod | 2:2182df2d7810 | 63 | void InactivateAll() |
SquirrelGod | 2:2182df2d7810 | 64 | { for (int n=0; n<number_; n++) Inactivate(n); } |
SquirrelGod | 2:2182df2d7810 | 65 | |
SquirrelGod | 2:2182df2d7810 | 66 | private: |
SquirrelGod | 2:2182df2d7810 | 67 | Button **buttons_; |
SquirrelGod | 2:2182df2d7810 | 68 | int number_; |
SquirrelGod | 2:2182df2d7810 | 69 | __IO int prevNum_; |
SquirrelGod | 2:2182df2d7810 | 70 | |
SquirrelGod | 2:2182df2d7810 | 71 | // Check range of argument |
SquirrelGod | 2:2182df2d7810 | 72 | bool Range(int n) |
SquirrelGod | 2:2182df2d7810 | 73 | { return ((n >= 0) && (n < number_)); } |
SquirrelGod | 2:2182df2d7810 | 74 | |
SquirrelGod | 2:2182df2d7810 | 75 | // disallow copy constructor and assignment operator |
SquirrelGod | 2:2182df2d7810 | 76 | ButtonGroup(const ButtonGroup&); |
SquirrelGod | 2:2182df2d7810 | 77 | ButtonGroup& operator=(const ButtonGroup&); |
SquirrelGod | 2:2182df2d7810 | 78 | }; |
SquirrelGod | 2:2182df2d7810 | 79 | } |
SquirrelGod | 2:2182df2d7810 | 80 | #endif // F746_BUTTON_GROUP_HPP |