Automate écran capacitif
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed
Fork of DISCO-F469NI_LCD_demo by
F469_GUI/SeekBar.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 | // SeekBar 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_SEEKBAR_HPP |
SquirrelGod | 2:2182df2d7810 | 8 | #define F746_SEEKBAR_HPP |
SquirrelGod | 2:2182df2d7810 | 9 | |
SquirrelGod | 2:2182df2d7810 | 10 | #include "GuiBase.hpp" |
SquirrelGod | 2:2182df2d7810 | 11 | #include "Label.hpp" |
SquirrelGod | 2:2182df2d7810 | 12 | |
SquirrelGod | 2:2182df2d7810 | 13 | namespace Mikami |
SquirrelGod | 2:2182df2d7810 | 14 | { |
SquirrelGod | 2:2182df2d7810 | 15 | class SeekBar : public GuiBase |
SquirrelGod | 2:2182df2d7810 | 16 | { |
SquirrelGod | 2:2182df2d7810 | 17 | public: |
SquirrelGod | 2:2182df2d7810 | 18 | enum Orientation { Holizontal, Vertical }; |
SquirrelGod | 2:2182df2d7810 | 19 | |
SquirrelGod | 2:2182df2d7810 | 20 | struct Point |
SquirrelGod | 2:2182df2d7810 | 21 | { |
SquirrelGod | 2:2182df2d7810 | 22 | uint16_t x, y; |
SquirrelGod | 2:2182df2d7810 | 23 | Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} |
SquirrelGod | 2:2182df2d7810 | 24 | }; |
SquirrelGod | 2:2182df2d7810 | 25 | |
SquirrelGod | 2:2182df2d7810 | 26 | // Constructor |
SquirrelGod | 2:2182df2d7810 | 27 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
SquirrelGod | 2:2182df2d7810 | 28 | float min, float max, float initialValue, |
SquirrelGod | 2:2182df2d7810 | 29 | Orientation hv = Holizontal, |
SquirrelGod | 2:2182df2d7810 | 30 | uint32_t thumbColor = 0xFFB0B0FF, |
SquirrelGod | 2:2182df2d7810 | 31 | uint16_t thumbSize = 30, uint16_t width = 4, |
SquirrelGod | 2:2182df2d7810 | 32 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
SquirrelGod | 2:2182df2d7810 | 33 | uint32_t colorH = 0xFFB0B0B0, |
SquirrelGod | 2:2182df2d7810 | 34 | uint32_t backColor = GuiBase::ENUM_BACK) |
SquirrelGod | 2:2182df2d7810 | 35 | : GuiBase(x, y, Font12, 0, backColor, thumbColor), |
SquirrelGod | 2:2182df2d7810 | 36 | L_(length), W_(width), |
SquirrelGod | 2:2182df2d7810 | 37 | SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), |
SquirrelGod | 2:2182df2d7810 | 38 | MIN_(min), MAX_(max), ORIENT_(hv), v_(initialValue), |
SquirrelGod | 2:2182df2d7810 | 39 | labelOn_(false), slided_(false), active_(true) |
SquirrelGod | 2:2182df2d7810 | 40 | { Draw(initialValue); } |
SquirrelGod | 2:2182df2d7810 | 41 | |
SquirrelGod | 2:2182df2d7810 | 42 | // Constructor with scale value (only horizontal) |
SquirrelGod | 2:2182df2d7810 | 43 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
SquirrelGod | 2:2182df2d7810 | 44 | float min, float max, float initialValue, |
SquirrelGod | 2:2182df2d7810 | 45 | string left, string center, string right, |
SquirrelGod | 2:2182df2d7810 | 46 | uint32_t thumbColor = 0xFFB0B0FF, |
SquirrelGod | 2:2182df2d7810 | 47 | uint16_t thumbSize = 30, uint16_t width = 4, |
SquirrelGod | 2:2182df2d7810 | 48 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
SquirrelGod | 2:2182df2d7810 | 49 | uint32_t colorH = 0xFFB0B0B0, |
SquirrelGod | 2:2182df2d7810 | 50 | uint32_t backColor = GuiBase::ENUM_BACK); |
SquirrelGod | 2:2182df2d7810 | 51 | |
SquirrelGod | 2:2182df2d7810 | 52 | virtual ~SeekBar(); |
SquirrelGod | 2:2182df2d7810 | 53 | |
SquirrelGod | 2:2182df2d7810 | 54 | bool Slide(); |
SquirrelGod | 2:2182df2d7810 | 55 | float GetValue() { return v_; } |
SquirrelGod | 2:2182df2d7810 | 56 | int GetIntValue() { return Round(v_); } |
SquirrelGod | 2:2182df2d7810 | 57 | |
SquirrelGod | 2:2182df2d7810 | 58 | void Activate(); |
SquirrelGod | 2:2182df2d7810 | 59 | void Inactivate(); |
SquirrelGod | 2:2182df2d7810 | 60 | bool IsActive() { return active_; } |
SquirrelGod | 2:2182df2d7810 | 61 | |
SquirrelGod | 2:2182df2d7810 | 62 | bool IsOnThumb(uint16_t &x, uint16_t &y); |
SquirrelGod | 2:2182df2d7810 | 63 | void Draw(float value, bool fill = false); |
SquirrelGod | 2:2182df2d7810 | 64 | void Redraw(bool fill = false); |
SquirrelGod | 2:2182df2d7810 | 65 | float ToValue(Point pt); |
SquirrelGod | 2:2182df2d7810 | 66 | |
SquirrelGod | 2:2182df2d7810 | 67 | void SetValue(float v) { v_ = v; } |
SquirrelGod | 2:2182df2d7810 | 68 | void SetSlided(bool tf) { slided_ = tf; } |
SquirrelGod | 2:2182df2d7810 | 69 | bool GetSlided() { return slided_; } |
SquirrelGod | 2:2182df2d7810 | 70 | |
SquirrelGod | 2:2182df2d7810 | 71 | private: |
SquirrelGod | 2:2182df2d7810 | 72 | const uint16_t L_, W_; |
SquirrelGod | 2:2182df2d7810 | 73 | const uint16_t SIZE_; // Size of thumb |
SquirrelGod | 2:2182df2d7810 | 74 | const uint32_t COLOR_L_, COLOR_H_; |
SquirrelGod | 2:2182df2d7810 | 75 | const float MIN_, MAX_; |
SquirrelGod | 2:2182df2d7810 | 76 | const Orientation ORIENT_; |
SquirrelGod | 2:2182df2d7810 | 77 | |
SquirrelGod | 2:2182df2d7810 | 78 | Label *labelLCR_[3]; |
SquirrelGod | 2:2182df2d7810 | 79 | float v_; // value of seekbar |
SquirrelGod | 2:2182df2d7810 | 80 | bool labelOn_; |
SquirrelGod | 2:2182df2d7810 | 81 | bool slided_; |
SquirrelGod | 2:2182df2d7810 | 82 | bool active_; |
SquirrelGod | 2:2182df2d7810 | 83 | |
SquirrelGod | 2:2182df2d7810 | 84 | int Round(float x) { return x + 0.5f - (x < 0); } |
SquirrelGod | 2:2182df2d7810 | 85 | Point ToPoint(float value); |
SquirrelGod | 2:2182df2d7810 | 86 | float Saturate(float value); |
SquirrelGod | 2:2182df2d7810 | 87 | |
SquirrelGod | 2:2182df2d7810 | 88 | // disallow copy constructor and assignment operator |
SquirrelGod | 2:2182df2d7810 | 89 | SeekBar(const SeekBar&); |
SquirrelGod | 2:2182df2d7810 | 90 | SeekBar& operator=(const SeekBar&); |
SquirrelGod | 2:2182df2d7810 | 91 | }; |
SquirrelGod | 2:2182df2d7810 | 92 | } |
SquirrelGod | 2:2182df2d7810 | 93 | #endif // F746_SEEKBAR_HPP |