![](/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
MyFiles/DelayedEnabler.hpp@2:aa11055138a2, 2017-11-08 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Wed Nov 08 11:10:56 2017 +0000
- Revision:
- 2:aa11055138a2
- Parent:
- 0:47718d3154d9
3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:47718d3154d9 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 2 | // ある機能を一定の時間が経過するまでは無効にし,その後有効に |
MikamiUitOpen | 0:47718d3154d9 | 3 | // するためのクラス |
MikamiUitOpen | 0:47718d3154d9 | 4 | // |
MikamiUitOpen | 0:47718d3154d9 | 5 | // 2017/08/21, Copyright (c) 2017 MIKAMI, Naoki |
MikamiUitOpen | 0:47718d3154d9 | 6 | //----------------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 7 | |
MikamiUitOpen | 0:47718d3154d9 | 8 | #ifndef DELAYED_ENABLER_HPP |
MikamiUitOpen | 0:47718d3154d9 | 9 | #define DELAYED_ENABLER_HPP |
MikamiUitOpen | 0:47718d3154d9 | 10 | |
MikamiUitOpen | 0:47718d3154d9 | 11 | #include "mbed.h" |
MikamiUitOpen | 0:47718d3154d9 | 12 | |
MikamiUitOpen | 0:47718d3154d9 | 13 | namespace Mikami |
MikamiUitOpen | 0:47718d3154d9 | 14 | { |
MikamiUitOpen | 0:47718d3154d9 | 15 | class DelayedEnabler |
MikamiUitOpen | 0:47718d3154d9 | 16 | { |
MikamiUitOpen | 0:47718d3154d9 | 17 | public: |
MikamiUitOpen | 0:47718d3154d9 | 18 | DelayedEnabler(float delayTime = 0.3f) |
MikamiUitOpen | 0:47718d3154d9 | 19 | : DELAY_TIME_(delayTime), enable_(true) {} |
MikamiUitOpen | 0:47718d3154d9 | 20 | |
MikamiUitOpen | 0:47718d3154d9 | 21 | // このメンバ関数の実行直後から指定された時間,IsEnabled() は false を |
MikamiUitOpen | 0:47718d3154d9 | 22 | // 返し,その後 InEnabled() は true を返す |
MikamiUitOpen | 0:47718d3154d9 | 23 | void Disable() |
MikamiUitOpen | 0:47718d3154d9 | 24 | { |
MikamiUitOpen | 0:47718d3154d9 | 25 | enable_ = false; |
MikamiUitOpen | 0:47718d3154d9 | 26 | Enabler_.attach(callback(this, &DelayedEnabler::TimeoutIsr), |
MikamiUitOpen | 0:47718d3154d9 | 27 | DELAY_TIME_); |
MikamiUitOpen | 0:47718d3154d9 | 28 | } |
MikamiUitOpen | 0:47718d3154d9 | 29 | |
MikamiUitOpen | 0:47718d3154d9 | 30 | bool IsEnabled() { return enable_; } |
MikamiUitOpen | 0:47718d3154d9 | 31 | |
MikamiUitOpen | 0:47718d3154d9 | 32 | private: |
MikamiUitOpen | 0:47718d3154d9 | 33 | const float DELAY_TIME_; // 無効になっている時間 |
MikamiUitOpen | 0:47718d3154d9 | 34 | |
MikamiUitOpen | 0:47718d3154d9 | 35 | __IO bool enable_; |
MikamiUitOpen | 0:47718d3154d9 | 36 | Timeout Enabler_; |
MikamiUitOpen | 0:47718d3154d9 | 37 | |
MikamiUitOpen | 0:47718d3154d9 | 38 | // 有効にする(Timeout 割り込みに対応する ISR) |
MikamiUitOpen | 0:47718d3154d9 | 39 | void TimeoutIsr() { enable_ = true; } |
MikamiUitOpen | 0:47718d3154d9 | 40 | }; |
MikamiUitOpen | 0:47718d3154d9 | 41 | } |
MikamiUitOpen | 0:47718d3154d9 | 42 | #endif // DELAYED_ENABLER_HPP |