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: BSP_DISCO_F746NG F746_GUI F746_SAI_IO LCD_DISCO_F746NG TS_DISCO_F746NG mbed
Trigger.hpp
00001 //--------------------------------------------------------------- 00002 // トリガの条件を満足したデータを表示用データ領域の先頭から順に転送する 00003 // トリガ条件は左右両チャンネルでチェックし,先に条件を 00004 // 満足した点をトリガポイントとする 00005 // 00006 // 2016/07/23, Copyright (c) 2016 MIKAMI, Naoki 00007 //--------------------------------------------------------------- 00008 00009 #ifndef F746_TRIGGER_HPP 00010 #define F746_TRIGGER_HPP 00011 00012 #include "mbed.h" 00013 #include "Array.hpp" 00014 #include <algorithm> // min(), max() で使う 00015 00016 namespace Mikami 00017 { 00018 class Trigger 00019 { 00020 public: 00021 Trigger(const Array<int16_t>& snL, // 元のデータ,左チャンネル 00022 const Array<int16_t>& snR, // 元のデータ,右チャンネル 00023 Array<int16_t>& xnL, // 表示用データ,左チャンネル 00024 Array<int16_t>& xnR, // 表示用データ,右チャンネル 00025 int threshold ) // トリガの基準値 00026 : snL_(snL), snR_(snR), xnL_(xnL), xnR_(xnR), 00027 TH_(threshold), N_SEARCH_(snL.Length()/3) {} 00028 00029 bool Execute() 00030 { 00031 int nL = Search(snL_); 00032 int nR = Search(snR_); 00033 int nStart = min(nL, nR); 00034 00035 for (int n=0; n<xnL_.Length(); n++) 00036 { 00037 int nS = n + nStart; 00038 xnL_[n] = snL_[nS]; 00039 xnR_[n] = snR_[nS]; 00040 } 00041 00042 return nStart < N_SEARCH_; 00043 } 00044 00045 private: 00046 const Array<int16_t> &snL_, &snR_; 00047 Array<int16_t> &xnL_, &xnR_; 00048 const int TH_; 00049 const int N_SEARCH_; 00050 00051 int Search(const Array<int16_t>& un) 00052 { 00053 int n; 00054 for (n=1; n<N_SEARCH_; n++) 00055 if ((un[n-1] < -TH_) && (un[n] > TH_)) 00056 break; 00057 return n; 00058 } 00059 }; 00060 } 00061 #endif // F746_TRIGGER_HPP
Generated on Fri Jul 22 2022 14:41:57 by
1.7.2