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-19 12:17:21 +02:00
|
|
|
DcCancelation<float> dc_blocker{0.95};
|
2022-06-17 03:31:17 +02:00
|
|
|
CRGB leds[NUM_LEDS];
|
|
|
|
static int16_t mic_offset = 0;
|
|
|
|
|
2022-06-19 13:05:58 +02:00
|
|
|
static uint16_t read_mic()
|
|
|
|
{
|
2022-06-17 03:31:17 +02:00
|
|
|
return analogRead(MIC_PIN);
|
|
|
|
}
|
|
|
|
|
2022-06-19 13:05:58 +02:00
|
|
|
int zauberstab_init()
|
|
|
|
{
|
2022-06-18 23:03:19 +02:00
|
|
|
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
|
2022-06-19 13:05:58 +02:00
|
|
|
// FastLED.setMaxPowerInVoltsAndMilliamps(5, 300);
|
2022-06-17 03:31:17 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-19 13:05:58 +02:00
|
|
|
float get_sample()
|
|
|
|
{
|
2022-06-18 23:03:19 +02:00
|
|
|
float sample = read_mic();
|
2022-06-19 12:17:21 +02:00
|
|
|
sample = dc_blocker.update(sample);
|
2022-06-18 23:03:19 +02:00
|
|
|
return sample;
|
2022-06-17 03:31:17 +02:00
|
|
|
}
|