working goood
This commit is contained in:
parent
d85647358b
commit
2e5be064bf
26
main.c
26
main.c
@ -52,11 +52,11 @@ int main (void)
|
|||||||
//int colora;
|
//int colora;
|
||||||
int sum,avg;
|
int sum,avg;
|
||||||
char sample[64];
|
char sample[64];
|
||||||
char im[64];
|
//char im[64];
|
||||||
char buff[64];
|
char buff[64];
|
||||||
|
|
||||||
float fac_r=0;
|
float fac_r=0.1;
|
||||||
float fac_g=0.5;
|
float fac_g=0.1;
|
||||||
float fac_b=1;
|
float fac_b=1;
|
||||||
msec=0;
|
msec=0;
|
||||||
struct cRGB led_bar1[8];
|
struct cRGB led_bar1[8];
|
||||||
@ -87,7 +87,7 @@ int main (void)
|
|||||||
STARTADC;
|
STARTADC;
|
||||||
sample[i] = (ADCH-128); //read Analog value register 8bit center -128
|
sample[i] = (ADCH-128); //read Analog value register 8bit center -128
|
||||||
//sample[i] = (sample[i] <= NOISE) ? 0 : (sample[i] - NOISE); //noise reduction
|
//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
|
sum+=sample[i];//dc-bias
|
||||||
|
|
||||||
@ -126,15 +126,16 @@ int main (void)
|
|||||||
}
|
}
|
||||||
else if(sample[i]<30)
|
else if(sample[i]<30)
|
||||||
{
|
{
|
||||||
led_bar1[i].r=0;
|
led_bar1[i].r=(char)sample[i]*fac_r*2;
|
||||||
led_bar1[i].g=sample[i];
|
led_bar1[i].g=(char)sample[i]*fac_g/2;
|
||||||
led_bar1[i].b=sample[i]/2;
|
led_bar1[i].b=(char)sample[i]*fac_b/2;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(sample[i]<50)
|
else if(sample[i]<50)
|
||||||
{
|
{
|
||||||
led_bar1[i].r=sample[i];
|
led_bar1[i].r=(char)sample[i]*fac_r*2;
|
||||||
led_bar1[i].g=0;
|
led_bar1[i].g=(char)sample[i]*fac_g*2;
|
||||||
led_bar1[i].b=sample[i]/2;
|
led_bar1[i].b=(char)sample[i]*fac_b*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws2812_setleds(led_bar1,8);
|
ws2812_setleds(led_bar1,8);
|
||||||
@ -142,10 +143,7 @@ int main (void)
|
|||||||
return 0;
|
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)
|
void setupTimer(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user