Working version
This commit is contained in:
parent
fa8bc109cd
commit
7c68c99ac0
2
Makefile
2
Makefile
@ -10,7 +10,7 @@ SRC = $(wildcard *.c)
|
||||
OUTPUTS = .hex .bin _eeprom.hex _eeprom.bin
|
||||
|
||||
CFLAGS = -Os -g -Wall -mmcu=$(MCU_TARGET)
|
||||
CFLAGS += -pipe -MMD -MP -MG -MF $(BUILD_DIR)/$(*D)/$(*F).d
|
||||
CFLAGS += -pipe -MMD -MP -MF $(BUILD_DIR)/$(*D)/$(*F).d
|
||||
LDFLAGS = -Wl,-Map,$(BUILD_DIR)/$(*D)/$(*F).map,--cref
|
||||
|
||||
CC = avr-gcc
|
||||
|
65
democode.c
65
democode.c
@ -23,9 +23,8 @@
|
||||
#include "rgb16mpm.h"
|
||||
|
||||
struct dm001data {
|
||||
uint8_t color;
|
||||
uint8_t pos;
|
||||
uint16_t ramp;
|
||||
uint8_t decay[16][3];
|
||||
};
|
||||
|
||||
struct dm002data {
|
||||
@ -33,6 +32,12 @@ struct dm002data {
|
||||
};
|
||||
|
||||
struct dm003data {
|
||||
uint8_t pos;
|
||||
uint16_t ramp;
|
||||
uint8_t decay[16][3];
|
||||
};
|
||||
|
||||
struct dm004data {
|
||||
uint8_t step;
|
||||
uint8_t pos[3];
|
||||
};
|
||||
@ -41,6 +46,7 @@ union demodata {
|
||||
struct dm001data dm001;
|
||||
struct dm002data dm002;
|
||||
struct dm003data dm003;
|
||||
struct dm004data dm004;
|
||||
};
|
||||
|
||||
static union demodata demo;
|
||||
@ -55,18 +61,28 @@ static uint16_t demomode001(void)
|
||||
struct dm001data *dm = &demo.dm001;
|
||||
|
||||
dm->pos = sequence_chase(dm->pos, nvram_data.channels);
|
||||
|
||||
uint8_t pos = dm->pos & POS_MASK;
|
||||
dm->ramp = color_ramp(dm->ramp +8, chan_value[pos]);
|
||||
color_div(chan_value[pos], 4, dm->decay[pos]);
|
||||
|
||||
uint8_t chan;
|
||||
for (chan = 0; chan < 16; chan++) {
|
||||
if (chan != pos) {
|
||||
color_sub(chan_value[chan], dm->decay[chan], chan_value[chan]);
|
||||
chan_value[chan][COLOR_RED] = 0x00;
|
||||
chan_value[chan][COLOR_GREEN] = 0x00;
|
||||
chan_value[chan][COLOR_BLUE] = 0x00;
|
||||
} else {
|
||||
chan_value[chan][dm->color] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
return 50;
|
||||
if (pos == 0) {
|
||||
dm->color++;
|
||||
if (dm->color == 3) {
|
||||
dm->color = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 250;
|
||||
}
|
||||
|
||||
static uint16_t demomode002(void)
|
||||
@ -83,13 +99,32 @@ static uint16_t demomode002(void)
|
||||
chan_value[chan][COLOR_BLUE] = color[COLOR_BLUE];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 50;
|
||||
}
|
||||
|
||||
static uint16_t demomode003(void)
|
||||
{
|
||||
struct dm003data *dm = &demo.dm003;
|
||||
|
||||
dm->pos = sequence_chase(dm->pos, nvram_data.channels);
|
||||
uint8_t pos = dm->pos & POS_MASK;
|
||||
dm->ramp = color_ramp(dm->ramp +8, chan_value[pos]);
|
||||
color_div(chan_value[pos], 8, dm->decay[pos]);
|
||||
|
||||
uint8_t chan;
|
||||
for (chan = 0; chan < 16; chan++) {
|
||||
if (chan != pos) {
|
||||
color_sub(chan_value[chan], dm->decay[chan], chan_value[chan]);
|
||||
}
|
||||
}
|
||||
|
||||
return 50;
|
||||
}
|
||||
|
||||
static uint16_t demomode004(void)
|
||||
{
|
||||
struct dm004data *dm = &demo.dm004;
|
||||
|
||||
uint8_t color;
|
||||
|
||||
dm->step++;
|
||||
@ -132,8 +167,6 @@ void demomode_init(uint8_t mode)
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
/* rgb chase */
|
||||
demo.dm001.pos = DIR_UP | 0;
|
||||
demomode_run = demomode001;
|
||||
break;
|
||||
|
||||
@ -143,13 +176,19 @@ void demomode_init(uint8_t mode)
|
||||
break;
|
||||
|
||||
case 0x03:
|
||||
/* three color chaser */
|
||||
demo.dm003.pos[COLOR_RED] = DIR_UP | 0;
|
||||
demo.dm003.pos[COLOR_GREEN] = DIR_UP | 9;
|
||||
demo.dm003.pos[COLOR_BLUE] = DIR_DOWN | 9;
|
||||
/* rgb chase */
|
||||
demo.dm003.pos = DIR_UP | 0;
|
||||
demomode_run = demomode003;
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
/* three color chaser */
|
||||
demo.dm004.pos[COLOR_RED] = DIR_UP | 0;
|
||||
demo.dm004.pos[COLOR_GREEN] = DIR_UP | 9;
|
||||
demo.dm004.pos[COLOR_BLUE] = DIR_DOWN | 9;
|
||||
demomode_run = demomode004;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* stay black */
|
||||
demomode_run = demomode000;
|
||||
|
@ -37,13 +37,13 @@ struct _nvdata {
|
||||
};
|
||||
|
||||
#define NVRAM_DEFAULTS {\
|
||||
.channels = 0x1F1F, \
|
||||
.channels = 0xFFFF, \
|
||||
.initialRGB = { { 0xFF, 0x00, 0x00 }, { 0xFF, 0x80, 0x00 }, { 0xFF, 0xFF, 0x00 }, { 0x80, 0xFF, 0x00 }, \
|
||||
{ 0x00, 0xFF, 0x00 }, { 0x00, 0xFF, 0x80 }, { 0x00, 0xFF, 0xFF }, { 0x00, 0x80, 0xFF }, \
|
||||
{ 0x00, 0x00, 0xFF }, { 0x80, 0x00, 0xFF }, { 0xFF, 0x00, 0xFF }, { 0xFF, 0x00, 0x80 }, \
|
||||
{ 0x20, 0x20, 0x20 }, { 0x40, 0x40, 0x40 }, { 0x80, 0x80, 0x80 }, { 0xFF, 0xFF, 0xFF } \
|
||||
}, \
|
||||
.demomode = 0x03, \
|
||||
.demomode = 0x04, \
|
||||
};
|
||||
|
||||
/* eeprom.c vars */
|
||||
|
Loading…
Reference in New Issue
Block a user