2022-06-17 03:31:17 +02:00
|
|
|
#include "zauberstab.h"
|
2022-06-18 11:16:07 +02:00
|
|
|
#include "dc_cancelation.h"
|
2022-06-17 03:31:17 +02:00
|
|
|
|
2022-06-18 11:16:07 +02:00
|
|
|
struct dc_cancelation_state dc_blocker;
|
2022-06-17 03:31:17 +02:00
|
|
|
CRGB leds[NUM_LEDS];
|
|
|
|
static int16_t mic_offset = 0;
|
|
|
|
|
|
|
|
static uint16_t read_mic() {
|
|
|
|
return analogRead(MIC_PIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
int zauberstab_init() {
|
|
|
|
FastLED.addLeds<WS2812, LED_PIN, RGB>(leds, NUM_LEDS);
|
2022-06-18 11:16:07 +02:00
|
|
|
dc_cancelation_init(&dc_blocker, 0.95);
|
2022-06-17 03:31:17 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-18 11:16:07 +02:00
|
|
|
float get_sample() {
|
|
|
|
int32_t raw_sample = read_mic();
|
|
|
|
return dc_cancelation_update(&dc_blocker, (float) raw_sample);
|
2022-06-17 03:31:17 +02:00
|
|
|
}
|