![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CQエレクトロニクス・セミナ「実習・マイコンを動かしながら学ぶディジタル・フィルタ」で使うプログラム.1次IIRフィルタの係数をターミナルから変更できる. http://seminar.cqpub.co.jp/ccm/ES18-0020
Dependencies: mbed Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
F746_Gui_New/SeekBar.hpp@0:47718d3154d9, 2017-10-09 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Oct 09 02:36:11 2017 +0000
- Revision:
- 0:47718d3154d9
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:47718d3154d9 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 2 | // SeekBar class -- Header |
MikamiUitOpen | 0:47718d3154d9 | 3 | // |
MikamiUitOpen | 0:47718d3154d9 | 4 | // 2017/01/25, Copyright (c) 2017 MIKAMI, Naoki |
MikamiUitOpen | 0:47718d3154d9 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 6 | |
MikamiUitOpen | 0:47718d3154d9 | 7 | #ifndef F746_SEEKBAR_HPP |
MikamiUitOpen | 0:47718d3154d9 | 8 | #define F746_SEEKBAR_HPP |
MikamiUitOpen | 0:47718d3154d9 | 9 | |
MikamiUitOpen | 0:47718d3154d9 | 10 | #include "GuiBase.hpp" |
MikamiUitOpen | 0:47718d3154d9 | 11 | #include "Label.hpp" |
MikamiUitOpen | 0:47718d3154d9 | 12 | |
MikamiUitOpen | 0:47718d3154d9 | 13 | namespace Mikami |
MikamiUitOpen | 0:47718d3154d9 | 14 | { |
MikamiUitOpen | 0:47718d3154d9 | 15 | class SeekBar : public GuiBase |
MikamiUitOpen | 0:47718d3154d9 | 16 | { |
MikamiUitOpen | 0:47718d3154d9 | 17 | public: |
MikamiUitOpen | 0:47718d3154d9 | 18 | enum Orientation { Holizontal, Vertical }; |
MikamiUitOpen | 0:47718d3154d9 | 19 | |
MikamiUitOpen | 0:47718d3154d9 | 20 | struct Point |
MikamiUitOpen | 0:47718d3154d9 | 21 | { |
MikamiUitOpen | 0:47718d3154d9 | 22 | uint16_t x, y; |
MikamiUitOpen | 0:47718d3154d9 | 23 | Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} |
MikamiUitOpen | 0:47718d3154d9 | 24 | }; |
MikamiUitOpen | 0:47718d3154d9 | 25 | |
MikamiUitOpen | 0:47718d3154d9 | 26 | // Constructor |
MikamiUitOpen | 0:47718d3154d9 | 27 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
MikamiUitOpen | 0:47718d3154d9 | 28 | float min, float max, float initialValue, |
MikamiUitOpen | 0:47718d3154d9 | 29 | Orientation hv = Holizontal, |
MikamiUitOpen | 0:47718d3154d9 | 30 | uint32_t thumbColor = 0xFFB0B0FF, |
MikamiUitOpen | 0:47718d3154d9 | 31 | uint16_t thumbSize = 30, uint16_t width = 4, |
MikamiUitOpen | 0:47718d3154d9 | 32 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
MikamiUitOpen | 0:47718d3154d9 | 33 | uint32_t colorH = 0xFFB0B0B0, |
MikamiUitOpen | 0:47718d3154d9 | 34 | uint32_t backColor = GuiBase::ENUM_BACK) |
MikamiUitOpen | 0:47718d3154d9 | 35 | : GuiBase(x, y, Font12, 0, backColor, thumbColor), |
MikamiUitOpen | 0:47718d3154d9 | 36 | L_(length), W_(width), |
MikamiUitOpen | 0:47718d3154d9 | 37 | SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), |
MikamiUitOpen | 0:47718d3154d9 | 38 | MIN_(min), MAX_(max), ORIENT_(hv), v_(initialValue), |
MikamiUitOpen | 0:47718d3154d9 | 39 | labelOn_(false), slided_(false), active_(true) |
MikamiUitOpen | 0:47718d3154d9 | 40 | { Draw(initialValue); } |
MikamiUitOpen | 0:47718d3154d9 | 41 | |
MikamiUitOpen | 0:47718d3154d9 | 42 | // Constructor with scale value (only horizontal) |
MikamiUitOpen | 0:47718d3154d9 | 43 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
MikamiUitOpen | 0:47718d3154d9 | 44 | float min, float max, float initialValue, |
MikamiUitOpen | 0:47718d3154d9 | 45 | string left, string center, string right, |
MikamiUitOpen | 0:47718d3154d9 | 46 | uint32_t thumbColor = 0xFFB0B0FF, |
MikamiUitOpen | 0:47718d3154d9 | 47 | uint16_t thumbSize = 30, uint16_t width = 4, |
MikamiUitOpen | 0:47718d3154d9 | 48 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
MikamiUitOpen | 0:47718d3154d9 | 49 | uint32_t colorH = 0xFFB0B0B0, |
MikamiUitOpen | 0:47718d3154d9 | 50 | uint32_t backColor = GuiBase::ENUM_BACK); |
MikamiUitOpen | 0:47718d3154d9 | 51 | |
MikamiUitOpen | 0:47718d3154d9 | 52 | virtual ~SeekBar() |
MikamiUitOpen | 0:47718d3154d9 | 53 | { for (int n=0; n<3; n++) delete labelLCR_[n]; } |
MikamiUitOpen | 0:47718d3154d9 | 54 | |
MikamiUitOpen | 0:47718d3154d9 | 55 | bool Slide(); |
MikamiUitOpen | 0:47718d3154d9 | 56 | float GetValue() { return v_; } |
MikamiUitOpen | 0:47718d3154d9 | 57 | int GetIntValue() { return Round(v_); } |
MikamiUitOpen | 0:47718d3154d9 | 58 | |
MikamiUitOpen | 0:47718d3154d9 | 59 | void Activate(); |
MikamiUitOpen | 0:47718d3154d9 | 60 | void Inactivate(); |
MikamiUitOpen | 0:47718d3154d9 | 61 | bool IsActive() { return active_; } |
MikamiUitOpen | 0:47718d3154d9 | 62 | |
MikamiUitOpen | 0:47718d3154d9 | 63 | bool IsOnThumb(uint16_t &x, uint16_t &y); |
MikamiUitOpen | 0:47718d3154d9 | 64 | void Draw(float value, bool fill = false); |
MikamiUitOpen | 0:47718d3154d9 | 65 | void Redraw(bool fill = false); |
MikamiUitOpen | 0:47718d3154d9 | 66 | float ToValue(Point pt); |
MikamiUitOpen | 0:47718d3154d9 | 67 | |
MikamiUitOpen | 0:47718d3154d9 | 68 | void SetValue(float v) { v_ = v; } |
MikamiUitOpen | 0:47718d3154d9 | 69 | void SetSlided(bool tf) { slided_ = tf; } |
MikamiUitOpen | 0:47718d3154d9 | 70 | bool GetSlided() { return slided_; } |
MikamiUitOpen | 0:47718d3154d9 | 71 | |
MikamiUitOpen | 0:47718d3154d9 | 72 | private: |
MikamiUitOpen | 0:47718d3154d9 | 73 | const uint16_t L_, W_; |
MikamiUitOpen | 0:47718d3154d9 | 74 | const uint16_t SIZE_; // Size of thumb |
MikamiUitOpen | 0:47718d3154d9 | 75 | const uint32_t COLOR_L_, COLOR_H_; |
MikamiUitOpen | 0:47718d3154d9 | 76 | const float MIN_, MAX_; |
MikamiUitOpen | 0:47718d3154d9 | 77 | const Orientation ORIENT_; |
MikamiUitOpen | 0:47718d3154d9 | 78 | |
MikamiUitOpen | 0:47718d3154d9 | 79 | Label *labelLCR_[3]; |
MikamiUitOpen | 0:47718d3154d9 | 80 | float v_; // value of seekbar |
MikamiUitOpen | 0:47718d3154d9 | 81 | bool labelOn_; |
MikamiUitOpen | 0:47718d3154d9 | 82 | bool slided_; |
MikamiUitOpen | 0:47718d3154d9 | 83 | bool active_; |
MikamiUitOpen | 0:47718d3154d9 | 84 | |
MikamiUitOpen | 0:47718d3154d9 | 85 | int Round(float x) { return x + 0.5f - (x < 0); } |
MikamiUitOpen | 0:47718d3154d9 | 86 | Point ToPoint(float value); |
MikamiUitOpen | 0:47718d3154d9 | 87 | float Saturate(float value); |
MikamiUitOpen | 0:47718d3154d9 | 88 | |
MikamiUitOpen | 0:47718d3154d9 | 89 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:47718d3154d9 | 90 | SeekBar(const SeekBar&); |
MikamiUitOpen | 0:47718d3154d9 | 91 | SeekBar& operator=(const SeekBar&); |
MikamiUitOpen | 0:47718d3154d9 | 92 | }; |
MikamiUitOpen | 0:47718d3154d9 | 93 | } |
MikamiUitOpen | 0:47718d3154d9 | 94 | #endif // F746_SEEKBAR_HPP |
MikamiUitOpen | 0:47718d3154d9 | 95 |