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.

134 lines
3.9 KiB

7 years ago
7 years ago
7 years ago
  1. /* Copyright 2017 Yang Liu
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef RGBLIGHT_H
  17. #define RGBLIGHT_H
  18. #ifdef RGBLIGHT_ANIMATIONS
  19. #define RGBLIGHT_MODES 34
  20. #else
  21. #define RGBLIGHT_MODES 1
  22. #endif
  23. #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
  24. #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4
  25. #endif
  26. #ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH
  27. #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3
  28. #endif
  29. #ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
  30. #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0
  31. #endif
  32. #ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM
  33. #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM
  34. #endif
  35. #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL
  36. #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000
  37. #endif
  38. #ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP
  39. #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2
  40. #endif
  41. #ifndef RGBLIGHT_HUE_STEP
  42. #define RGBLIGHT_HUE_STEP 10
  43. #endif
  44. #ifndef RGBLIGHT_SAT_STEP
  45. #define RGBLIGHT_SAT_STEP 17
  46. #endif
  47. #ifndef RGBLIGHT_VAL_STEP
  48. #define RGBLIGHT_VAL_STEP 17
  49. #endif
  50. #define RGBLED_TIMER_TOP F_CPU/(256*64)
  51. // #define RGBLED_TIMER_TOP 0xFF10
  52. #include <stdint.h>
  53. #include <stdbool.h>
  54. #include "eeconfig.h"
  55. #ifndef RGBLIGHT_CUSTOM_DRIVER
  56. #include "ws2812.h"
  57. #endif
  58. #include "rgblight_types.h"
  59. extern LED_TYPE led[RGBLED_NUM];
  60. extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
  61. extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
  62. extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM;
  63. extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM;
  64. extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM;
  65. typedef union {
  66. uint32_t raw;
  67. struct {
  68. bool enable :1;
  69. uint8_t mode :6;
  70. uint16_t hue :9;
  71. uint8_t sat :8;
  72. uint8_t val :8;
  73. };
  74. } rgblight_config_t;
  75. void rgblight_init(void);
  76. void rgblight_increase(void);
  77. void rgblight_decrease(void);
  78. void rgblight_toggle(void);
  79. void rgblight_enable(void);
  80. void rgblight_step(void);
  81. void rgblight_step_reverse(void);
  82. uint32_t rgblight_get_mode(void);
  83. void rgblight_mode(uint8_t mode);
  84. void rgblight_set(void);
  85. void rgblight_update_dword(uint32_t dword);
  86. void rgblight_increase_hue(void);
  87. void rgblight_decrease_hue(void);
  88. void rgblight_increase_sat(void);
  89. void rgblight_decrease_sat(void);
  90. void rgblight_increase_val(void);
  91. void rgblight_decrease_val(void);
  92. void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
  93. void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b);
  94. uint32_t eeconfig_read_rgblight(void);
  95. void eeconfig_update_rgblight(uint32_t val);
  96. void eeconfig_update_rgblight_default(void);
  97. void eeconfig_debug_rgblight(void);
  98. void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
  99. void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1);
  100. void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
  101. #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF)
  102. void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b);
  103. void rgblight_task(void);
  104. void rgblight_timer_init(void);
  105. void rgblight_timer_enable(void);
  106. void rgblight_timer_disable(void);
  107. void rgblight_timer_toggle(void);
  108. void rgblight_effect_breathing(uint8_t interval);
  109. void rgblight_effect_rainbow_mood(uint8_t interval);
  110. void rgblight_effect_rainbow_swirl(uint8_t interval);
  111. void rgblight_effect_snake(uint8_t interval);
  112. void rgblight_effect_knight(uint8_t interval);
  113. void rgblight_effect_christmas(void);
  114. #endif