Skip to content
Snippets Groups Projects
Commit 8f488267 authored by schneider's avatar schneider
Browse files

Merge branch 'electrodes' into 'master'

electrodes unfiltered

See merge request card10/firmware!347
parents 3cc52e92 b3d6d203
No related branches found
No related tags found
No related merge requests found
...@@ -51,19 +51,25 @@ last_sample_count = 1 ...@@ -51,19 +51,25 @@ last_sample_count = 1
leds.dim_top(1) leds.dim_top(1)
COLORS = [((23 + (15 * i)) % 360, 1.0, 1.0) for i in range(11)] COLORS = [((23 + (15 * i)) % 360, 1.0, 1.0) for i in range(11)]
# variables for high-pass filter # variables for high-pass filter
# note: corresponds to 1st order hpf with -3dB at ~18.7Hz
# general formula: f(-3dB)=-(sample_rate/tau)*ln(1-betadash)
moving_average = 0 moving_average = 0
alpha = 2 alpha = 2
beta = 3 beta = 3
betadash = beta / (alpha + beta)
def update_history(datasets): def update_history(datasets):
global history, moving_average, alpha, beta, last_sample_count global history, moving_average, alpha, beta, last_sample_count
last_sample_count = len(datasets) last_sample_count = len(datasets)
for val in datasets: for val in datasets:
history.append(val - moving_average) if current_mode == MODE_FINGER:
moving_average = (alpha * moving_average + beta * val) / (alpha + beta) history.append(val - moving_average)
moving_average += betadash * (val - moving_average)
# identical to: moving_average = (alpha * moving_average + beta * val) / (alpha + beta)
else:
history.append(val)
# trim old elements # trim old elements
history = history[-HISTORY_MAX:] history = history[-HISTORY_MAX:]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment