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.

98 lines
2.5 KiB

  1. /* Copyright 2021
  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. #pragma once
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include "color.h"
  20. #if defined(__GNUC__)
  21. # define PACKED __attribute__((__packed__))
  22. #else
  23. # define PACKED
  24. #endif
  25. #if defined(_MSC_VER)
  26. # pragma pack(push, 1)
  27. #endif
  28. #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
  29. # define RGB_MATRIX_KEYREACTIVE_ENABLED
  30. #endif
  31. // Last led hit
  32. #ifndef LED_HITS_TO_REMEMBER
  33. # define LED_HITS_TO_REMEMBER 8
  34. #endif // LED_HITS_TO_REMEMBER
  35. #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
  36. typedef struct PACKED {
  37. uint8_t count;
  38. uint8_t x[LED_HITS_TO_REMEMBER];
  39. uint8_t y[LED_HITS_TO_REMEMBER];
  40. uint8_t index[LED_HITS_TO_REMEMBER];
  41. uint16_t tick[LED_HITS_TO_REMEMBER];
  42. } last_hit_t;
  43. #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
  44. typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states;
  45. typedef uint8_t led_flags_t;
  46. typedef struct PACKED {
  47. uint8_t iter;
  48. led_flags_t flags;
  49. bool init;
  50. } effect_params_t;
  51. typedef struct PACKED {
  52. uint8_t x;
  53. uint8_t y;
  54. } point_t;
  55. #define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
  56. #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00)
  57. #define LED_FLAG_ALL 0xFF
  58. #define LED_FLAG_NONE 0x00
  59. #define LED_FLAG_MODIFIER 0x01
  60. #define LED_FLAG_UNDERGLOW 0x02
  61. #define LED_FLAG_KEYLIGHT 0x04
  62. #define LED_FLAG_INDICATOR 0x08
  63. #define NO_LED 255
  64. typedef struct PACKED {
  65. uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
  66. point_t point[DRIVER_LED_TOTAL];
  67. uint8_t flags[DRIVER_LED_TOTAL];
  68. } led_config_t;
  69. typedef union {
  70. uint32_t raw;
  71. struct PACKED {
  72. uint8_t enable : 2;
  73. uint8_t mode : 6;
  74. HSV hsv;
  75. uint8_t speed; // EECONFIG needs to be increased to support this
  76. led_flags_t flags;
  77. };
  78. } rgb_config_t;
  79. #if defined(_MSC_VER)
  80. # pragma pack(pop)
  81. #endif