optimization
This commit is contained in:
13
main.c
13
main.c
@@ -1,3 +1,4 @@
|
||||
#include<math.h>
|
||||
#include<util/delay.h>
|
||||
#include<avr/io.h>
|
||||
#include"fix_fft.h"
|
||||
@@ -7,6 +8,7 @@
|
||||
#include"main.h"
|
||||
|
||||
#define STARTADC ADCSRA |= (1<<ADSC)
|
||||
#define WAITADC ADCSRA & (1<<ADSC)
|
||||
#define PB_mic PB0
|
||||
#define NOISE 100
|
||||
#define SCALE_FACTOR 10
|
||||
@@ -38,9 +40,9 @@ int main (void)
|
||||
int colorb;
|
||||
int colora;
|
||||
int sum,avg;
|
||||
char sample[64];
|
||||
char im[64];
|
||||
char buff[64];
|
||||
static char sample[64];
|
||||
static char im[64];
|
||||
static char buff[64];
|
||||
char temp;
|
||||
msec=0;
|
||||
struct cRGB led_bar1[8];
|
||||
@@ -69,6 +71,7 @@ int main (void)
|
||||
{
|
||||
msec=0;
|
||||
STARTADC;
|
||||
WAITADC;//as adc is slower than cpu
|
||||
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
|
||||
@@ -121,14 +124,16 @@ int main (void)
|
||||
led_bar1[i].b=sample[i]/2;
|
||||
}
|
||||
}
|
||||
cli();//disable interupts to prevent intereference
|
||||
ws2812_setleds(led_bar1,8);
|
||||
sei();//reenable interupts
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int map(int value, int old_min, int old_max,int new_min, int new_max)
|
||||
{
|
||||
return (new_max/old_max*value);
|
||||
return (value - old_min) * (new_max - new_min) / (old_max - old_min) + new_min;
|
||||
}
|
||||
|
||||
void setupTimer(void)
|
||||
|
||||
Reference in New Issue
Block a user