Cosmetics

This commit is contained in:
ccppi 2024-03-14 21:25:20 +00:00
parent e0db62d3f5
commit 6ccdeb6cf0

48
main.c
View File

@ -39,10 +39,10 @@ void count(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}, {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,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}},
{{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}}};
int i=0,i2=0,i3;
@ -52,10 +52,9 @@ int main (void)
uint16_t pre_delay=0;
ms =0;
counts = 0;
//disable prescaler
CLKPR = (1<<CLKPR);
CLKPR = 0x00;
CLKPR = 0x00;
//#######OC0A auf ausgang
DDRB = (1 << PB0 )|(1<<PB1)|(1<<PB4);
cli();
@ -92,10 +91,10 @@ int main (void)
//reset timer counter
while(1)
{
//input handling
input=PINB;
//input handling
input=PINB;
if(((input & (1<<PB2)) == 0 && set==0))
{
{
set=1;
i=0;
i2++;
@ -104,7 +103,6 @@ int main (void)
i2=0;
}
//cycle through and stop pwm at value 0
//Visual feedback "mode change"
for(i3=0;i3<i2;i3++)
{
@ -113,26 +111,26 @@ int main (void)
OCR0A=255;OCR0B=255;OCR1B=255;
_delay_ms(30);
}
}
}
else if(((input & (1<<PB2)) != 0))
{
set=0;
}
//Pattern handling
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(b < pattern[i2][i+1].b) {b++;}
if(b > pattern[i2][i+1].b) {b--;}
OCR0A = g;//green
OCR0B = r;//red
OCR1B = b;//blue
// _delay_ms(10);
pre_delay = ms;
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;
}
//Pattern handling
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(b < pattern[i2][i+1].b) {b++;}
if(b > pattern[i2][i+1].b) {b--;}
OCR0A = g;//green
OCR0B = r;//red
OCR1B = b;//blue
// _delay_ms(10);
pre_delay = ms;
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;
}
}
}