MPM controlled 16ch RGB LED dimmer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.6 KiB

  1. #ifndef _RGB16MPM_H_
  2. #define _RGB16MPM_H_
  3. #define F_CPU 8000000
  4. //#include <util/delay.h>
  5. #define ROW1 PORTB1 /* RED */
  6. #define ROW2 PORTB0 /* GREEN */
  7. #define ROW3 PORTB3 /* BLUE */
  8. #define ROW4 PORTB2 /* not used */
  9. #define RXTX PORTD2 /* RS485 TX enable */
  10. #define LED PORTD3
  11. /* running without mpmboot? */
  12. #define STANDALONE 0
  13. #if (STANDALONE)
  14. #define OSCCAL 0xAA
  15. #define BAUDRATE 115200
  16. #define MPM_ADDRESS 0x11
  17. #endif /* STANDALONE */
  18. #define VERSION_STRING "rgb16mpm v0.99"
  19. #define COLOR_RED 0
  20. #define COLOR_GREEN 1
  21. #define COLOR_BLUE 2
  22. #define COLOR_MASK ((1<<COLOR_RED) | (1<<COLOR_GREEN) | (1<<COLOR_BLUE))
  23. struct _nvdata {
  24. uint16_t nvram_size; /* first */
  25. uint16_t channels; /* connected channels */
  26. uint8_t initialRGB[16][3]; /* initial color values */
  27. uint8_t demomode; /* initial demo mode */
  28. uint16_t nvram_crc; /* last */
  29. };
  30. #define NVRAM_DEFAULTS {\
  31. .channels = 0xFFFF, \
  32. .initialRGB = { { 0xFF, 0x00, 0x00 }, { 0xFF, 0x80, 0x00 }, { 0xFF, 0xFF, 0x00 }, { 0x80, 0xFF, 0x00 }, \
  33. { 0x00, 0xFF, 0x00 }, { 0x00, 0xFF, 0x80 }, { 0x00, 0xFF, 0xFF }, { 0x00, 0x80, 0xFF }, \
  34. { 0x00, 0x00, 0xFF }, { 0x80, 0x00, 0xFF }, { 0xFF, 0x00, 0xFF }, { 0xFF, 0x00, 0x80 }, \
  35. { 0x20, 0x20, 0x20 }, { 0x40, 0x40, 0x40 }, { 0x80, 0x80, 0x80 }, { 0xFF, 0xFF, 0xFF } \
  36. }, \
  37. .demomode = 0x04, \
  38. };
  39. /* eeprom.c vars */
  40. extern struct _nvdata nvram_data;
  41. /* eeprom.c funcs */
  42. void eeprom_write(void);
  43. void eeprom_read(uint8_t defaults);
  44. /* democode.c funcs */
  45. void demomode_init(uint8_t mode);
  46. extern uint16_t (*demomode_run)(void);
  47. /* demohelper.c funcs */
  48. uint8_t sequence_chase(uint8_t old_value, uint16_t mask);
  49. #define POS_MASK 0x7F
  50. #define DIR_MASK 0x80
  51. #define DIR_UP 0x80
  52. #define DIR_DOWN 0x00
  53. uint16_t color_ramp(uint16_t pos, uint8_t *color);
  54. void color_add(uint8_t *color1, uint8_t *color2, uint8_t *output);
  55. void color_sub(uint8_t *color1, uint8_t *color2, uint8_t *output);
  56. void color_div(uint8_t *color, uint8_t div, uint8_t *output);
  57. /* mpmctrl.c funcs */
  58. void mpm_init(void);
  59. void mpm_check_transfer(void);
  60. /* rgbctrl.c vars */
  61. extern uint8_t chan_value[16][3];
  62. /* rgbctrl.c funcs */
  63. void rgb_init(void);
  64. #define UPDATE_NONE 0x00
  65. #define UPDATE_PARTIAL 0x01
  66. #define UPDATE_BLOCKING 0x02
  67. uint8_t rgb_update(uint8_t dirty_mask, uint8_t update_mode);
  68. #endif /* _RGB16MPM_H_ */