Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
F469_GUI/NumericLabel.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 | // NumericLabel class -- derived class of Label class |
SquirrelGod | 2:2182df2d7810 | 3 | // |
SquirrelGod | 2:2182df2d7810 | 4 | // 2016/04/12, Copyright (c) 2016 MIKAMI, Naoki |
SquirrelGod | 2:2182df2d7810 | 5 | //----------------------------------------------------------- |
SquirrelGod | 2:2182df2d7810 | 6 | |
SquirrelGod | 2:2182df2d7810 | 7 | #ifndef F746_NUMERIC_LABEL_HPP |
SquirrelGod | 2:2182df2d7810 | 8 | #define F746_NUMERIC_LABEL_HPP |
SquirrelGod | 2:2182df2d7810 | 9 | |
SquirrelGod | 2:2182df2d7810 | 10 | #include "Label.hpp" |
SquirrelGod | 2:2182df2d7810 | 11 | |
SquirrelGod | 2:2182df2d7810 | 12 | namespace Mikami |
SquirrelGod | 2:2182df2d7810 | 13 | { |
SquirrelGod | 2:2182df2d7810 | 14 | template <typename T> class NumericLabel : public Label |
SquirrelGod | 2:2182df2d7810 | 15 | { |
SquirrelGod | 2:2182df2d7810 | 16 | public: |
SquirrelGod | 2:2182df2d7810 | 17 | // Constructor without drawing value |
SquirrelGod | 2:2182df2d7810 | 18 | NumericLabel(uint16_t x, uint16_t y, |
SquirrelGod | 2:2182df2d7810 | 19 | TextAlignMode mode = LEFT, |
SquirrelGod | 2:2182df2d7810 | 20 | sFONT &fonts = Font12, |
SquirrelGod | 2:2182df2d7810 | 21 | uint32_t textColor = GuiBase::ENUM_TEXT, |
SquirrelGod | 2:2182df2d7810 | 22 | uint32_t backColor = GuiBase::ENUM_BACK) |
SquirrelGod | 2:2182df2d7810 | 23 | : Label(x, y, "", mode, fonts, textColor, backColor) {} |
SquirrelGod | 2:2182df2d7810 | 24 | |
SquirrelGod | 2:2182df2d7810 | 25 | // Constructor with drawing value |
SquirrelGod | 2:2182df2d7810 | 26 | NumericLabel(uint16_t x, uint16_t y, |
SquirrelGod | 2:2182df2d7810 | 27 | const char fmt[], T val, |
SquirrelGod | 2:2182df2d7810 | 28 | TextAlignMode mode = LEFT, |
SquirrelGod | 2:2182df2d7810 | 29 | sFONT &fonts = Font12, |
SquirrelGod | 2:2182df2d7810 | 30 | uint32_t textColor = GuiBase::ENUM_TEXT, |
SquirrelGod | 2:2182df2d7810 | 31 | uint32_t backColor = GuiBase::ENUM_BACK) |
SquirrelGod | 2:2182df2d7810 | 32 | : Label(x, y, "", mode, fonts, textColor, backColor) |
SquirrelGod | 2:2182df2d7810 | 33 | { Draw(fmt, val); } |
SquirrelGod | 2:2182df2d7810 | 34 | |
SquirrelGod | 2:2182df2d7810 | 35 | // Draw value |
SquirrelGod | 2:2182df2d7810 | 36 | void Draw(const char fmt[], T val) |
SquirrelGod | 2:2182df2d7810 | 37 | { |
SquirrelGod | 2:2182df2d7810 | 38 | sprintf(str_, fmt, val); |
SquirrelGod | 2:2182df2d7810 | 39 | Label::Draw(str_); |
SquirrelGod | 2:2182df2d7810 | 40 | } |
SquirrelGod | 2:2182df2d7810 | 41 | |
SquirrelGod | 2:2182df2d7810 | 42 | // Draw previous value with specified color |
SquirrelGod | 2:2182df2d7810 | 43 | void Draw(uint32_t color) |
SquirrelGod | 2:2182df2d7810 | 44 | { Label::Draw(str_, color); } |
SquirrelGod | 2:2182df2d7810 | 45 | |
SquirrelGod | 2:2182df2d7810 | 46 | private: |
SquirrelGod | 2:2182df2d7810 | 47 | char str_[81]; |
SquirrelGod | 2:2182df2d7810 | 48 | |
SquirrelGod | 2:2182df2d7810 | 49 | // disallow copy constructor and assignment operator |
SquirrelGod | 2:2182df2d7810 | 50 | NumericLabel(const NumericLabel&); |
SquirrelGod | 2:2182df2d7810 | 51 | NumericLabel& operator=(const NumericLabel&); |
SquirrelGod | 2:2182df2d7810 | 52 | }; |
SquirrelGod | 2:2182df2d7810 | 53 | } |
SquirrelGod | 2:2182df2d7810 | 54 | #endif // F746_NUMERIC_LABEL_HPP |