Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09015cad97 | ||
|
|
11836cb058 | ||
|
|
2ecdc9a788 | ||
| b274fece85 | |||
| 91e1fa894b |
2
dev-files/60-avr-uspasp.rules
Normal file
2
dev-files/60-avr-uspasp.rules
Normal file
@@ -0,0 +1,2 @@
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc",
|
||||
GROUP="uucp", MODE="0666"
|
||||
3
dev-files/99-avrprogrammer.rules
Normal file
3
dev-files/99-avrprogrammer.rules
Normal file
@@ -0,0 +1,3 @@
|
||||
# Set group for a programmer matching with vendor and product IDs
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", GROUP="uucp", MODE="0666"
|
||||
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
6
dev-install.sh
Normal file
6
dev-install.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
sudo cp ./dev-files/* /etc/udev/rules.d/
|
||||
sudo udevadm control --reload
|
||||
sudo usermod ccppi -aG uucp
|
||||
newgrp uucp
|
||||
|
||||
sudo pacman -S avr-gcc avr-libc avrdude micronucleus
|
||||
16
main.c
16
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
|
||||
@@ -29,7 +31,6 @@
|
||||
//7- 880
|
||||
//8- 1kHz
|
||||
//
|
||||
const float log_scale = 64./log(64./SCALE_FACTOR + 1.);
|
||||
|
||||
int msec;
|
||||
int main (void)
|
||||
@@ -38,9 +39,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 +70,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
|
||||
@@ -90,7 +92,7 @@ int main (void)
|
||||
if(sample[i]<0) sample[i] = 0;
|
||||
if(sample[i]>64) sample[i]=64;
|
||||
sample[i] = sample[i] *SCALE_FACTOR;
|
||||
sample[i] = (sample[i]*0.7 + buff[i]*0.3);
|
||||
sample[i] = (sample[i]*7 + buff[i]*3)/10;
|
||||
buff[i] = sample[i];
|
||||
|
||||
}
|
||||
@@ -121,14 +123,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)
|
||||
|
||||
3
main.h
Normal file
3
main.h
Normal file
@@ -0,0 +1,3 @@
|
||||
void wait_period(void);
|
||||
int map(int value, int old_min, int old_max,int new_min, int new_max);
|
||||
void setupTimer(void);
|
||||
6
makefile
6
makefile
@@ -142,7 +142,11 @@ sym: $(TARGET).sym
|
||||
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
#for normal attiny85 or with usbasp
|
||||
#$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
#this is for digispark attiny85 with micronucleus bootloader on it
|
||||
micronucleus --run $(TARGET).hex
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user