Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Array_Matrix TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
DelayedEnabler.hpp
00001 //----------------------------------------------------------- 00002 // ある機能を一定の時間が経過するまでは無効にし,その後有効に 00003 // するためのクラス 00004 // 00005 // 2018/03/12, Copyright (c) 2018 MIKAMI, Naoki 00006 //----------------------------------------------------------- 00007 00008 #ifndef DELAYED_ENABLER_HPP 00009 #define DELAYED_ENABLER_HPP 00010 00011 #include "mbed.h" 00012 00013 namespace Mikami 00014 { 00015 class DelayedEnabler 00016 { 00017 public: 00018 DelayedEnabler(float delayTime = 0.3f) 00019 : DELAY_TIME_(delayTime), enable_(true) {} 00020 00021 // このメンバ関数の実行直後から指定された時間,IsEnabled() は false を 00022 // 返し,その後 InEnabled() は true を返す 00023 void Disable() 00024 { 00025 enable_ = false; 00026 Enabler_.attach(callback(this, &DelayedEnabler::TimeoutIsr), 00027 DELAY_TIME_); 00028 } 00029 00030 bool IsEnabled() { return enable_; } 00031 00032 private: 00033 const float DELAY_TIME_; // 無効になっている時間 00034 00035 __IO bool enable_; 00036 Timeout Enabler_; 00037 00038 // 有効にする(Timeout 割り込みに対応する ISR) 00039 void TimeoutIsr() { enable_ = true; } 00040 00041 // disallow copy constructor and assignment operator 00042 DelayedEnabler(const DelayedEnabler&); 00043 DelayedEnabler& operator=(const DelayedEnabler&); 00044 }; 00045 } 00046 #endif // DELAYED_ENABLER_HPP
Generated on Thu Jul 14 2022 07:59:59 by
1.7.2