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.

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