Cosmetics
This commit is contained in:
parent
e0db62d3f5
commit
6ccdeb6cf0
50
main.c
50
main.c
@ -39,10 +39,10 @@ void count(void)
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
rgbval pattern[6][PATTERN_COUNT]={ {{0,0,0,10}, {0,0,0,10}, {0,0,0,10}, {0,0,0,10}},
|
rgbval pattern[6][PATTERN_COUNT]={ {{0,0,0,10}, {0,0,0,10}, {0,0,0,10}, {0,0,0,10}},
|
||||||
{{1,1,1,10}, {1,1,153,20}, {200,50,39,10}, {204,255,153,20}},
|
{{1,1,1,10}, {1,1,153,20}, {200,50,39,10}, {204,255,153,20}},
|
||||||
{{1,1,1,10}, {10,255,0,10}, {1,1,255,20}, {1,200,1,20}},
|
{{1,1,1,10}, {10,255,0,10}, {1,1,255,20}, {1,200,1,20}},
|
||||||
{{1,1,5,10}, {1,1,255,10}, {1,1,5,10}, {1,1,255,10}},
|
{{1,1,5,10}, {1,1,255,10}, {1,1,5,10}, {1,1,255,10}},
|
||||||
{{252,102,3,10}, {161,67,47,10}, {118,120,74,10}, {83,120,74,20}},
|
{{252,102,3,10}, {161,67,47,10}, {118,120,74,10}, {83,120,74,20}},
|
||||||
{{87,119,122,10}, {95,87,122,10}, {52, 69, 56,10}, {83, 84, 72,10}}};
|
{{87,119,122,10}, {95,87,122,10}, {52, 69, 56,10}, {83, 84, 72,10}}};
|
||||||
int i=0,i2=0,i3;
|
int i=0,i2=0,i3;
|
||||||
@ -51,11 +51,10 @@ int main (void)
|
|||||||
int input=0;
|
int input=0;
|
||||||
uint16_t pre_delay=0;
|
uint16_t pre_delay=0;
|
||||||
ms =0;
|
ms =0;
|
||||||
counts = 0;
|
counts = 0;
|
||||||
|
|
||||||
//disable prescaler
|
//disable prescaler
|
||||||
CLKPR = (1<<CLKPR);
|
CLKPR = (1<<CLKPR);
|
||||||
CLKPR = 0x00;
|
CLKPR = 0x00;
|
||||||
//#######OC0A auf ausgang
|
//#######OC0A auf ausgang
|
||||||
DDRB = (1 << PB0 )|(1<<PB1)|(1<<PB4);
|
DDRB = (1 << PB0 )|(1<<PB1)|(1<<PB4);
|
||||||
cli();
|
cli();
|
||||||
@ -92,10 +91,10 @@ int main (void)
|
|||||||
//reset timer counter
|
//reset timer counter
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
//input handling
|
//input handling
|
||||||
input=PINB;
|
input=PINB;
|
||||||
if(((input & (1<<PB2)) == 0 && set==0))
|
if(((input & (1<<PB2)) == 0 && set==0))
|
||||||
{
|
{
|
||||||
set=1;
|
set=1;
|
||||||
i=0;
|
i=0;
|
||||||
i2++;
|
i2++;
|
||||||
@ -104,7 +103,6 @@ int main (void)
|
|||||||
i2=0;
|
i2=0;
|
||||||
}
|
}
|
||||||
//cycle through and stop pwm at value 0
|
//cycle through and stop pwm at value 0
|
||||||
|
|
||||||
//Visual feedback "mode change"
|
//Visual feedback "mode change"
|
||||||
for(i3=0;i3<i2;i3++)
|
for(i3=0;i3<i2;i3++)
|
||||||
{
|
{
|
||||||
@ -113,26 +111,26 @@ int main (void)
|
|||||||
OCR0A=255;OCR0B=255;OCR1B=255;
|
OCR0A=255;OCR0B=255;OCR1B=255;
|
||||||
_delay_ms(30);
|
_delay_ms(30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(((input & (1<<PB2)) != 0))
|
else if(((input & (1<<PB2)) != 0))
|
||||||
{
|
{
|
||||||
set=0;
|
set=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
//Pattern handling
|
//Pattern handling
|
||||||
if(r < pattern[i2][i+1].r) {r++;}
|
if(r < pattern[i2][i+1].r) {r++;}
|
||||||
if(r > pattern[i2][i+1].r) {r--;}
|
if(r > pattern[i2][i+1].r) {r--;}
|
||||||
if(g < pattern[i2][i+1].g) {g++;}
|
if(g < pattern[i2][i+1].g) {g++;}
|
||||||
if(g > pattern[i2][i+1].g) {g--;}
|
if(g > pattern[i2][i+1].g) {g--;}
|
||||||
if(b < pattern[i2][i+1].b) {b++;}
|
if(b < pattern[i2][i+1].b) {b++;}
|
||||||
if(b > pattern[i2][i+1].b) {b--;}
|
if(b > pattern[i2][i+1].b) {b--;}
|
||||||
OCR0A = g;//green
|
OCR0A = g;//green
|
||||||
OCR0B = r;//red
|
OCR0B = r;//red
|
||||||
OCR1B = b;//blue
|
OCR1B = b;//blue
|
||||||
// _delay_ms(10);
|
// _delay_ms(10);
|
||||||
pre_delay = ms;
|
pre_delay = ms;
|
||||||
while((ms-pre_delay) < pattern[i2][i+1].time_hold){};
|
while((ms-pre_delay) < pattern[i2][i+1].time_hold){};
|
||||||
if(r == pattern[i2][i+1].r && g == pattern[i2][i+1].g && b == pattern[i2][i+1].b) break;
|
if(r == pattern[i2][i+1].r && g == pattern[i2][i+1].g && b == pattern[i2][i+1].b) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user