-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e879be0
commit 526b353
Showing
9 changed files
with
102 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//buildconfig.h 由 cmake 从 buildconfig.h.in 自动生成 | ||
#pragma once | ||
#define LversionStr L"0.1.2" | ||
#define versionStr "0.1.2" | ||
#define LversionStr L"0.1.3" | ||
#define versionStr "0.1.3" | ||
constexpr int DEFAULT_KEY_THRESHOLD = 6; | ||
constexpr int DEFAULT_LOG_LEVEL = 4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <deque> | ||
#include <algorithm> | ||
#include <numeric> | ||
|
||
template<int BUFFER_SIZE> | ||
class PulseDetector{ | ||
private: | ||
//触发状态, 防止连续触发 | ||
bool triggered = false; | ||
bool pulse = false; | ||
|
||
float threshold = 0.0f; | ||
float last_sample = 0; | ||
|
||
public: | ||
PulseDetector(float threshold_){ | ||
threshold = threshold_; | ||
} | ||
~PulseDetector(){}; | ||
void addSample(float sample){ | ||
float delta = -(sample - last_sample); | ||
last_sample = sample; | ||
if(delta > threshold){ | ||
if(!triggered){ | ||
triggered = true; | ||
} | ||
return; | ||
} | ||
//复位 | ||
if(delta < 0){ | ||
if(triggered){ | ||
triggered = false; | ||
pulse = true; | ||
} | ||
return; | ||
} | ||
|
||
} | ||
|
||
bool havePulse(){ | ||
if(pulse){ | ||
pulse = false; | ||
return true; | ||
} | ||
return false; | ||
} | ||
void reset(){ | ||
} | ||
}; |