todo: reduce magic constants
This commit is contained in:
parent
abd85cf8dc
commit
717e36a7a4
|
@ -190,17 +190,18 @@ void processLastKnockEvent() {
|
||||||
|
|
||||||
float sumSq = 0;
|
float sumSq = 0;
|
||||||
|
|
||||||
|
// todo: reduce magic constants. engineConfiguration->adcVcc?
|
||||||
constexpr float ratio = 3.3f / 4095.0f;
|
constexpr float ratio = 3.3f / 4095.0f;
|
||||||
|
|
||||||
size_t localCount = sampleCount;
|
size_t localCount = sampleCount;
|
||||||
|
|
||||||
// Prepare the steady state at vcc/2 so that there isn't a step
|
// Prepare the steady state at vcc/2 so that there isn't a step
|
||||||
// when samples begin
|
// when samples begin
|
||||||
|
// todo: reduce magic constants. engineConfiguration->adcVcc?
|
||||||
knockFilter.cookSteadyState(3.3f / 2);
|
knockFilter.cookSteadyState(3.3f / 2);
|
||||||
|
|
||||||
// Compute the sum of squares
|
// Compute the sum of squares
|
||||||
for (size_t i = 0; i < localCount; i++)
|
for (size_t i = 0; i < localCount; i++) {
|
||||||
{
|
|
||||||
float volts = ratio * sampleBuffer[i];
|
float volts = ratio * sampleBuffer[i];
|
||||||
|
|
||||||
float filtered = knockFilter.filter(volts);
|
float filtered = knockFilter.filter(volts);
|
||||||
|
@ -221,7 +222,7 @@ void processLastKnockEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void KnockThread::ThreadTask() {
|
void KnockThread::ThreadTask() {
|
||||||
while(1) {
|
while (1) {
|
||||||
chBSemWait(&knockSem);
|
chBSemWait(&knockSem);
|
||||||
|
|
||||||
ScopePerf perf(PE::SoftwareKnockProcess);
|
ScopePerf perf(PE::SoftwareKnockProcess);
|
||||||
|
|
Loading…
Reference in New Issue