Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
F469_GUI/GuiBase.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 | // GuiBase class (abstract base class) ---- Header |
SquirrelGod | 2:2182df2d7810 | 3 | // |
SquirrelGod | 2:2182df2d7810 | 4 | // 2016/04/10, Copyright (c) 2016 MIKAMI, Naoki |
SquirrelGod | 2:2182df2d7810 | 5 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 6 | |
SquirrelGod | 2:2182df2d7810 | 7 | #ifndef F746_GUI_BASE_HPP |
SquirrelGod | 2:2182df2d7810 | 8 | #define F746_GUI_BASE_HPP |
SquirrelGod | 2:2182df2d7810 | 9 | |
SquirrelGod | 2:2182df2d7810 | 10 | #include "mbed.h" |
SquirrelGod | 2:2182df2d7810 | 11 | #include <string> |
SquirrelGod | 2:2182df2d7810 | 12 | #include "TS_DISCO_F469NI.h" |
SquirrelGod | 2:2182df2d7810 | 13 | #include "LCD_DISCO_F469NI.h" |
SquirrelGod | 2:2182df2d7810 | 14 | |
SquirrelGod | 2:2182df2d7810 | 15 | namespace Mikami |
SquirrelGod | 2:2182df2d7810 | 16 | { |
SquirrelGod | 2:2182df2d7810 | 17 | class GuiBase |
SquirrelGod | 2:2182df2d7810 | 18 | { |
SquirrelGod | 2:2182df2d7810 | 19 | public: |
SquirrelGod | 2:2182df2d7810 | 20 | static LCD_DISCO_F469NI* GetLcdPtr() { return &lcd_; } |
SquirrelGod | 2:2182df2d7810 | 21 | static TS_DISCO_F469NI* GetTsPtr() { return &ts_; } |
SquirrelGod | 2:2182df2d7810 | 22 | |
SquirrelGod | 2:2182df2d7810 | 23 | // If panel touched, return true |
SquirrelGod | 2:2182df2d7810 | 24 | static bool PanelTouched(); |
SquirrelGod | 2:2182df2d7810 | 25 | // Get touch panel state |
SquirrelGod | 2:2182df2d7810 | 26 | static TS_StateTypeDef GetTsState() { return state_; } |
SquirrelGod | 2:2182df2d7810 | 27 | |
SquirrelGod | 2:2182df2d7810 | 28 | enum { ENUM_TEXT = 0xFFFFFFFF, ENUM_BACK = 0xFF003538, |
SquirrelGod | 2:2182df2d7810 | 29 | ENUM_CREATED = 0xFF0068B7, ENUM_TOUCHED = 0xFF7F7FFF, |
SquirrelGod | 2:2182df2d7810 | 30 | ENUM_INACTIVE = 0xD0003538, ENUM_INACTIVE_TEXT = 0xFF808080}; |
SquirrelGod | 2:2182df2d7810 | 31 | |
SquirrelGod | 2:2182df2d7810 | 32 | protected: |
SquirrelGod | 2:2182df2d7810 | 33 | static LCD_DISCO_F469NI lcd_; // for LCD display |
SquirrelGod | 2:2182df2d7810 | 34 | static TS_DISCO_F469NI ts_; // for touch pannel |
SquirrelGod | 2:2182df2d7810 | 35 | |
SquirrelGod | 2:2182df2d7810 | 36 | static TS_StateTypeDef state_; |
SquirrelGod | 2:2182df2d7810 | 37 | static bool multiTouch_; |
SquirrelGod | 2:2182df2d7810 | 38 | |
SquirrelGod | 2:2182df2d7810 | 39 | const uint16_t X_, Y_; |
SquirrelGod | 2:2182df2d7810 | 40 | sFONT *const FONTS_; |
SquirrelGod | 2:2182df2d7810 | 41 | |
SquirrelGod | 2:2182df2d7810 | 42 | const uint32_t TEXT_COLOR_; |
SquirrelGod | 2:2182df2d7810 | 43 | const uint32_t BACK_COLOR_; |
SquirrelGod | 2:2182df2d7810 | 44 | const uint32_t CREATED_COLOR_; |
SquirrelGod | 2:2182df2d7810 | 45 | const uint32_t TOUCHED_COLOR_; |
SquirrelGod | 2:2182df2d7810 | 46 | const uint32_t INACTIVE_COLOR_; |
SquirrelGod | 2:2182df2d7810 | 47 | const uint32_t INACTIVE_TEXT_COLOR_; |
SquirrelGod | 2:2182df2d7810 | 48 | |
SquirrelGod | 2:2182df2d7810 | 49 | // Constructor |
SquirrelGod | 2:2182df2d7810 | 50 | GuiBase(uint16_t x =0, uint16_t y =0, |
SquirrelGod | 2:2182df2d7810 | 51 | sFONT &fonts = Font12, |
SquirrelGod | 2:2182df2d7810 | 52 | uint32_t textColor = GuiBase::ENUM_TEXT, |
SquirrelGod | 2:2182df2d7810 | 53 | uint32_t backColor = GuiBase::ENUM_BACK, |
SquirrelGod | 2:2182df2d7810 | 54 | uint32_t createdColor = GuiBase::ENUM_CREATED, |
SquirrelGod | 2:2182df2d7810 | 55 | uint32_t touchedColor = GuiBase::ENUM_TOUCHED, |
SquirrelGod | 2:2182df2d7810 | 56 | uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, |
SquirrelGod | 2:2182df2d7810 | 57 | uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT); |
SquirrelGod | 2:2182df2d7810 | 58 | |
SquirrelGod | 2:2182df2d7810 | 59 | void DrawString(uint16_t x, uint16_t y, const string str) |
SquirrelGod | 2:2182df2d7810 | 60 | { lcd_.DisplayStringAt(x, y, (uint8_t *)str.c_str(), LEFT_MODE); } |
SquirrelGod | 2:2182df2d7810 | 61 | |
SquirrelGod | 2:2182df2d7810 | 62 | private: |
SquirrelGod | 2:2182df2d7810 | 63 | static bool first_; |
SquirrelGod | 2:2182df2d7810 | 64 | |
SquirrelGod | 2:2182df2d7810 | 65 | // disallow copy constructor and assignment operator |
SquirrelGod | 2:2182df2d7810 | 66 | GuiBase(const GuiBase&); |
SquirrelGod | 2:2182df2d7810 | 67 | GuiBase& operator=(const GuiBase&); |
SquirrelGod | 2:2182df2d7810 | 68 | }; |
SquirrelGod | 2:2182df2d7810 | 69 | } |
SquirrelGod | 2:2182df2d7810 | 70 | #endif // F746_GUI_BASE_HPP |