Browse Source

use helper functions

master
Olaf Rempel 8 years ago
parent
commit
d2e2bb1695
1 changed files with 16 additions and 17 deletions
  1. +16
    -17
      main.c

+ 16
- 17
main.c View File

@@ -130,13 +130,20 @@ void color_div(uint8_t *color, uint8_t div, uint8_t *output)
{
uint8_t i;
for (i = 0; i < 3; i++) {
output[i] = color[i] / div;
if ((output[i] == 0) && (color[i] != 0)) {
output[i] = 0x01;
if (color[i] != 0) {
output[i] = color[i] / div;
if (output[i] == 0) {
output[i] = 0x01;
}

} else {
output[i] = 0x00;
}
}
}

static uint8_t chan_decay[16][3];

int main(void) __attribute__ ((noreturn));
int main(void)
{
@@ -152,7 +159,6 @@ int main(void)
uint8_t x = 0;
uint8_t xdir = 1;
uint16_t ramp = 0;
uint8_t step = 0;

/* wait for complete update */
rgb_update(COLOR_MASK, 1);
@@ -163,24 +169,17 @@ int main(void)
/* wait for complete update */
rgb_update(COLOR_MASK, 1);

// _delay_ms(1);
_delay_ms(50);

#if 1
step++;
if (step == 16) {
step = 0;
x = sequence_chase(x, &xdir, 0x1F1F);
}

uint8_t color[3] = { 0, 0, 0 };
ramp = color_ramp(ramp +1, chan_value[x]);
x = sequence_chase(x, &xdir, 0x1F1F);
ramp = color_ramp(ramp +8, chan_value[x]);
color_div(chan_value[x], 4, chan_decay[x]);

uint8_t i, j;
uint8_t i;
for (i = 0; i < 16; i++) {
if (x != i) {
chan_value[i][0] = 0;
chan_value[i][1] = 0;
chan_value[i][2] = 0;
color_sub(chan_value[i], chan_decay[i], chan_value[i]);
}
}
#endif


Loading…
Cancel
Save