batteriehalter finetuning

This commit is contained in:
Alexander Alber 2023-06-26 23:20:20 +02:00
parent 7e2a287786
commit 2f6da3c531
6 changed files with 51 additions and 51 deletions

View File

@ -6,7 +6,7 @@
#include "zauberstab.h" #include "zauberstab.h"
#undef NUM_LEDS #undef NUM_LEDS
#define NUM_LEDS 48 #define NUM_LEDS 46
#define SAMPLING_FREQUENCY_BP 40 // number of energy chunks per second #define SAMPLING_FREQUENCY_BP 40 // number of energy chunks per second
#define SAMPLING_FREQUENCY_CONTROL \ #define SAMPLING_FREQUENCY_CONTROL \
@ -37,12 +37,6 @@ static float y_fil[n_BP];
static float angle; static float angle;
static float angle_pre = 0.1; static float angle_pre = 0.1;
//static float angle2;
// static double energy_fil = 800.;
//static float pos_target = NUM_LEDS / 2;
//static float pos_target_filtered = NUM_LEDS / 2;
static long initial_time; static long initial_time;
static int active = 15; static int active = 15;
@ -59,6 +53,7 @@ static int quarter_color_v = 50;
//modus 0: farbverlauf, farben wechseln alle 4 beats //modus 0: farbverlauf, farben wechseln alle 4 beats
//modus 1: konstante farbe, wechselt bei jedem beat //modus 1: konstante farbe, wechselt bei jedem beat
//modus 2: weiß, zählt binärzahlen hoch
static int modus = 0; static int modus = 0;
static int modus_count = 0; static int modus_count = 0;
@ -68,7 +63,21 @@ static int get_value(int pos, int quarter, int beat_count, char component)
{ {
if (modus == 2) if (modus == 3)
{
if (component == 'h'){return 255;}
if (component == 's'){return 0;}
if (component == 'v')
{
if ((quarter+pos)%2==0)
{return 50;}
else
{return 0;}
}
}
else if (modus == 2)
{ {
if (component == 'h'){return 255;} if (component == 'h'){return 255;}
if (component == 's'){return 0;} if (component == 's'){return 0;}
@ -132,25 +141,18 @@ static int get_value(int pos, int quarter, int beat_count, char component)
else if (pos < NUM_LEDS/2) {return s2*v;} else if (pos < NUM_LEDS/2) {return s2*v;}
else if (pos < 3*NUM_LEDS/4) {return s3*v;} else if (pos < 3*NUM_LEDS/4) {return s3*v;}
else {return s4*v;} else {return s4*v;}
}
} }
} else if (pos < NUM_LEDS*quarter/3)
if (pos < NUM_LEDS*quarter/3)
{ {
if (component == 'h') if (component == 'h')
{ {
if (modus == 0) if (modus == 0)
{ {
int color = quarter_color_h1 + 50*pos/NUM_LEDS; int color = quarter_color_h1 + 50*pos/NUM_LEDS;
return color%255; return color%255;
} }
return quarter_color_h1; return quarter_color_h1;
@ -263,23 +265,28 @@ void QuarterApp::loop()
//every beat //every beat
if (angle > 0 and angle_pre <= 0) if (angle > 0 and angle_pre <= 0)
{ {
quarter = beat_count%4;
//mode 0 logic if active
if (modus == 0 & quarter == 0)
{
quarter_color_h1 += 10;
quarter_color_h1 = quarter_color_h1%255;
}
//mode 1 logic if active //mode 1 logic if active
if (modus == 1) else if (modus == 1)
{ {
quarter_color_h1 += 15; quarter_color_h1 += 15;
quarter_color_h1 = quarter_color_h1%255; quarter_color_h1 = quarter_color_h1%255;
quarter_color_s = 255; quarter_color_s = 255;
} }
quarter = beat_count%4;
//every 4 beats //every 4 beats
if (quarter == 0) else if (quarter == 0 & modus == 2)
{
//mode 2 logic if active
if (modus == 2)
{ {
quarter_color_s = 0; quarter_color_s = 0;
} }
@ -288,16 +295,6 @@ void QuarterApp::loop()
quarter_color_s = 255; quarter_color_s = 255;
} }
//mode 0 logic if active
if (modus == 0)
{
quarter_color_h1 += 10;
quarter_color_h1 = quarter_color_h1%255;
}
}
// state machine // state machine
beat_count++; beat_count++;
if (beat_count > 15) if (beat_count > 15)
@ -305,11 +302,11 @@ void QuarterApp::loop()
beat_count = 0; beat_count = 0;
modus_count++; modus_count++;
if (modus_count > 3) if (modus_count > 7)
{ {
modus_count = 0; modus_count = 0;
modus++; modus++;
if (modus > 2) if (modus > 3)
{ {
modus = 0; modus = 0;
} }
@ -319,6 +316,9 @@ void QuarterApp::loop()
} }
}
for (int i = 0; i < NUM_LEDS; i++) for (int i = 0; i < NUM_LEDS; i++)
{ {
@ -330,7 +330,6 @@ void QuarterApp::loop()
} }
FastLED.show(); FastLED.show();
}
angle_pre = angle; angle_pre = angle;
energy = 0; energy = 0;

View File

@ -6,6 +6,7 @@
struct BeatDetectApp beat_detect_app struct BeatDetectApp beat_detect_app
{ {
}; };
struct QuarterApp quarter_app struct QuarterApp quarter_app
{ {
}; };

Binary file not shown.

Binary file not shown.