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() {
|
2022-06-18 23:03:19 +02:00
|
|
|
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
|
|
|
|
//FastLED.setMaxPowerInVoltsAndMilliamps(5, 300);
|
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() {
|
2022-06-18 23:03:19 +02:00
|
|
|
float sample = read_mic();
|
|
|
|
sample = dc_cancelation_update(&dc_blocker, sample);
|
|
|
|
return sample;
|
2022-06-17 03:31:17 +02:00
|
|
|
}
|