working goood

This commit is contained in:
Jonathan Wyss 2024-03-26 17:51:20 +01:00
parent d85647358b
commit 2e5be064bf

26
main.c
View File

@ -52,11 +52,11 @@ int main (void)
//int colora;
int sum,avg;
char sample[64];
char im[64];
//char im[64];
char buff[64];
float fac_r=0;
float fac_g=0.5;
float fac_r=0.1;
float fac_g=0.1;
float fac_b=1;
msec=0;
struct cRGB led_bar1[8];
@ -87,7 +87,7 @@ int main (void)
STARTADC;
sample[i] = (ADCH-128); //read Analog value register 8bit center -128
//sample[i] = (sample[i] <= NOISE) ? 0 : (sample[i] - NOISE); //noise reduction
im[i]=0; //pseudo data for funciton
//im[i]=0; //pseudo data for funciton
//
sum+=sample[i];//dc-bias
@ -126,15 +126,16 @@ int main (void)
}
else if(sample[i]<30)
{
led_bar1[i].r=0;
led_bar1[i].g=sample[i];
led_bar1[i].b=sample[i]/2;
led_bar1[i].r=(char)sample[i]*fac_r*2;
led_bar1[i].g=(char)sample[i]*fac_g/2;
led_bar1[i].b=(char)sample[i]*fac_b/2;
}
else if(sample[i]<50)
{
led_bar1[i].r=sample[i];
led_bar1[i].g=0;
led_bar1[i].b=sample[i]/2;
led_bar1[i].r=(char)sample[i]*fac_r*2;
led_bar1[i].g=(char)sample[i]*fac_g*2;
led_bar1[i].b=(char)sample[i]*fac_b*2;
}
}
ws2812_setleds(led_bar1,8);
@ -142,10 +143,7 @@ int main (void)
return 0;
}
int map(int value, int old_min, int old_max,int new_min, int new_max)
{
return (new_max/old_max*value);
}
void setupTimer(void)
{