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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

rgb.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. Copyright 2014 Kai Ryu <[email protected]>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef RGB_H
  15. #define RGB_H
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. enum rgb_mode_id {
  19. RGB_FIXED = 0,
  20. RGB_VARIABLE
  21. };
  22. enum rgb_fixed_id {
  23. RGB_FIXED_WHITE = 0,
  24. RGB_FIXED_RED,
  25. RGB_FIXED_GREEN,
  26. RGB_FIXED_BLUE,
  27. RGB_FIXED_RED_1,
  28. RGB_FIXED_GREEN_1,
  29. RGB_FIXED_BLUE_1,
  30. RGB_FIXED_RED_2,
  31. RGB_FIXED_GREEN_2,
  32. RGB_FIXED_BLUE_2,
  33. RGB_FIXED_RED_3,
  34. RGB_FIXED_GREEN_3,
  35. RGB_FIXED_BLUE_3,
  36. RGB_FIXED_RED_4,
  37. RGB_FIXED_GREEN_4,
  38. RGB_FIXED_BLUE_4,
  39. RGB_FIXED_COUNT
  40. };
  41. enum rgb_variable_id {
  42. RGB_VARIABLE_FLASH = 0,
  43. RGB_VARIABLE_STROBE,
  44. RGB_VARIABLE_FADE,
  45. RGB_VARIABLE_SMOOTH,
  46. RGB_VARIABLE_COUNT
  47. };
  48. typedef union {
  49. uint8_t raw;
  50. struct {
  51. uint8_t id :4;
  52. uint8_t mode :3;
  53. bool enable :1;
  54. };
  55. } rgb_config_t;
  56. #define EECONFIG_RGB (uint8_t *)7
  57. #define RGB_UNCONFIGURED 0xFF
  58. void rgb_init(void);
  59. void rgb_resume(void);
  60. void rgb_read_config(void);
  61. void rgb_write_config(void);
  62. void rgb_on(void);
  63. void rgb_off(void);
  64. void rgb_toggle(void);
  65. void rgb_increase(void);
  66. void rgb_decrease(void);
  67. void rgb_set(uint8_t mode, uint8_t id);
  68. void rgb_step(uint8_t mode);
  69. uint8_t rgb_to_yc059(uint8_t mode, uint8_t id);
  70. #endif