![](/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/NumericLabel.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 | // NumericLabel class -- derived class of Label class |
MikamiUitOpen | 0:47718d3154d9 | 3 | // |
MikamiUitOpen | 0:47718d3154d9 | 4 | // 2016/11/07, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:47718d3154d9 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 6 | |
MikamiUitOpen | 0:47718d3154d9 | 7 | #ifndef F746_NUMERIC_LABEL_HPP |
MikamiUitOpen | 0:47718d3154d9 | 8 | #define F746_NUMERIC_LABEL_HPP |
MikamiUitOpen | 0:47718d3154d9 | 9 | |
MikamiUitOpen | 0:47718d3154d9 | 10 | #include "Label.hpp" |
MikamiUitOpen | 0:47718d3154d9 | 11 | |
MikamiUitOpen | 0:47718d3154d9 | 12 | namespace Mikami |
MikamiUitOpen | 0:47718d3154d9 | 13 | { |
MikamiUitOpen | 0:47718d3154d9 | 14 | template <typename T> class NumericLabel : public Label |
MikamiUitOpen | 0:47718d3154d9 | 15 | { |
MikamiUitOpen | 0:47718d3154d9 | 16 | public: |
MikamiUitOpen | 0:47718d3154d9 | 17 | // Constructor without drawing value |
MikamiUitOpen | 0:47718d3154d9 | 18 | NumericLabel(uint16_t x, uint16_t y, |
MikamiUitOpen | 0:47718d3154d9 | 19 | const char fmt[], |
MikamiUitOpen | 0:47718d3154d9 | 20 | TextAlignMode mode = LEFT, |
MikamiUitOpen | 0:47718d3154d9 | 21 | sFONT &fonts = Font12, |
MikamiUitOpen | 0:47718d3154d9 | 22 | uint32_t textColor = GuiBase::ENUM_TEXT, |
MikamiUitOpen | 0:47718d3154d9 | 23 | uint32_t backColor = GuiBase::ENUM_BACK) |
MikamiUitOpen | 0:47718d3154d9 | 24 | : Label(x, y, "", mode, fonts, textColor, backColor), FMT_(fmt) {} |
MikamiUitOpen | 0:47718d3154d9 | 25 | |
MikamiUitOpen | 0:47718d3154d9 | 26 | // Constructor with drawing value |
MikamiUitOpen | 0:47718d3154d9 | 27 | NumericLabel(uint16_t x, uint16_t y, |
MikamiUitOpen | 0:47718d3154d9 | 28 | const char fmt[], T val, |
MikamiUitOpen | 0:47718d3154d9 | 29 | TextAlignMode mode = LEFT, |
MikamiUitOpen | 0:47718d3154d9 | 30 | sFONT &fonts = Font12, |
MikamiUitOpen | 0:47718d3154d9 | 31 | uint32_t textColor = GuiBase::ENUM_TEXT, |
MikamiUitOpen | 0:47718d3154d9 | 32 | uint32_t backColor = GuiBase::ENUM_BACK) |
MikamiUitOpen | 0:47718d3154d9 | 33 | : Label(x, y, "", mode, fonts, textColor, backColor), FMT_(fmt) |
MikamiUitOpen | 0:47718d3154d9 | 34 | { Draw(val); } |
MikamiUitOpen | 0:47718d3154d9 | 35 | |
MikamiUitOpen | 0:47718d3154d9 | 36 | // Draw value using format specified in constructor |
MikamiUitOpen | 0:47718d3154d9 | 37 | void Draw(T val) |
MikamiUitOpen | 0:47718d3154d9 | 38 | { |
MikamiUitOpen | 0:47718d3154d9 | 39 | sprintf(str_, FMT_, val); |
MikamiUitOpen | 0:47718d3154d9 | 40 | Label::Draw(str_); |
MikamiUitOpen | 0:47718d3154d9 | 41 | } |
MikamiUitOpen | 0:47718d3154d9 | 42 | |
MikamiUitOpen | 0:47718d3154d9 | 43 | // Draw value |
MikamiUitOpen | 0:47718d3154d9 | 44 | void Draw(const char fmt[], T val) |
MikamiUitOpen | 0:47718d3154d9 | 45 | { |
MikamiUitOpen | 0:47718d3154d9 | 46 | sprintf(str_, fmt, val); |
MikamiUitOpen | 0:47718d3154d9 | 47 | Label::Draw(str_); |
MikamiUitOpen | 0:47718d3154d9 | 48 | } |
MikamiUitOpen | 0:47718d3154d9 | 49 | |
MikamiUitOpen | 0:47718d3154d9 | 50 | // Draw previous value with specified color |
MikamiUitOpen | 0:47718d3154d9 | 51 | void Redraw(uint32_t color) |
MikamiUitOpen | 0:47718d3154d9 | 52 | { Label::Draw(str_, color); } |
MikamiUitOpen | 0:47718d3154d9 | 53 | |
MikamiUitOpen | 0:47718d3154d9 | 54 | private: |
MikamiUitOpen | 0:47718d3154d9 | 55 | const char *const FMT_; |
MikamiUitOpen | 0:47718d3154d9 | 56 | char str_[81]; |
MikamiUitOpen | 0:47718d3154d9 | 57 | |
MikamiUitOpen | 0:47718d3154d9 | 58 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:47718d3154d9 | 59 | NumericLabel(const NumericLabel&); |
MikamiUitOpen | 0:47718d3154d9 | 60 | NumericLabel& operator=(const NumericLabel&); |
MikamiUitOpen | 0:47718d3154d9 | 61 | }; |
MikamiUitOpen | 0:47718d3154d9 | 62 | } |
MikamiUitOpen | 0:47718d3154d9 | 63 | #endif // F746_NUMERIC_LABEL_HPP |
MikamiUitOpen | 0:47718d3154d9 | 64 |