89 lines
2.6 KiB
C
89 lines
2.6 KiB
C
#ifndef _RGB16MPM_H_
|
|
#define _RGB16MPM_H_
|
|
|
|
#define F_CPU 8000000
|
|
//#include <util/delay.h>
|
|
|
|
#define ROW1 PORTB1 /* RED */
|
|
#define ROW2 PORTB0 /* GREEN */
|
|
#define ROW3 PORTB3 /* BLUE */
|
|
#define ROW4 PORTB2 /* not used */
|
|
|
|
#define RXTX PORTD2 /* RS485 TX enable */
|
|
#define LED PORTD3
|
|
|
|
/* running without mpmboot? */
|
|
#define STANDALONE 0
|
|
|
|
#if (STANDALONE)
|
|
#define OSCCAL 0xAA
|
|
#define BAUDRATE 115200
|
|
#define MPM_ADDRESS 0x11
|
|
#endif /* STANDALONE */
|
|
|
|
#define VERSION_STRING "rgb16mpm v0.99"
|
|
|
|
#define COLOR_RED 0
|
|
#define COLOR_GREEN 1
|
|
#define COLOR_BLUE 2
|
|
#define COLOR_MASK ((1<<COLOR_RED) | (1<<COLOR_GREEN) | (1<<COLOR_BLUE))
|
|
|
|
struct _nvdata {
|
|
uint16_t nvram_size; /* first */
|
|
uint16_t channels; /* connected channels */
|
|
uint8_t initialRGB[16][3]; /* initial color values */
|
|
uint8_t demomode; /* initial demo mode */
|
|
uint16_t nvram_crc; /* last */
|
|
};
|
|
|
|
#define NVRAM_DEFAULTS {\
|
|
.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 = 0x04, \
|
|
};
|
|
|
|
/* eeprom.c vars */
|
|
extern struct _nvdata nvram_data;
|
|
|
|
/* eeprom.c funcs */
|
|
void eeprom_write(void);
|
|
void eeprom_read(uint8_t defaults);
|
|
|
|
/* democode.c funcs */
|
|
void demomode_init(uint8_t mode);
|
|
extern uint16_t (*demomode_run)(void);
|
|
|
|
/* demohelper.c funcs */
|
|
uint8_t sequence_chase(uint8_t old_value, uint16_t mask);
|
|
|
|
#define POS_MASK 0x7F
|
|
#define DIR_MASK 0x80
|
|
#define DIR_UP 0x80
|
|
#define DIR_DOWN 0x00
|
|
uint16_t color_ramp(uint16_t pos, uint8_t *color);
|
|
|
|
void color_add(uint8_t *color1, uint8_t *color2, uint8_t *output);
|
|
void color_sub(uint8_t *color1, uint8_t *color2, uint8_t *output);
|
|
void color_div(uint8_t *color, uint8_t div, uint8_t *output);
|
|
|
|
/* mpmctrl.c funcs */
|
|
void mpm_init(void);
|
|
void mpm_check_transfer(void);
|
|
|
|
/* rgbctrl.c vars */
|
|
extern uint8_t chan_value[16][3];
|
|
|
|
/* rgbctrl.c funcs */
|
|
void rgb_init(void);
|
|
|
|
#define UPDATE_NONE 0x00
|
|
#define UPDATE_PARTIAL 0x01
|
|
#define UPDATE_BLOCKING 0x02
|
|
uint8_t rgb_update(uint8_t dirty_mask, uint8_t update_mode);
|
|
|
|
#endif /* _RGB16MPM_H_ */
|