todo: reduce magic constants

This commit is contained in:
rusefillc 2021-01-14 22:34:06 -05:00
parent abd85cf8dc
commit 717e36a7a4
1 changed files with 4 additions and 3 deletions

View File

@ -190,17 +190,18 @@ void processLastKnockEvent() {
float sumSq = 0;
// todo: reduce magic constants. engineConfiguration->adcVcc?
constexpr float ratio = 3.3f / 4095.0f;
size_t localCount = sampleCount;
// Prepare the steady state at vcc/2 so that there isn't a step
// when samples begin
// todo: reduce magic constants. engineConfiguration->adcVcc?
knockFilter.cookSteadyState(3.3f / 2);
// 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 filtered = knockFilter.filter(volts);
@ -221,7 +222,7 @@ void processLastKnockEvent() {
}
void KnockThread::ThreadTask() {
while(1) {
while (1) {
chBSemWait(&knockSem);
ScopePerf perf(PE::SoftwareKnockProcess);