Hey folks, I am working on an attiny84 bike light, it's main feature is a cylon light fade chase. I found some code from atmel and adapted it, and I'm having a few issues I hope you can shed some light on.
The project is here:
https://github.com/blark/leetbike/blob/master/cylon.c
Here are my issues:
1. If i delete one of my variables (char wtf) the program stops working! it's the most bizarre thing ever -- everything works great when the variable is there. Even if I change it's name, it still works fine. Any ideas? I'm totally stumped! I've tried compiling on Linux and in Windows using Atmel Studio. At no point is this char used in the program... completely weird.
2. The software pwm used a volatile array hold pwm values and then one by one copied the values in to the compare array. I have switched that to a memcpy, and it seems to work fine, am I doing something stupid here?
Old code:
compare[0] = compbuff[0]; // verbose code for speed compare[1] = compbuff[1]; compare[2] = compbuff[2]; compare[3] = compbuff[3]; compare[4] = compbuff[4]; ...
New code:
memcpy(compare, led_bright, CHMAX*sizeof(int));
3. Is there any way to cut down on the repetitive #defines, say like a for loop or something? Also if I want to alter the number of channels it would be much easier if I did this.
#define LED0 PA0 // assign LED names to output ports on the attiny84 #define LED1 PA1 #define LED2 PA2 #define LED3 PA3 #define LED4 PA4 #define LED5 PA5 #define LED6 PA6
Sorry for being such a n00b, I'd REALLY appreciate your help though!
Thanks